InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport);
Connector connector = new Connector(locator, sconfig);
connector.create();
// Set ServerSocketFactory and SocketFactory in ServerInvoker.
ServerInvoker serverInvoker = connector.getServerInvoker();
ServerSocketFactory ssf1 = getDefaultServerSocketFactory();
serverInvoker.setServerSocketFactory(ssf1);
SocketFactory sf1 = getDefaultCallbackSocketFactory();
serverInvoker.setSocketFactory(sf1);
connector.addInvocationHandler("sample", new SampleInvocationHandler());
connector.start();
/////////////////////////////////////
///// Set up client side. ////
/////////////////////////////////////
HashMap cconfig = new HashMap();
// Make Client use remote invoker.
cconfig.put(InvokerLocator.FORCE_REMOTE, "true");
// Create Client.
Client client = new Client(locator, cconfig);
client.connect();
// Set SocketFactory in ClientInvoker.
SocketFactory sf2 = getDefaultSocketFactory();
ClientInvoker clientInvoker = client.getInvoker();
clientInvoker.setSocketFactory(sf2);
System.out.println(getName() + ": " + client.invoke("test invoke()"));
//////////////////////////////////////////////
///// Set up callback handling. ////
//////////////////////////////////////////////
// Start callback Connector.
freeport = PortUtil.findFreePort(getHostName());
InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport);
Connector callbackConnector = new Connector(callbackLocator.getLocatorURI());
callbackConnector.create();
ServerInvoker callbackServerInvoker = callbackConnector.getServerInvoker();
ServerSocketFactory ssf2 = getDefaultCallbackServerSocketFactory();
callbackServerInvoker.setServerSocketFactory(ssf2);
callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler());
callbackConnector.start();
// Add callback handler.
CallbackHandler callbackHandler = new CallbackHandler();