public void open() throws NodeException {
try {
protocol = newProtocol();
} catch (ProtocolException e) {
throw new NodeException("Can not create protocol", e);
}
Protocol curProtocol = protocol;
while ( null != curProtocol ) {
if ( curProtocol instanceof CallbackSocketProtocol ) {
((CallbackSocketProtocol) curProtocol).setListener(
new SocketProtocolListener() {
public void onClose() {
msgOut = null;
inDispatcher = null;
if ( null != listener ) {
listener.onClose();
}
}
});
break;
}
curProtocol = curProtocol.getDownProtocol();
}
if ( false == curProtocol instanceof CallbackSocketProtocol ) {
throw new AssertionError("No CallbackSocketProtocol.");
}
StreamManager streamManager = ioContext.getStreamManager();
ReplacerResolver replacerResolver = ioContext.getReplacerResolver();
PushSynchronization pushSynchronization =
ioContext.getPushSynchronization();
PopSynchronization popSynchronization =
ioContext.getPopSynchronization();
try {
msgOut = new ProtocolOutInterceptor(protocol,
streamManager, pushSynchronization, replacerResolver);
inDispatcher = new ProtocolInDispatcher(protocol,
streamManager, popSynchronization, replacerResolver);
} catch (IOException e) {
throw new NodeException("Can not set-up IO context.", e);
}
}