Package org.jboss.netty.bootstrap

Examples of org.jboss.netty.bootstrap.ClientBootstrap


  private final Condition _shutdownReqCondition = _lock.newCondition();
  private final Condition _shutdownCondition = _lock.newCondition();

  public SimpleTestClientConnection(ByteOrder bufferByteOrder)
  {
    _clientBootstrap = new ClientBootstrap(new DefaultLocalClientChannelFactory());
    _clientBootstrap.setOption("bufferFactory",
                               DirectChannelBufferFactory.getInstance(bufferByteOrder));
  }
View Full Code Here


  }

  static ChannelFuture createChannelFuture(final GenericHttpResponseHandler responseHandler, int port)
  {

    ClientBootstrap client = new ClientBootstrap(
        new NioClientSocketChannelFactory(BOSS_POOL, IO_POOL));
    client.setPipelineFactory(new ChannelPipelineFactory()
    {
      @Override
      public ChannelPipeline getPipeline() throws Exception
      {
        return Channels.pipeline(new LoggingHandler(InternalLogLevel.DEBUG),
            new HttpClientCodec(), new LoggingHandler(InternalLogLevel.DEBUG),
            responseHandler);
      }
    });
    final ChannelFuture connectFuture = client.connect(new InetSocketAddress(
        "localhost", port));
    return connectFuture;
  }
View Full Code Here

  {
    Checkpoint ckpt = Checkpoint.createOnlineConsumptionCheckpoint(scn);
    //TODO why is this needed
    //ckpt.setCatchupSource("foo");
    String uristr = "/stream?sources=105&output=json&size=" + fetchSize + "&streamFromLatestScn=false&checkPoint=" + ckpt.toString();
    ClientBootstrap bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(),
                                                                                      Executors.newCachedThreadPool()));
    bootstrap.setPipelineFactory(new HttpClientPipelineFactory(handler));
    ChannelFuture future = bootstrap.connect(new InetSocketAddress("localhost", relayPort));
    Channel channel = future.awaitUninterruptibly().getChannel();
    Assert.assertTrue(future.isSuccess(), "Cannot connect to relay at localhost:" + relayPort);
    HttpRequest request  = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uristr);
    request.setHeader(HttpHeaders.Names.HOST, "localhost");
    channel.write(request);
View Full Code Here

    _serverChannel = _serverBootstrap.bind(_serverAddress);
  }

  private void setupClient()
  {
    _clientBootstrap = new ClientBootstrap(new DefaultLocalClientChannelFactory());

    _clientBootstrap.setPipelineFactory(new ChannelPipelineFactory()
    {
      @Override
      public ChannelPipeline getPipeline() throws Exception
View Full Code Here

        _channelGroup = new DefaultChannelGroup();;
      }

      public TestClientConnection createConnection(ServerInfo relay, List<MsgState> msgList)
      {
        return new TestClientConnection(relay, new ClientBootstrap(_channelFactory), null, _timeoutTimer,
                                        _clientConfig, _channelGroup, msgList,
                                        15000, Logger.getLogger(TestClientConnectionFactory.class));
      }
View Full Code Here

                                             int protocolVersion,
                                             ChannelGroup channelGroup)
  {
    this(relay,
         callback,
         new ClientBootstrap(channelFactory),
         containerStatsCollector,
         remoteExceptionHandler,
         timeoutTimer,
         writeTimeoutMs,
         readTimeoutMs,
View Full Code Here

                                         int maxEventVersion,
                                         ChannelGroup channelGroup)
  {
    this(relay,
         callback,
         new ClientBootstrap(channelFactory), containerStatsCollector, remoteExceptionHandler,
                             timeoutTimer, writeTimeoutMs, readTimeoutMs, protocolVersion,
                             maxEventVersion, channelGroup);
  }
View Full Code Here

  private ClientBootstrap _clientBootstrap;
  private final TimeoutPolicy _timeoutPolicy;

  public SimpleTestHttpClient(ChannelFactory channelFactory, TimeoutPolicy timeoutPolicy) throws Exception
  {
    _clientBootstrap = new ClientBootstrap(channelFactory);
    ChannelPipeline pipeline = createPipeline();
    _clientBootstrap.setPipeline(pipeline);
    _timeoutPolicy = timeoutPolicy;
  }
View Full Code Here

    workerThreadFactory = new ExecutorThreadFactory("ClientWorkerPool", true);
    bossPool = Executors.newCachedThreadPool(bossThreadFactory);
    workerPool = Executors.newCachedThreadPool(workerThreadFactory);
    channelFactory = new NioClientSocketChannelFactory(bossPool, workerPool);
    pipelineFactory = new ChannelPipelineFactoryImpl(providers);
    bootstrap = new ClientBootstrap(channelFactory);
    bootstrap.setOptions(channelOptions);
    bootstrap.setPipelineFactory(pipelineFactory);
 
View Full Code Here

     * @param url URL to connect to.
     * @param callback Callback interface to receive events
     * @return A WebSocket client. Call {@link WebSocketClient#connect()} to connect.
     */
    public WebSocketClient newClient(final URI url, final WebSocketCallback callback) {
        ClientBootstrap bootstrap = new ClientBootstrap(socketChannelFactory);

        String protocol = url.getScheme();
        if (!protocol.equals("ws") && !protocol.equals("wss")) {
            throw new IllegalArgumentException("Unsupported protocol: " + protocol);
        }

        final WebSocketClientHandler clientHandler = new WebSocketClientHandler(bootstrap, url, callback);

        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
            public ChannelPipeline getPipeline() throws Exception {
                ChannelPipeline pipeline = Channels.pipeline();
                pipeline.addLast("decoder", new HttpResponseDecoder());
                pipeline.addLast("encoder", new HttpRequestEncoder());
                pipeline.addLast("ws-handler", clientHandler);
View Full Code Here

TOP

Related Classes of org.jboss.netty.bootstrap.ClientBootstrap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.