connector.setServerSocketFactory(ServerSocketFactory.getDefault());
// creates all the connector's needed resources, such as the server invoker
connector.create();
RMIServerInvoker invoker = (RMIServerInvoker) connector.getServerInvoker();
invoker.setSocketFactory(new SocketFactoryMock());
// create the handler to receive the invocation request from the client for processing
SampleInvocationHandler invocationHandler = new SampleInvocationHandler();
// first parameter is sub-system name. can be any String value.
connector.addInvocationHandler("sample", invocationHandler);