Caucho Forums  

This forum is permanently closed because of spam. For free community support, please visit Google Groups:


Go Back   Caucho Forums > Hessian

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-17-2011, 09:59 AM
nhinhi nhinhi is offline
Junior Member
 
Join Date: Aug 2011
Posts: 2
Default how to create mutilple hessian client?

Hi all,
Look at my code below:
//service
public interface WordService {
/**
* Submits a poem as a List of Words to the service.
**/
public String hello();

public void initWord(String word);
}
//implement service
public class WordServiceImpl extends HessianServlet implements WordService{
String word;
public String hello() {
return word;
}

public void initWord(String word) {
this.word = word;
}
}
//client
public class WordClient {
/** The client proxy for the WordService. */
private WordService _service;
public WordClient(String url, String word) {
HessianProxyFactory factory = new HessianProxyFactory();
try {
_service = (WordService) factory.create(WordService.class, url);
_service.initWord(word);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}

public void helloClient() {
if(_service != null)
System.out.println(_service.hello());
}

public static void main(String[] args) {
String url = "http://localhost:8080/Word/Word";
WordClient client = new WordClient(url, "Word"
client.helloClient(); //will print Word
WordClient client1 = new WordClient(url, "Word 1"
client.helloClient(); //will print Word 1 ( ->here, I would like to print Word )
client1.helloClient(); //will print Word 1
}
}

I mean on client side, if I create multiple client, the last created client will override other clients. I don't know what's wrong?
Thanks
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:27 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.