callbackHandler = new CallbackHandler(); callbackClient.addListener(callbackHandler, callbackMetadata);
/** * Adds the specified handler as a callback listener for push (async) callbacks. If the transport * is uni-directional (e.g. http), remoting will automatically poll for callbacks from the server * and deliver them to the callback handler. If the transport is bi-directional (e.g. multiplex), * remoting will automatically create a callback server internally and receive and deliver to * callback handler the callbacks as they are generated on the server. The metadata map passed * will control configuration for how the callbacks are processed, such as the polling frequency. */ public void addListener(InvokerCallbackHandler callbackhandler, Map metadata) throws Throwable { addListener(callbackhandler, metadata, null); }
/** * Adds the specified handler as a callback listener for pull (sync) callbacks. Using this method * will require the programatic getting of callbacks from the server (they will not be pushed to * the callback handler automatically). */ public void addListener(InvokerCallbackHandler callbackHandler) throws Throwable { addListener(callbackHandler, (InvokerLocator) null); }
/** * Adds the specified handler as a callback listener for push (async) callbacks. The invoker * server will then callback on this handler (via the server invoker specified by the * clientLocator) when it gets a callback from the server handler. * * Note: passing a null clientLocator will cause the client invoker's client locator to be set to * null, which basically converts the mode to be pull (sync) where will require call to get * callbacks (as will not automatically be pushed to callback handler). */ public void addListener(InvokerCallbackHandler callbackHandler, InvokerLocator clientLocator) throws Throwable { addListener(callbackHandler, clientLocator, null); }
/** * Adds the specified handler as a callback listener for push (async) callbacks. If the transport * is uni-directional (e.g. http), remoting will automatically poll for callbacks from the server * and deliver them to the callback handler. If the transport is bi-directional (e.g. multiplex), * remoting will automatically create a callback server internally and receive and deliver to * callback handler the callbacks as they are generated on the server. The metadata map passed * will control configuration for how the callbacks are processed, such as the polling frequency. * * @param callbackHandlerObject - this object will be included in the Callback object instance * passed to the InvokerCallbackHandler specified. */ public void addListener(InvokerCallbackHandler callbackhandler, Map metadata, Object callbackHandlerObject) throws Throwable { addListener(callbackhandler, metadata, callbackHandlerObject, false); }
public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); }
public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); }
public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); }
public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); }
public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); }
public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); }
/** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. Acknowledgements are handled implicitly * by Remoting. */ public void testPolledCallbackRemotingAcknowledgements() { try { // Register callback handler. InvokerCallbackHandler callbackHandler = new NonAcknowledgingCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "1000"); client.addListener(callbackHandler, metadata); // Request callbacks from server. client.invoke(CallbackAcknowledgeServer.REMOTING_ACKNOWLDEGEMENTS); Thread.sleep(2000); // Unregister callback handler. client.removeListener(callbackHandler); } catch (Throwable e) { System.out.println("failure: " + e.getMessage()); } }
/** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. Acknowledgements are made from * TestCallbackHandler.handleCallback() by an explicit call to * Client.acknowledgeCallback() after the callbacks have been received. */ public void testPolledCallbackApplicationAcknowledgements() { try { // Register callback handler. InvokerCallbackHandler callbackHandler = new AcknowledgingCallbackHandler(client); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "1000"); client.addListener(callbackHandler, metadata); // Request callbacks from server. client.invoke(CallbackAcknowledgeServer.APPLICATION_ACKNOWLDEGEMENTS); Thread.sleep(2000); // Unregister callback handler. client.removeListener(callbackHandler); } catch (Throwable e) { System.out.println("failure: " + e.getMessage()); } }
/** * In this test the connection is configured for true push callbacks, and * Acknowledgements are handled implicitly by Remoting. */ public void testPushCallbackRemotingAcknowledgements() { try { // Register callback handler. InvokerCallbackHandler callbackHandler = new NonAcknowledgingCallbackHandler(); client.addListener(callbackHandler, null, null, true); // Request callbacks from server. client.invoke(CallbackAcknowledgeServer.REMOTING_ACKNOWLDEGEMENTS); // Unregister callback handler. client.removeListener(callbackHandler); } catch (Throwable e) { System.out.println("failure: " + e.getMessage()); } }
/** * In this test the connection is configured for true push callbacks. * Acknowledgements are made from TestCallbackHandler.handleCallback() * by an explicit call to Client.acknowledgeCallback() after the callbacks * have been received. */ public void testPushCallbackApplicationAcknowledgements() { try { // Register callback handler. InvokerCallbackHandler callbackHandler = new AcknowledgingCallbackHandler(client); client.addListener(callbackHandler, null, null, true); // Request callbacks from servrr. client.invoke(CallbackAcknowledgeServer.APPLICATION_ACKNOWLDEGEMENTS); // Unregister callback handler. client.removeListener(callbackHandler); } catch (Throwable e) { System.out.println("failure: " + e.getMessage()); } }
/** * Shows how to register for pull callbacks and then get any callbacks * that are waiting on the server. * * @throws Throwable */ public void testPullCallback() throws Throwable { // our impplementation of the InvokerCallbackHandler interface, which // is defined as an inner class below. CallbackHandler callbackHandler = new CallbackHandler(); // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(callbackHandler); // the callback server generates callback messages on its own and need // to give a few seconds to generate them. Thread.currentThread().sleep(2000); // call also make regular invocations on the server at any time. makeInvocation(); // go get our callbacks residing on the server List callbacks = remotingClient.getCallbacks(callbackHandler); Iterator itr = callbacks.iterator(); while(itr.hasNext()) { Callback callbackObject = (Callback) itr.next(); System.out.println("Pull Callback value = " + callbackObject.getCallbackObject()); } // remove callback handler from server remotingClient.removeListener(callbackHandler); }
/** * Registers callback listener and asks CallbackPoller to print statistics. */ public void getPolledCallbacks(String locatorURI) throws Throwable { System.out.println("Calling remoting server with locator uri of: " + locatorURI); InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); // Registter callback handler and tell CallbackPoller to report statistics. CallbackHandler callbackHandler = new CallbackHandler(); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.REPORT_STATISTICS, "true"); client.addListener(callbackHandler, metadata); // Wait for callbacks to received, processed, and acknowledged. Thread.sleep(20000); // remove callback handler from server client.removeListener(callbackHandler); client.disconnect(); }
client.addListener(callbackHandler);
remotingClient.addListener(callbackHandler, callbackLocator, callbackHandleObject);
receiverLocator = receiverConnector.getLocator(); InvokerCallbackHandler receiverHandler = new ChatReceiverHandler(talkFrame); serverClient.addListener(receiverHandler, receiverLocator, newMember);