Java Code Examples for io.netty.bootstrap.AbstractBootstrap

The following are top voted examples for showing how to use io.netty.bootstrap.AbstractBootstrap. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: yajsw   File: ReconnectHandler.java   View source code 6 votes vote down vote up
protected void connect(AbstractBootstrap bootstrap)
{
	Channel channel = null;
	Constants.ahessianLogger.warn("reconnecting...");
	while (channel == null && !_stop)
		try
		{
			channel = ((Bootstrap) bootstrap).connect().sync().channel();
		}
		catch (Exception ex)
		{
			if (ex instanceof ConnectException)
			{
				System.out.println(ex);
				try
				{
					Thread.sleep(RECONNECT_DELAY);
				}
				catch (InterruptedException e)
				{
					e.printStackTrace();
				}
			}
		}

}
 
Example 2
Project: netty4.0.27Learn   File: SocketTestPermutation.java   View source code 6 votes vote down vote up
protected <A extends AbstractBootstrap<?, ?>, B extends AbstractBootstrap<?, ?>>
List<BootstrapComboFactory<A, B>> combo(List<BootstrapFactory<A>> sbfs, List<BootstrapFactory<B>> cbfs) {

    List<BootstrapComboFactory<A, B>> list = new ArrayList<BootstrapComboFactory<A, B>>();

    // Populate the combinations
    for (BootstrapFactory<A> sbf: sbfs) {
        for (BootstrapFactory<B> cbf: cbfs) {
            final BootstrapFactory<A> sbf0 = sbf;
            final BootstrapFactory<B> cbf0 = cbf;
            list.add(new BootstrapComboFactory<A, B>() {
                @Override
                public A newServerInstance() {
                    return sbf0.newInstance();
                }

                @Override
                public B newClientInstance() {
                    return cbf0.newInstance();
                }
            });
        }
    }

    return list;
}
 
Example 3
Project: netty4.0.27Learn   File: EpollReuseAddrTest.java   View source code 5 votes vote down vote up
private static void testMultipleBindDatagramChannelWithoutReusePortFails0(AbstractBootstrap<?, ?> bootstrap) {
    bootstrap.handler(new DummyHandler());
    ChannelFuture future = bootstrap.bind().syncUninterruptibly();
    try {
        bootstrap.bind().syncUninterruptibly();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof IOException);
    }
    future.channel().close().syncUninterruptibly();
}
 
Example 4
Project: jreactive-8583   File: Iso8583ChannelInitializerTest.java   View source code 5 votes vote down vote up
@Test
public void testInitChannelWithLogger() throws Exception {
    //given
    configurationBuilder.withAddLoggingHandler(true);
    Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> channelInitializer = createChannelInitializer(configurer);

    // when
    channelInitializer.initChannel(channel);

    //then
    verify(pipeline).addLast(same(workerGroup), eq("logging"), any(IsoMessageLoggingHandler.class));
}
 
Example 5
Project: jreactive-8583   File: Iso8583ChannelInitializerTest.java   View source code 5 votes vote down vote up
@Test
public void testInitChannelWithoutLogger() throws Exception {
    //given
    configurationBuilder.withAddLoggingHandler(false);

    Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> channelInitializer = createChannelInitializer(configurer);

    //when
    channelInitializer.initChannel(channel);

    //then
    verify(pipeline, never()).addLast(any(EventLoopGroup.class), anyString(), any(IsoMessageLoggingHandler.class));
}
 
Example 6
Project: jreactive-8583   File: Iso8583ChannelInitializerTest.java   View source code 5 votes vote down vote up
private Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> createChannelInitializer(ConnectorConfigurer<ConnectorConfiguration, AbstractBootstrap> configurer) {
    return new Iso8583ChannelInitializer<>(
            configurationBuilder.build(),
            configurer,
            workerGroup,
            messageFactory,
            handlers);
}
 
Example 7
Project: jreactive-8583   File: AbstractIso8583ConnectorTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    compositeIsoMessageHandler = new CompositeIsoMessageHandler<>();
    subject = new AbstractIso8583Connector<ConnectorConfiguration, AbstractBootstrap, M>(
            config, messageFactory, compositeIsoMessageHandler
    ) {
        @Override
        protected AbstractBootstrap createBootstrap() {
            throw new UnsupportedOperationException("Method is not implemented: .createBootstrap");
        }
    };
}
 
Example 8
Project: yajsw   File: ChannelPipelineFactoryFactory.java   View source code 4 votes vote down vote up
public ChannelPipelineFactory create(EventExecutorGroup group,
AbstractBootstrap bootstrap);
 
Example 9
Project: yajsw   File: ChannelPipelineFactoryBuilder.java   View source code 4 votes vote down vote up
@Override
public ChannelPipelineFactory create(EventExecutorGroup group,
		AbstractBootstrap bootstrap)
{
	ChannelPipelineFactory result;
	if (isRPCServer() && isRPC() && _serverFactory == null)
	{
		_serverFactory = new HessianRPCServiceHandler(
				Executors.newCachedThreadPool(), _serviceOptions, TIMER);
		_serverFactory.setConnectListener(_connectedListener);
		_serverFactory.setDisconnectListener(_disconnectedListener);
		if (isExecutorService())
			_serverFactory
					.addService(
							"default",
							new ExecutorInvokeService(
									_serverService,
									_serverServiceInterface,
									_serverFactory,
									Executors
											.newFixedThreadPool(_executorThreads)));
		else
			_serverFactory.addService("default",
					new ImmediateInvokeService(_serverService,
							_serverServiceInterface, _serverFactory));
	}
	else if (isRPC() && _clientFactory == null)
	{
		Executor executor = _executorThreads > 0 ? Executors
				.newFixedThreadPool(_executorThreads) : Executors
				.newSingleThreadExecutor();
		String name = "NONAME?";
		_clientFactory = new HessianProxyFactory(executor, name,
				_serviceOptions);
	}

	if (hasSession())
	{
		result = basePipelineFactory(
				mixinPipelineFactory(group, bootstrap), group, bootstrap);
	}
	else
		result = mergePipelineFactory(
				basePipelineFactory(group, bootstrap),
				mixinPipelineFactory(group, bootstrap));

	if (_debug)
		result.debug();

	return result;
}
 
Example 10
Project: yajsw   File: ChannelPipelineFactoryBuilder.java   View source code 4 votes vote down vote up
private ChannelPipelineFactory basePipelineFactory(
		EventExecutorGroup group, AbstractBootstrap bootstrap)
{
	return basePipelineFactory(null, group, bootstrap);
}
 
Example 11
Project: reactor-netty   File: NettyOptions.java   View source code 4 votes vote down vote up
private void defaultNettyOptions(AbstractBootstrap<?, ?> bootstrap) {
	bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
}
 
Example 12
Project: yajsw   File: BootstrapProvider.java   View source code votes vote down vote up
public AbstractBootstrap getBootstrap(); 
Example 13
Project: datacollector   File: BaseNettyServer.java   View source code votes vote down vote up
protected abstract AbstractBootstrap bootstrap(boolean enableEpoll);