@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 stopServer() throws Exception { LOG.debug("In stopServer method of class: {}", this.getClass().getName()); ChannelGroupFuture future = ALL_CHANNELS.close(); try { future.await(); } catch (InterruptedException e) { LOG.error("Execption occurred while waiting for channels to close: {}",e); } serverBootstrap.releaseExternalResources(); gameAdminService.shutdown(); }
if (!isOrderedMap(pipelineMap)) { throw new IllegalArgumentException( "pipelineMap is not an ordered map. " + setPipeline(pipeline);
@Override public void startServer(InetSocketAddress socketAddress) { this.socketAddress = socketAddress; //TODO these should be set from spring serverBootstrap.setOption("broadcast", "false"); serverBootstrap.setOption("receiveBufferSizePredictorFactory", bufferSizePredictor); serverBootstrap.setOption("sendBufferSize", 65536); serverBootstrap.setOption("receiveBufferSize", 65536); configureServerBootStrap(args); try { channel = ((ConnectionlessBootstrap) serverBootstrap) .bind(socketAddress); } catch (ChannelException e) { LOG.error("Unable to start UDP server due to error {}",e); throw e; } }
/** * Creates a new instance with the specified initial {@link ChannelFactory}. */ protected Bootstrap(ChannelFactory channelFactory) { setFactory(channelFactory); }
@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); } }
InetSocketAddress getRemoteAddress() { Resolver resolver = (Resolver) bootstrap.getOption("resolver"); return resolver.resolve(); }
@Override public void stop() { if (acceptChannel != null && acceptChannel.isOpen()) { acceptChannel.close(); } if (bootstrap != null) { bootstrap.shutdown(); } }
@Override protected Bootstrap getBootstrap() { final Bootstrap bootstrap = super.getBootstrap(); bootstrap.setOption("child.keepAlive", tcpKeepalive); return bootstrap; }
/** * Sets the {@link ServerChannelFactory} that will be used to perform an I/O * operation. This method can be called only once and can't be called at * all if the factory was specified in the constructor. * * @throws IllegalStateException * if the factory is already set * @throws IllegalArgumentException * if the specified {@code factory} is not a * {@link ServerChannelFactory} */ @Override public void setFactory(ChannelFactory factory) { if (factory == null) { throw new NullPointerException("factory"); } if (!(factory instanceof ServerChannelFactory)) { throw new IllegalArgumentException( "factory must be a " + ServerChannelFactory.class.getSimpleName() + ": " + factory.getClass()); } super.setFactory(factory); }
public void start() { ResteasyDeployment dp = new ResteasyDeployment(); Collection<Object> providers = ac.getBeansWithAnnotation(Provider.class).values(); Collection<Object> controllers = ac.getBeansWithAnnotation(Controller.class).values(); Assert.notEmpty(controllers); // extract providers if (providers != null) { dp.getProviders().addAll(providers); } // extract only controller annotated beans dp.getResources().addAll(controllers); netty = new ConfigurableNettyJaxrsServer(); netty.initBootstrap().setOption("reuseAddress", true); netty.setDeployment(dp); netty.setPort(port); netty.setRootResourcePath("/resteasy"); netty.setSecurityDomain(null); netty.start(); }
@Override public void run() { log.debug("Releasing " + enlistedResources.size() + " Bootstrap."); for( Bootstrap bootstrap : enlistedResources ) { bootstrap.releaseExternalResources(); } } }
if (!isOrderedMap(pipelineMap)) { throw new IllegalArgumentException( "pipelineMap is not an ordered map. " + setPipeline(pipeline);
/** * Creates a new instance with the specified initial {@link ChannelFactory}. */ protected Bootstrap(ChannelFactory channelFactory) { setFactory(channelFactory); }
/** * Sets the {@link ServerChannelFactory} that will be used to perform an I/O * operation. This method can be called only once and can't be called at * all if the factory was specified in the constructor. * * @throws IllegalStateException * if the factory is already set * @throws IllegalArgumentException * if the specified {@code factory} is not a * {@link ServerChannelFactory} */ @Override public void setFactory(ChannelFactory factory) { if (factory == null) { throw new NullPointerException("factory"); } if (!(factory instanceof ServerChannelFactory)) { throw new IllegalArgumentException( "factory must be a " + ServerChannelFactory.class.getSimpleName() + ": " + factory.getClass()); } super.setFactory(factory); }