@Override public void configureServerBootStrap(String[] optionsList) { // For clients who do not use spring. if(null == serverBootstrap){ createServerBootstrap(); } serverBootstrap.setPipelineFactory(pipelineFactory); if (null != optionsList && optionsList.length > 0) { for (String option : optionsList) { serverBootstrap.setOption(option, true); } } }
@Override public void launch(final MessageInput input) throws MisfireException { final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlerList = getBaseChannelHandlers(input); final LinkedHashMap<String, Callable<? extends ChannelHandler>> finalHandlers = getFinalChannelHandlers(input); handlerList.putAll(finalHandlers); try { bootstrap = getBootstrap(); bootstrap.setPipelineFactory(getPipelineFactory(handlerList)); // sigh, bindable bootstraps do not share a common interface int receiveBufferSize; if (bootstrap instanceof ConnectionlessBootstrap) { acceptChannel = ((ConnectionlessBootstrap) bootstrap).bind(socketAddress); final DefaultDatagramChannelConfig channelConfig = (DefaultDatagramChannelConfig) acceptChannel.getConfig(); receiveBufferSize = channelConfig.getReceiveBufferSize(); } else if (bootstrap instanceof ServerBootstrap) { acceptChannel = ((ServerBootstrap) bootstrap).bind(socketAddress); final ServerSocketChannelConfig channelConfig = (ServerSocketChannelConfig) acceptChannel.getConfig(); receiveBufferSize = channelConfig.getReceiveBufferSize(); } else { log.error("Unknown Netty bootstrap class returned: {}. Cannot safely bind.", bootstrap); throw new IllegalStateException("Unknown netty bootstrap class returned: " + bootstrap + ". Cannot safely bind."); } if (receiveBufferSize != getRecvBufferSize()) { log.warn("receiveBufferSize (SO_RCVBUF) for input {} should be {} but is {}.", input, getRecvBufferSize(), receiveBufferSize); } } catch (Exception e) { throw new MisfireException(e); } }