![]() |
|
#1
|
|||
|
|||
|
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 |
| Thread Tools | |
| Display Modes | |
|
|