this.listener = listener;
}
@Override
public NextAction handleAccept(final FilterChainContext ctx) throws IOException {
final NIOConnection nioConnection = (NIOConnection) ctx.getConnection();
final SelectableChannel channel = nioConnection.getChannel();
if (targetInitializer == null) {
synchronized (LOCK_OBJ) {
if (targetInitializer == null) {
LazyServiceInitializer targetInitializerLocal = null;
for (final ActiveDescriptor<?> initializer : initializerImplList) {
String listenerName = listener.getName();
String serviceName = initializer.getName();
if (serviceName != null && listenerName.equalsIgnoreCase(serviceName)) {
targetInitializerLocal = (LazyServiceInitializer) locator.getServiceHandle(initializer).getService();
break;
}
}
if (targetInitializerLocal == null) {
logger.log(Level.SEVERE, "NO Lazy Initialiser implementation was found for port = {0}",
String.valueOf(listener.getPort()));
nioConnection.close();
return ctx.getStopAction();
}
if (!targetInitializerLocal.initializeService()) {
logger.log(Level.SEVERE, "Lazy Service initialization failed for port = {0}",
String.valueOf(listener.getPort()));
nioConnection.close();
return ctx.getStopAction();
}
targetInitializer = targetInitializerLocal;
}
}
}
final NextAction nextAction = ctx.getSuspendAction();
ctx.completeAndRecycle();
// Deregister channel
final SelectorRunner runner = nioConnection.getSelectorRunner();
final SelectorHandler selectorHandler =
((NIOTransport) nioConnection.getTransport()).getSelectorHandler();
selectorHandler.deregisterChannel(runner, channel);
// Underlying service rely the channel is blocking
channel.configureBlocking(true);