From: Tom E. <tom...@jb...> - 2005-06-16 15:19:39
|
User: telrod Date: 05/06/16 11:19:03 Modified: src/main/org/jboss/remoting Client.java Log: JBREM-134 - updated to handle the adding and removing of multiple callback servers via locator urls. Also added code so will throw exception if callback listener removed and is not registered. Revision Changes Path 1.11 +13 -28 JBossRemoting/src/main/org/jboss/remoting/Client.java (In the diff below, changes in quantity of whitespace are not shown.) Index: Client.java =================================================================== RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/Client.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -b -r1.10 -r1.11 --- Client.java 14 Jun 2005 17:08:17 -0000 1.10 +++ Client.java 16 Jun 2005 15:19:03 -0000 1.11 @@ -29,7 +29,7 @@ * * @author <a href="mailto:jh...@vo...">Jeff Haynie</a> * @author <a href="mailto:te...@e2...">Tom Elrod</a> - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ */ public class Client { @@ -159,27 +159,6 @@ } /** - * This should be set when want to override the default behavior of automatically - * getting s suitable locator. This should be used want want to control what type - * of callbacks to receive (pull or push). Set to null to poll for callback messages. - * This can also be used to receive callbacks using another transport and subsystem, - * if desired. - * - * @param locator - */ - private void setClientLocator(InvokerLocator locator) throws Exception - { - if (invoker != null) - { - invoker.setClientLocator(locator); - } - else - { - throw new Exception("Can not set client locator because client invoker is null."); - } - } - - /** * Invokes the server invoker handler with the payload parameter passed. * @param param * @return @@ -202,6 +181,12 @@ public Object invoke(Object param, Map metadata) throws Throwable { + return invoke(param, metadata, null); + } + + private Object invoke(Object param, Map metadata, InvokerLocator callbackServerLocator) + throws Throwable + { /** * Using a local variable for the invoker as work around so don't have * to sync method (and take performance hit) @@ -233,7 +218,7 @@ throw new Exception("Can not perform invoke because invoker is null."); } - Object ret = localInvoker.invoke(new InvocationRequest(sessionId, subsystem, param, metadata, null, null)); + Object ret = localInvoker.invoke(new InvocationRequest(sessionId, subsystem, param, metadata, null, callbackServerLocator)); this.invoker = localInvoker; return ret; } @@ -376,8 +361,8 @@ if(callbackHandler != null) { Map metadata = createListenerMetadata(callbackHandler); - - invoker.setClientLocator(clientLocator); + String listenerId = (String)metadata.get(LISTENER_ID_KEY); + invoker.addClientLocator(listenerId, clientLocator); if(clientLocator != null) { Client client = new Client(clientLocator, subsystem); @@ -390,7 +375,7 @@ client.disconnect(); } // now call server to add listener - invoke(new InternalInvocation(InternalInvocation.ADDLISTENER, null), metadata); + invoke(new InternalInvocation(InternalInvocation.ADDLISTENER, null), metadata, clientLocator); } else { @@ -418,9 +403,9 @@ if(callbackHandler != null) { Map metadata = createListenerMetadata(callbackHandler); - + String listenerId = (String)metadata.get(LISTENER_ID_KEY); // connect to the given client locator and remove handler as listener - InvokerLocator locator = invoker.getClientLocator(); + InvokerLocator locator = invoker.getClientLocator(listenerId); if(locator != null) // async callback { Client client = new Client(locator, subsystem); |