Examples of ChannelPipeline


Examples of org.jboss.netty.channel.ChannelPipeline

        res.addHeader("Cache-Control", "no-cache");
        res.setChunked(false);
    }

    protected void adjustPipeline(ChannelHandlerContext ctx) {
        ChannelPipeline p = ctx.getChannel().getPipeline();
        p.remove("aggregator");
        p.replace("handler", "ssehandler", this);
//        ctx.getChannel().write("");
    }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelPipeline

*/
public class FactorialServerPipelineFactory implements
        ChannelPipelineFactory {

    public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = pipeline();

        // Enable stream compression (you can remove these two if unnecessary)
        pipeline.addLast("deflater", new ZlibEncoder(ZlibWrapper.GZIP));
        pipeline.addLast("inflater", new ZlibDecoder(ZlibWrapper.GZIP));

        // Add the number codec first,
        pipeline.addLast("decoder", new BigIntegerDecoder());
        pipeline.addLast("encoder", new NumberEncoder());

        // and then business logic.
        // Please note we create a handler for every new channel
        // because it has stateful properties.
        pipeline.addLast("handler", new FactorialServerHandler());

        return pipeline;
    }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelPipeline

    _executor = executor;
  }
 
  public ChannelPipeline getPipeline() throws Exception
  {
    ChannelPipeline pipeline = new MixinPipeline();
        pipeline.addLast("inputStream", new InputStreamDecoder());
        //pipeline.addLast("logger2",new OutLogger("2"));
        pipeline.addLast("outputStream", new OutputStreamEncoder());
        pipeline.addLast("callDecoder", new PullInputStreamConsumer(new HessianRPCCallDecoder(_serializerFactory), _executor ));
        pipeline.addLast("replyEncoder", new HessianRPCReplyEncoder(_serializerFactory));
    pipeline.addLast("outputProducer", new OutputProducer(_executor));
        //pipeline.addLast("logger3",new OutLogger("3"));
        HessianRPCServiceHandler factory =  new HessianRPCServiceHandler(_executor);
    ArrayList servers = MBeanServerFactory.findMBeanServer(null);
    MBeanServer server = null;
      if (servers != null && servers.size() > 0)
        server = (MBeanServer) servers.get(0);
      if (server == null)
        server = MBeanServerFactory.createMBeanServer();
   

        //factory.addService("default", new ContinuationService(new ContinuationHalloWorldService(), HelloWorldServiceInterface.class, factory, _executor));
        factory.addService("default", new ImmediateInvokeService(server, MBeanServerConnection.class, factory));
        pipeline.addLast("hessianRPCServer", factory);
       
        //bootstrap.getPipeline().addLast("logger4",new OutLogger("4"));
        return pipeline;
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelPipeline

    _mixinFactory = mixinFactory;
  }
 
  public ChannelPipeline getPipeline() throws Exception
 
    ChannelPipeline pipeline = pipeline(); // Note the static import.
    pipeline.addLast("logger",new OutLogger("1"));
    pipeline.addLast("sessionFilter", new ServerSessionFilter(_mixinFactory));
    return pipeline;
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelPipeline

 

 
  public ChannelPipeline getPipeline() throws Exception
  {
        ChannelPipeline pipeline = new MixinPipeline();
        // InputStreamDecoder returns an input stream and calls the next handler in a separate thread

        pipeline.addLast("inputStream", new InputStreamDecoder());

        //pipeline.addLast("logger2",new OutLogger1("2"));
        pipeline.addLast("outputStream", new OutputStreamEncoder());
       
        pipeline.addLast("hessianReplyDecoder", new PullInputStreamConsumer(new HessianRPCReplyDecoder(_factory, _serializerFactory), _executor));
        pipeline.addLast("hessianCallEncoder", new HessianRPCCallEncoder(_serializerFactory));
    pipeline.addLast("outputProducer", new OutputProducer(_executor));
        //pipeline.addLast("logger3",new OutLogger("3"));
        pipeline.addLast("hessianHandler", _factory);
       
        return pipeline;

  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelPipeline

    _bootstrap = bootstrap;
  }
 
  public ChannelPipeline getPipeline() throws Exception
 
    ChannelPipeline pipeline = pipeline(); // Note the static import.
    pipeline.addLast("logger",new OutLogger("1"));
    pipeline.addLast("reconnector", new SimpleChannelUpstreamHandler()
                {
           
            @Override
              public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) {
              ctx.sendUpstream(e);
              System.out.println("channel closed wait to reconnect ...");
                  timer.schedule(new TimerTask() {
                      public void run() {
                        System.out.println("reconnecting...");
                         ChannelFuture f = _bootstrap.connect();
                         try
              {
                           System.out.println("future wait");
                f.awaitUninterruptibly();
                         System.out.println("future wait terminated");
              }
              catch (Exception e)
              {
                // TODO Auto-generated catch block
                e.printStackTrace();
                 }
                       if (f.isSuccess())
                       System.out.println("connected");
                       else
                       {
                         System.out.println("not connected");
                        // f.getChannel().close();
                       }
                        
                      }
                  }, RECONNECT_DELAY);
              }
           
            @Override
              public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
                  Throwable cause = e.getCause();
                  if (cause instanceof ConnectException)
                  {
                    System.out.println("conection lost");
                  }
                  ctx.getChannel().close();
              }
                }
);
    pipeline.addLast("sessionFilter", _sessionFilter);

    return pipeline;
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelPipeline

  }

  public ChannelPipeline getPipeline() throws Exception
  {

    ChannelPipeline pipeline = pipeline(); // Note the static import.
    if (_debug)
      pipeline.addLast("logging1", new LoggingFilter(_controller.getLog(), "controller"));

    // allow new connections only if state != LOGGED_ON
    pipeline.addLast("checkWaiting", new ConditionFilter(new Condition()
    {
      public boolean isOk(ChannelHandlerContext ctx, ChannelEvent e)
      {
        boolean result = true;
        int currentState = _controller.getState();
        if (currentState == JVMController.STATE_LOGGED_ON)
        {
          _controller.getLog().info("app already logged on -> rejecting new connedction");
          result = false;
        }
        return result;
      }
    }));

    // create a firewall allowing only localhosts to connect
    WhitelistFilter firewall = new WhitelistFilter();
    try
    {
      firewall.allowAll(InetAddress.getAllByName("127.0.0.1"));
      firewall.allow(InetAddress.getLocalHost());
      pipeline.addLast("firewall", firewall);
    }
    catch (UnknownHostException e)
    {
      _controller.getLog().throwing(JVMController.class.getName(), "start", e);
    }

    // add a framer to split incoming bytes to message chunks
    pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, true, Delimiters.nulDelimiter()));

    // add messge codec
    pipeline.addLast("messageEncoder", new MessageEncoder());
    pipeline.addLast("messageDecoder", new MessageDecoder());

    if (_controller.isDebug())
    {
      pipeline.addLast("logging", new LoggingFilter(_controller.getLog(), "controller"));
      _controller.getLog().info("Logging ON");
    }

    // if we found our partner close all other open connections
    pipeline.addLast("removeConnected", new ChannelGroupFilter(new Condition()
    {
      public boolean isOk(ChannelHandlerContext ctx, ChannelEvent e)
      {
        boolean result = false;
        if (e instanceof MessageEvent)
        {
          Message m = (Message) ((MessageEvent) e).getMessage();
          result = m.getCode() == Constants.WRAPPER_MSG_OKKEY;
        }
        return result;
      }
    }));

    // at last add the message handler
    pipeline.addLast("handler", new ControllerHandler(_controller));

    return pipeline;
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelPipeline

    _acl = acl;
  }
 
  public ChannelPipeline getPipeline() throws Exception
  {
      ChannelPipeline pipeline = pipeline(); // Note the static import.
      if (_acl != null)
      {
       
        pipeline.addFirst("firewall", new IpFilterRuleHandler(new IpFilterRuleList(_acl)));
      }
        pipeline.addLast("logger",new OutLogger("server"));
        pipeline.addLast("inputStream", new InputStreamDecoder());
         pipeline.addLast("outputStream", new OutputStreamEncoder());
         pipeline.addLast("callDecoder", new PushInputStreamConsumer(new HessianRPCCallDecoder(), _executor));
         pipeline.addLast("replyEncoder", new HessianRPCReplyEncoder());
         pipeline.addLast("outputProducer", new OutputProducer(_executor));
        pipeline.addLast("hessianRPCServer", _handler);
       
        //bootstrap.getPipeline().addLast("logger4",new OutLogger("4"));
        return pipeline;
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelPipeline

    _acl = acl;
  }
 
  public ChannelPipeline getPipeline() throws Exception
  {
      ChannelPipeline pipeline = pipeline(); // Note the static import.
      if (_acl != null)
      {
       
        pipeline.addFirst("firewall", new IpFilterRuleHandler(new IpFilterRuleList(_acl)));
      }
         pipeline.addLast("inputStream", new InputStreamDecoder());
          pipeline.addLast("outputStream", new OutputStreamEncoder());
          pipeline.addLast("callDecoder", new PushInputStreamConsumer(new HessianRPCCallDecoder(), _executor));
          pipeline.addLast("replyEncoder", new HessianRPCReplyEncoder());
          pipeline.addLast("outputProducer", new OutputProducer(_executor));
        pipeline.addLast("hessianRPCServer", _handler);
       
        //bootstrap.getPipeline().addLast("logger4",new OutLogger("4"));
        return pipeline;
  }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelPipeline

    this(executor, factory, null);
  }

  public ChannelPipeline getPipeline() throws Exception
  {
    ChannelPipeline pipeline = StopablePipeline.pipeline(); // Note the
                                // static
                                // import.

    // no auto reconnect: port may change in case of mcast discovery
    if (_bootstrapProvider != null)
      pipeline.addLast("reconnect", new ReconnectHandler(_bootstrapProvider, 1000));
    // pipeline.addLast("logger1",new OutLogger("1"));

    // InputStreamDecoder returns an input stream and calls the next handler
    // in a separate thread
    pipeline.addLast("inputStream", new InputStreamDecoder());

    // pipeline.addLast("logger2",new OutLogger("2"));
    pipeline.addLast("outputStream", new OutputStreamEncoder());

    pipeline.addLast("hessianReplyDecoder", new PullInputStreamConsumer(new HessianRPCReplyDecoder(_factory, new JmxSerializerFactory()), _executor));
    pipeline.addLast("hessianCallEncoder", new HessianRPCCallEncoder(new JmxSerializerFactory()));
    pipeline.addLast("outputProducer", new OutputProducer(_executor));
    // pipeline.addLast("logger3",new OutLogger("3"));
    pipeline.addLast("hessianHandler", _factory);
    pipeline.addLast("stopHandler", new StopHandler());

    return pipeline;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.