Java Code Examples for org.jboss.netty.channel.ChannelPipeline

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project graylog2-server, under directory /src/main/java/org/graylog2/inputs/gelf/.

Source file: GELFTCPPipelineFactory.java

  23 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p=Channels.pipeline();
  p.addLast("framer",new DelimiterBasedFrameDecoder(2 * 1024 * 1024,Delimiters.nulDelimiter()));
  p.addLast("handler",new GELFDispatcher(server));
  return p;
}
 

Example 2

From project httptunnel, under directory /src/main/java/com/yammer/httptunnel/server/.

Source file: HttpTunnelAcceptedChannelPipelineFactory.java

  23 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  final ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("httpResponseEncoder",new HttpResponseEncoder());
  pipeline.addLast("httpRequestDecoder",new HttpRequestDecoder());
  pipeline.addLast("httpChunkAggregator",new HttpChunkAggregator(HttpTunnelMessageUtils.MAX_BODY_SIZE));
  pipeline.addLast("messageSwitchClient",channelHandler);
  return pipeline;
}
 

Example 3

From project ardverk-dht, under directory /components/http/src/main/java/org/ardverk/dht/http/.

Source file: HttpClientPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("codec",new HttpClientCodec());
  pipeline.addLast("idle",IdleUtils.DEFAULT);
  pipeline.addLast("handler",channelHandler);
  return pipeline;
}
 

Example 4

From project avro, under directory /lang/java/ipc/src/test/java/org/apache/avro/ipc/.

Source file: TestNettyServerWithSSL.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  SSLEngine sslEngine=createServerSSLContext().createSSLEngine();
  sslEngine.setUseClientMode(false);
  pipeline.addLast("ssl",new SslHandler(sslEngine));
  return pipeline;
}
 

Example 5

From project bagheera, under directory /src/main/java/com/mozilla/bagheera/http/.

Source file: HttpServerPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("decoder",new BagheeraHttpRequestDecoder());
  pipeline.addLast("rootResponse",new RootResponse());
  pipeline.addLast("aggregator",new HttpChunkAggregator(maxContentLength));
  pipeline.addLast("contentLengthFilter",new ContentLengthFilter(maxContentLength));
  pipeline.addLast("accessFilter",new AccessFilter(validator,props));
  pipeline.addLast("inflater",new HttpContentDecompressor());
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("handler",new SubmissionHandler(validator,producer));
  return pipeline;
}
 

Example 6

From project bbb-java, under directory /src/main/java/org/mconf/bbb/.

Source file: MainRtmpConnection.java

  22 
vote

@Override protected ChannelPipelineFactory pipelineFactory(){
  return new ChannelPipelineFactory(){
    @Override public ChannelPipeline getPipeline() throws Exception {
      final ChannelPipeline pipeline=Channels.pipeline();
      pipeline.addLast("handshaker",new ClientHandshakeHandler(options));
      pipeline.addLast("decoder",new RtmpDecoder());
      pipeline.addLast("encoder",new RtmpEncoder());
      pipeline.addLast("handler",MainRtmpConnection.this);
      return pipeline;
    }
  }
;
}
 

Example 7

From project chililog-server, under directory /src/main/java/org/chililog/server/pubsub/jsonhttp/.

Source file: JsonHttpServerPipelineFactory.java

  22 
vote

/** 
 * Creates an HTTP Pipeline for our server
 */
public ChannelPipeline getPipeline() throws Exception {
  AppProperties appProperties=AppProperties.getInstance();
  ChannelPipeline pipeline=pipeline();
  if (appProperties.getPubSubJsonHttpSslEnabled()) {
    SSLEngine engine=JsonHttpSslContextManager.getInstance().getServerContext().createSSLEngine();
    engine.setUseClientMode(false);
    pipeline.addLast("ssl",new SslHandler(engine));
  }
  pipeline.addLast("decoder",new HttpRequestDecoder());
  pipeline.addLast("aggregator",new HttpChunkAggregator(1048576));
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("handler",new JsonHttpRequestHandler(_executor));
  return pipeline;
}
 

Example 8

From project Countandra, under directory /src/org/countandra/netty/.

Source file: NettyUtils.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("decoder",new HttpRequestDecoder());
  pipeline.addLast("aggregator",new HttpChunkAggregator(1048576));
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("handler",new CountandraHttpRequestHandler());
  return pipeline;
}
 

Example 9

From project dragon, under directory /hadoop-dragon-core/src/main/java/org/apache/hadoop/realtime/shuffle/.

Source file: ShuffleClientPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=new DefaultChannelPipeline();
  pipeline.addLast("decoder",new ResponseDecoder(conf));
  pipeline.addLast("encoder",new RequestEncoder(conf));
  pipeline.addLast("handler",handler);
  return pipeline;
}
 

Example 10

From project enterprise, under directory /com/src/main/java/org/neo4j/com/.

Source file: Client.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  addLengthFieldPipes(pipeline,frameLength);
  BlockingReadHandler<ChannelBuffer> reader=new BlockingReadHandler<ChannelBuffer>(new ArrayBlockingQueue<ChannelEvent>(3,false));
  pipeline.addLast("blockingHandler",reader);
  return pipeline;
}
 

Example 11

From project fast-http, under directory /src/main/java/org/neo4j/smack/pipeline/http/.

Source file: NettyHttpPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("channeltracker",new NettyChannelTrackingHandler(openChannels));
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("handler",new NettyHttpHandler(workConsumer,connectionIdGenerator));
  return pipeline;
}
 

Example 12

From project flazr, under directory /src/main/java/com/flazr/rtmp/client/.

Source file: ClientPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline(){
  final ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("handshaker",new ClientHandshakeHandler(options));
  pipeline.addLast("decoder",new RtmpDecoder());
  pipeline.addLast("encoder",new RtmpEncoder());
  pipeline.addLast("handler",new ClientHandler(options));
  return pipeline;
}
 

Example 13

From project floodlight, under directory /src/main/java/net/floodlightcontroller/core/internal/.

Source file: OpenflowPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  OFChannelState state=new OFChannelState();
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("ofmessagedecoder",new OFMessageDecoder());
  pipeline.addLast("ofmessageencoder",new OFMessageEncoder());
  pipeline.addLast("idle",idleHandler);
  pipeline.addLast("timeout",readTimeoutHandler);
  pipeline.addLast("handshaketimeout",new HandshakeTimeoutHandler(state,timer,15));
  if (pipelineExecutor != null)   pipeline.addLast("pipelineExecutor",new ExecutionHandler(pipelineExecutor));
  pipeline.addLast("handler",controller.getChannelHandler(state));
  return pipeline;
}
 

Example 14

From project galaxy, under directory /src/co/paralleluniverse/galaxy/netty/.

Source file: UdpMessagePipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  final ChannelPipeline pipeline=Channels.pipeline();
  if (executor != null)   pipeline.addLast("executor",new ExecutionHandler(executor));
  pipeline.addLast("logging",new LoggingHandler(logger));
  pipeline.addLast("messageCodec",new MessagePacketCodec());
  pipeline.addLast("nodeResolver",nodeResolver);
  return pipeline;
}
 

Example 15

From project gnip4j, under directory /mock-server/src/main/java/com/zaubersoftware/gnip4j/server/netty/.

Source file: NettyGnipServer.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  final ChannelPipeline pipeline=pipeline();
  pipeline.addLast("decoder",new HttpRequestDecoder());
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("chunkedWriter",new ChunkedWriteHandler());
  pipeline.addLast("handler",new HttpGnipServerHandler(chunkedInputFactory.getChunkedInput()));
  return pipeline;
}
 

Example 16

From project idigi-java-monitor-api, under directory /netty/src/main/java/com/idigi/api/monitor/netty/.

Source file: MonitorPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("hexLogger",Logging.getLoggingHandler());
  pipeline.addLast("decoder",new ConnectResponseDecoder());
  pipeline.addLast("authHandler",connectHandler);
  pipeline.addLast("connectRequestEncoder",new ConnectRequestEncoder());
  pipeline.addLast("publishMessageResponseEncoder",new PublishMessageReceivedEncoder());
  pipeline.addLast("listenerHandler",listenerHandler);
  pipeline.addLast("responder",new PublishMessageResponder());
  pipeline.addLast("reconnectHandler",reconnectHandler);
  return pipeline;
}
 

Example 17

From project incubator-s4, under directory /subprojects/s4-core/src/main/java/org/apache/s4/deploy/.

Source file: HttpS4RFetcher.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("codec",new HttpClientCodec());
  pipeline.addLast("inflater",new HttpContentDecompressor());
  pipeline.addLast("handler",new HttpResponseHandler(tmpFile));
  return pipeline;
}
 

Example 18

From project JAirPort, under directory /src/de/debugco/jairport/.

Source file: RtspServerPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=pipeline();
  pipeline.addLast("decoder",new RtspRequestDecoder());
  pipeline.addLast("encoder",new RtspResponseEncoder());
  pipeline.addLast("handler",new RtspRequestHandler());
  return pipeline;
}
 

Example 19

From project java-webserver, under directory /src/org/nikki/http/fastcgi/net/.

Source file: FastCGIPipeline.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("decoder",new FastCGIDecoder());
  pipeline.addLast("encoder",new FastCGIEncoder());
  pipeline.addLast("handler",new FastCGIChannelHandler(module));
  return pipeline;
}
 

Example 20

From project JMaNGOS, under directory /Auth/src/main/java/org/jmangos/auth/network/factory/.

Source file: AuthToClientPipelineFactory.java

  22 
vote

/** 
 * @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
 */
@Override public ChannelPipeline getPipeline() throws Exception {
  final ChannelPipeline pipeline=pipeline();
  pipeline.addLast("executor",getExecutorHandler());
  pipeline.addLast("eventlog",new EventLogHandler());
  pipeline.addLast("handler",new AuthToClientChannelHandler(this.packetService,this.connectionHandler,new NettyPacketReceiver()));
  return pipeline;
}
 

Example 21

From project l2jserver2, under directory /l2jserver2-gameserver/l2jserver2-gameserver-freya/src/main/java/com/l2jserver/game/net/.

Source file: Lineage2PipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  final ChannelPipeline pipeline=pipeline();
  pipeline.addLast("frame.encoder",new Lineage2FrameEncoder());
  pipeline.addLast("frame.decoder",new Lineage2FrameDecoder());
  pipeline.addLast(Lineage2Encrypter.HANDLER_NAME,new Lineage2Encrypter());
  pipeline.addLast(Lineage2Decrypter.HANDLER_NAME,new Lineage2Decrypter());
  pipeline.addLast(Lineage2PacketWriter.HANDLER_NAME,new Lineage2PacketWriter());
  pipeline.addLast(Lineage2PacketReader.HANDLER_NAME,new Lineage2PacketReader(injector));
  pipeline.addLast("logger",new LoggingHandler(InternalLogLevel.DEBUG,true));
  final Lineage2TimeoutHandler timeoutHandler=new Lineage2TimeoutHandler();
  pipeline.addLast("packet.handler",new Lineage2PacketHandler(nettyNetworkService,timeoutHandler));
  return pipeline;
}
 

Example 22

From project msgpack-rpc, under directory /java/src/main/java/org/msgpack/rpc/loop/netty/.

Source file: StreamPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p=Channels.pipeline();
  p.addLast("msgpack-decode-stream",new MessagePackStreamDecoder(messagePack));
  p.addLast("msgpack-encode",new MessagePackEncoder(messagePack));
  p.addLast("message",new MessageHandler(handler));
  return p;
}
 

Example 23

From project nettosphere, under directory /server/src/main/java/org/atmosphere/nettosphere/.

Source file: AtmosphereChannelPipelineFactory.java

  22 
vote

/** 
 * Retrieve the channel pipeline factory.
 * @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
 */
public ChannelPipeline getPipeline(){
  final ChannelPipeline pipeline=pipeline();
  pipeline.addLast("decoder",new HttpRequestDecoder());
  pipeline.addLast("aggregator",new HttpChunkAggregator(65536));
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("nettyAtmosphereHandler",nettyAtmosphereHandler);
  return pipeline;
}
 

Example 24

From project netty-icap, under directory /src/main/java/ch/mimo/netty/example/icap/preview/.

Source file: IcapClientChannelPipeline.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=pipeline();
  pipeline.addLast("encoder",new IcapRequestEncoder());
  pipeline.addLast("decoder",new IcapResponseDecoder());
  pipeline.addLast("handler",new IcapClientHandler());
  return pipeline;
}
 

Example 25

From project niosmtp, under directory /src/main/java/me/normanmaurer/niosmtp/transport/netty/internal/.

Source file: SecureSMTPClientPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline cp=super.getPipeline();
  if (mode == SMTPDeliveryMode.SMTPS) {
    cp.addFirst(SSL_HANDSHAKE_HANDLER_KEY,SSL_HANDSHAKE_HANDLER);
    final SslHandler sslHandler=new SslHandler(createSSLClientEngine(),false);
    cp.addFirst(SSL_HANDLER_KEY,sslHandler);
  }
  return cp;
}
 

Example 26

From project omid, under directory /src/main/java/com/yahoo/omid/tso/.

Source file: TSOPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("decoder",new TSODecoder());
  pipeline.addLast("encoder",new TSOEncoder());
synchronized (this) {
    if (x == null)     x=new ExecutionHandler(pipelineExecutor);
    if (bwhandler == null)     bwhandler=new BandwidthMeterHandler();
  }
  pipeline.addLast("pipelineExecutor",x);
  pipeline.addFirst("bw",bwhandler);
  pipeline.addLast("handler",handler);
  return pipeline;
}
 

Example 27

From project opentsdb, under directory /src/tsd/.

Source file: PipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  final ChannelPipeline pipeline=pipeline();
  pipeline.addLast("connmgr",connmgr);
  pipeline.addLast("detect",HTTP_OR_RPC);
  return pipeline;
}
 

Example 28

From project osiris, under directory /src/osiris/net/.

Source file: OsirisPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("decoder",new ServiceRequestDecoder());
  pipeline.addLast("upHandler",new OsirisUpstreamHandler());
  pipeline.addLast("encoder",new OsirisPacketEncoder());
  return pipeline;
}
 

Example 29

From project pasc-paxos, under directory /src/main/java/com/yahoo/pasc/paxos/server/.

Source file: PipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("decoder",new ManualDecoder());
  if (twoStages) {
    pipeline.addLast("executor",executionHandler);
  }
  pipeline.addLast("handler",channelHandler);
  return pipeline;
}
 

Example 30

From project ps3mediaserver, under directory /src/main/java/net/pms/network/.

Source file: HttpServerPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  logger.trace("Creating new pipeline");
  ChannelPipeline pipeline=pipeline();
  pipeline.addLast("decoder",new HttpRequestDecoder());
  pipeline.addLast("aggregator",new HttpChunkAggregator(65536));
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("chunkedWriter",new ChunkedWriteHandler());
  pipeline.addLast("handler",new RequestHandlerV2(group));
  return pipeline;
}
 

Example 31

From project ptest-server, under directory /src/main/java/com/mnxfst/testing/server/.

Source file: TSPipelineFactory.java

  22 
vote

/** 
 * @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
 */
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline channelPipeline=Channels.pipeline();
  channelPipeline.addLast("decoder",new HttpRequestDecoder());
  channelPipeline.addLast("aggregator",new HttpChunkAggregator(1048576));
  channelPipeline.addLast("encoder",new HttpResponseEncoder());
  channelPipeline.addLast("deflater",new HttpContentCompressor());
  channelPipeline.addLast("handler",new TSHttpRequestHandler(hostname,port));
  return channelPipeline;
}
 

Example 32

From project sitebricks, under directory /sitebricks-mail/src/main/java/com/google/sitebricks/mail/.

Source file: MailClientPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  if (config.getAuthType() != Auth.PLAIN) {
    SSLEngine sslEngine=SSLContext.getDefault().createSSLEngine();
    sslEngine.setUseClientMode(true);
    SslHandler sslHandler=new SslHandler(sslEngine);
    sslHandler.setEnableRenegotiation(true);
    pipeline.addLast("ssl",sslHandler);
  }
  pipeline.addLast("decoder",new StringDecoder());
  pipeline.addLast("encoder",new StringEncoder());
  pipeline.addLast("handler",mailClientHandler);
  return pipeline;
}
 

Example 33

From project soja, under directory /soja-core/src/main/java/com/excilys/soja/core/factory/.

Source file: StompPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("frameDecoder",new StompFrameDecoder());
  pipeline.addLast("frameEncoder",new StompFrameEncoder());
  return pipeline;
}
 

Example 34

From project stilts, under directory /stomp-server-core/src/main/java/org/projectodd/stilts/stomp/server/protocol/.

Source file: ProtocolDetector.java

  22 
vote

protected ChannelBuffer switchToPureStomp(ChannelHandlerContext context,ChannelBuffer buffer){
  ChannelBuffer fullBuffer=buffer.readBytes(super.actualReadableBytes());
  ChannelPipeline pipeline=context.getPipeline();
  pipeline.remove(this);
  pipeline.addLast("stomp-frame-encoder",new StompFrameEncoder());
  pipeline.addLast("stomp-frame-decoder",new StompFrameDecoder());
  appendCommonHandlers(pipeline);
  return fullBuffer;
}
 

Example 35

From project Terasology, under directory /src/main/java/org/terasology/network/.

Source file: TerasologyClientPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p=pipeline();
  p.addLast("frameDecoder",new ProtobufVarint32FrameDecoder());
  p.addLast("protobufDecoder",new ProtobufDecoder(NetData.ServerMessage.getDefaultInstance()));
  p.addLast("frameEncoder",new ProtobufVarint32LengthFieldPrepender());
  p.addLast("protobufEncoder",new ProtobufEncoder());
  p.addLast("handler",new TerasologyClientHandler());
  return p;
}
 

Example 36

From project thumbslug, under directory /src/main/java/org/candlepin/thumbslug/.

Source file: HttpCandlepinClient.java

  22 
vote

private ChannelPipeline getPipeline(){
  ChannelPipeline pipeline=pipeline();
  if (useSSL) {
    SSLEngine engine=SslContextFactory.getCandlepinClientContext().createSSLEngine();
    engine.setUseClientMode(true);
    pipeline.addLast("ssl",new SslHandler(engine));
  }
  pipeline.addLast("codec",new HttpClientCodec());
  pipeline.addLast("inflater",new HttpContentDecompressor());
  pipeline.addLast("aggregator",new HttpChunkAggregator(1048576));
  pipeline.addLast("handler",new HttpResponseHandler());
  return pipeline;
}
 

Example 37

From project TomP2P, under directory /src/main/java/net/tomp2p/connection/.

Source file: ChannelCreator.java

  22 
vote

/** 
 * Fill the TCP pipeline with handlers. . This pipeline does not contains the streamer, which the UDP version does.
 * @param bootstrap The bootstrap object with settings
 * @param timeoutHandler The handler that deals with timeouts
 * @param requestHandler The handler that deals with incoming replies
 * @param decoder The message decoder that converts from a Netty byte buffer to an {@link Message} object
 * @param encoder The message encoder that converts from a {@link Message} object to a Netty byte buffer
 * @param messageLoggerFilter The handler to log what was sent over the wire
 */
private static void setupBootstrapUDP(Bootstrap bootstrap,ChannelHandler timeoutHandler,ChannelHandler requestHandler,ChannelUpstreamHandler decoder,ChannelDownstreamHandler encoder,ChannelHandler messageLoggerFilter){
  ChannelPipeline pipe=bootstrap.getPipeline();
  if (timeoutHandler != null) {
    pipe.addLast("timeout",timeoutHandler);
  }
  pipe.addLast("encoder",encoder);
  pipe.addLast("decoder",decoder);
  if (messageLoggerFilter != null) {
    pipe.addLast("loggerUpstream",messageLoggerFilter);
  }
  if (requestHandler != null) {
    pipe.addLast("request",requestHandler);
  }
}
 

Example 38

From project tourenplaner-server, under directory /src/de/tourenplaner/server/.

Source file: ServerInfoOnlyPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=pipeline();
  pipeline.addLast("decoder",new HttpRequestDecoder());
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("handler",new ServerInfoHandler(info));
  return pipeline;
}
 

Example 39

From project ubuntu-packaging-floodlight, under directory /src/main/java/net/floodlightcontroller/core/internal/.

Source file: OpenflowPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  OFChannelState state=new OFChannelState();
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("ofmessagedecoder",new OFMessageDecoder());
  pipeline.addLast("ofmessageencoder",new OFMessageEncoder());
  pipeline.addLast("idle",idleHandler);
  pipeline.addLast("timeout",readTimeoutHandler);
  pipeline.addLast("handshaketimeout",new HandshakeTimeoutHandler(state,timer,15));
  if (pipelineExecutor != null)   pipeline.addLast("pipelineExecutor",new ExecutionHandler(pipelineExecutor));
  pipeline.addLast("handler",controller.getChannelHandler(state));
  return pipeline;
}
 

Example 40

From project UniversalMediaServer, under directory /src/main/java/net/pms/network/.

Source file: HttpServerPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  LOGGER.trace("Creating new pipeline");
  ChannelPipeline pipeline=pipeline();
  pipeline.addLast("decoder",new HttpRequestDecoder());
  pipeline.addLast("aggregator",new HttpChunkAggregator(65536));
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("chunkedWriter",new ChunkedWriteHandler());
  pipeline.addLast("handler",new RequestHandlerV2(group));
  return pipeline;
}
 

Example 41

From project usergrid-stack, under directory /mongo-emulator/src/main/java/org/usergrid/mongo/testproxy/.

Source file: MongoProxyPipelineFactory.java

  22 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p=pipeline();
  p.addLast("framer",new MongoMessageFrame());
  p.addLast("handler",new MongoProxyInboundHandler(cf,remoteHost,remotePort));
  return p;
}
 

Example 42

From project WaarpExec, under directory /src/main/java/org/waarp/commandexec/client/.

Source file: LocalExecClientPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("framer",new DelimiterBasedFrameDecoder(8192,Delimiters.lineDelimiter()));
  pipeline.addLast("decoder",new StringDecoder());
  pipeline.addLast("encoder",new StringEncoder());
  LocalExecClientHandler localExecClientHandler=new LocalExecClientHandler(this);
  pipeline.addLast("handler",localExecClientHandler);
  return pipeline;
}
 

Example 43

From project WaarpFtp, under directory /src/main/java/org/waarp/ftp/core/control/.

Source file: FtpPipelineFactory.java

  22 
vote

/** 
 * Create the pipeline with Handler, ObjectDecoder, ObjectEncoder.
 * @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
 */
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("framer",new DelimiterBasedFrameDecoder(8192,delimiter));
  pipeline.addLast("decoder",ftpControlStringDecoder);
  pipeline.addLast("encoder",ftpControlStringEncoder);
  pipeline.addLast("pipelineExecutor",new ExecutionHandler(configuration.getFtpInternalConfiguration().getPipelineExecutor()));
  BusinessHandler newbusiness=businessHandler.newInstance();
  NetworkHandler newNetworkHandler=new NetworkHandler(new FtpSession(configuration,newbusiness));
  pipeline.addLast("handler",newNetworkHandler);
  return pipeline;
}
 

Example 44

From project WaarpR66, under directory /src/main/java/org/waarp/openr66/protocol/http/.

Source file: HttpPipelineFactory.java

  22 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=pipeline();
  pipeline.addLast("decoder",new HttpRequestDecoder());
  pipeline.addLast("aggregator",new HttpChunkAggregator(1048576));
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("pipelineExecutor",new ExecutionHandler(Configuration.configuration.getHttpPipelineExecutor()));
  pipeline.addLast("streamer",new ChunkedWriteHandler());
  if (useHttpCompression) {
    pipeline.addLast("deflater",new HttpContentCompressor());
  }
  pipeline.addLast("handler",new HttpFormattedHandler());
  return pipeline;
}
 

Example 45

From project zk-service-registry-server, under directory /lib/zk-service-registry-server/zookeeper-3.3.3/contrib/bookkeeper/src/java/org/apache/bookkeeper/proto/.

Source file: PerChannelBookieClient.java

  22 
vote

/** 
 * In the netty pipeline, we need to split packets based on length, so we use the  {@link LengthFieldBasedFrameDecoder}. Other than that all actions are carried out in this class, e.g., making sense of received messages, prepending the length to outgoing packets etc.
 */
@Override public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("lengthbasedframedecoder",new LengthFieldBasedFrameDecoder(MAX_FRAME_LENGTH,0,4,0,4));
  pipeline.addLast("mainhandler",this);
  return pipeline;
}
 

Example 46

From project adbcj, under directory /mysql/netty/src/main/java/org/adbcj/mysql/netty/.

Source file: MysqlConnectionManager.java

  21 
vote

private void init(String host,int port){
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    @Override public ChannelPipeline getPipeline() throws Exception {
      ChannelPipeline pipeline=Channels.pipeline();
      pipeline.addFirst(QUEUE_HANDLER,new MessageQueuingHandler());
      pipeline.addLast(DECODER,new Decoder());
      pipeline.addLast(ENCODER,new Encoder());
      return pipeline;
    }
  }
);
  bootstrap.setOption("tcpNoDelay",true);
  bootstrap.setOption("keepAlive",true);
  bootstrap.setOption("remoteAddress",new InetSocketAddress(host,port));
}
 

Example 47

From project hotpotato, under directory /src/functionaltest/java/com/biasedbit/hotpotato/pipelining/.

Source file: Http11PipeliningTestClient.java

  21 
vote

public boolean init(){
  this.factory=new NioClientSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool());
  this.handler=new ClientHandler();
  ClientBootstrap bootstrap=new ClientBootstrap(this.factory);
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    @Override public ChannelPipeline getPipeline() throws Exception {
      ChannelPipeline pipeline=Channels.pipeline();
      pipeline.addLast("codec",new HttpClientCodec());
      pipeline.addLast("handler",handler);
      return pipeline;
    }
  }
);
  ChannelFuture future=bootstrap.connect(new InetSocketAddress(this.host,this.port));
  return future.awaitUninterruptibly().isSuccess();
}
 

Example 48

From project http-client, under directory /src/main/java/com/biasedbit/http/client/.

Source file: AbstractHttpClient.java

  21 
vote

protected void openConnection(final HostContext context){
  final ChannelPipeline pipeline;
  try {
    pipeline=this.pipelineFactory.getPipeline();
  }
 catch (  Exception e) {
    System.err.println("Failed to create pipeline.");
    e.printStackTrace();
    return;
  }
  context.getConnectionPool().connectionOpening();
  String id=new StringBuilder().append(this.hostId(context)).append("-").append(this.connectionCounter++).toString();
  Executor writeDelegator=this.useNio ? null : this.executor;
  final HttpConnection connection=this.connectionFactory.createConnection(id,context.getHost(),context.getPort(),this,this.timeoutManager,writeDelegator);
  pipeline.addLast("handler",connection);
  this.executor.execute(new Runnable(){
    @Override public void run(){
      ClientBootstrap bootstrap=new ClientBootstrap(channelFactory);
      bootstrap.setOption("reuseAddress",true);
      bootstrap.setOption("connectTimeoutMillis",connectionTimeoutInMillis);
      bootstrap.setPipeline(pipeline);
      ChannelFuture future=bootstrap.connect(new InetSocketAddress(context.getHost(),context.getPort()));
      future.addListener(new ChannelFutureListener(){
        @Override public void operationComplete(        ChannelFuture future) throws Exception {
          if (future.isSuccess()) {
            channelGroup.add(future.getChannel());
          }
        }
      }
);
    }
  }
);
}
 

Example 49

From project james, under directory /protocols-imap4/src/main/java/org/apache/james/imapserver/netty/.

Source file: ChannelImapResponseWriter.java

  21 
vote

/** 
 * @see org.apache.james.imap.encode.ImapResponseWriter#write(org.apache.james.imap.message.response.Literal)
 */
public void write(Literal literal) throws IOException {
  if (channel.isConnected()) {
    InputStream in=literal.getInputStream();
    if (in instanceof FileInputStream && channel.getFactory() instanceof NioServerSocketChannelFactory) {
      FileChannel fc=((FileInputStream)in).getChannel();
      ChannelPipeline cp=channel.getPipeline();
      if (zeroCopy && cp.get(SslHandler.class) == null && cp.get(ZlibEncoder.class) == null) {
        channel.write(new DefaultFileRegion(fc,fc.position(),literal.size()));
      }
 else {
        channel.write(new ChunkedNioFile(fc,8192));
      }
    }
 else {
      channel.write(new ChunkedStream(literal.getInputStream()));
    }
  }
}
 

Example 50

From project Lily, under directory /global/rowlog/impl/src/main/java/org/lilyproject/rowlog/impl/.

Source file: RemoteListenerHandler.java

  21 
vote

public RemoteListenerHandler(RowLog rowLog,String subscriptionId,RowLogMessageListener consumer,RowLogConfigurationManager rowLogConfMgr) throws RowLogException {
  this.rowLog=rowLog;
  this.subscriptionId=subscriptionId;
  this.consumer=consumer;
  this.rowLogConfMgr=rowLogConfMgr;
  bootstrap=new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    public ChannelPipeline getPipeline() throws Exception {
      ChannelPipeline pipeline=Channels.pipeline();
      pipeline.addLast("messageDecoder",new MessageDecoder());
      pipeline.addLast("messageHandler",new MessageHandler());
      pipeline.addLast("resultEncoder",new ResultEncoder());
      return pipeline;
    }
  }
);
}
 

Example 51

From project moho, under directory /moho-remote/src/test/java/com/voxeo/rayo/client/internal/.

Source file: NettyServer.java

  21 
vote

private NettyServer(int port) throws Exception {
  nettyServerHandler=new NettyServerHandler();
  group=new DefaultChannelGroup("myServer");
  factory=new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool());
  ServerBootstrap bootstrap=new ServerBootstrap(factory);
  bootstrap.setOption("child.tcpNoDelay",true);
  bootstrap.setOption("child.keepAlive",true);
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    @Override public ChannelPipeline getPipeline() throws Exception {
      ChannelPipeline pipeline=Channels.pipeline();
      pipeline.addLast("decoder",new StringDecoder());
      pipeline.addLast("encoder",new StringEncoder());
      pipeline.addLast("handler",nettyServerHandler);
      return pipeline;
    }
  }
);
  Channel channel=bootstrap.bind(new InetSocketAddress(port));
  group.add(channel);
}
 

Example 52

From project netty-socketio, under directory /src/main/java/com/corundumstudio/socketio/.

Source file: SocketIOPipelineFactory.java

  21 
vote

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=pipeline();
  boolean isFlashTransport=configuration.getTransports().contains(FlashSocketTransport.NAME);
  if (isFlashTransport) {
    pipeline.addLast(FLASH_POLICY_HANDLER,flashPolicyHandler);
  }
  if (sslContext != null) {
    SSLEngine engine=sslContext.createSSLEngine();
    engine.setUseClientMode(false);
    pipeline.addLast(SSL_HANDLER,new SslHandler(engine));
  }
  pipeline.addLast(HTTP_REQUEST_DECODER,new HttpRequestDecoder());
  pipeline.addLast(HTTP_AGGREGATOR,new HttpChunkAggregator(configuration.getMaxHttpContentLength()));
  pipeline.addLast(HTTP_ENCODER,new HttpResponseEncoder());
  if (isFlashTransport) {
    pipeline.addLast(RESOURCE_HANDLER,resourceHandler);
  }
  pipeline.addLast(PACKET_HANDLER,packetHandler);
  pipeline.addLast(AUTHORIZE_HANDLER,authorizeHandler);
  pipeline.addLast(XHR_POLLING_TRANSPORT,xhrPollingTransport);
  pipeline.addLast(WEB_SOCKET_TRANSPORT,webSocketTransport);
  pipeline.addLast(FLASH_SOCKET_TRANSPORT,flashSocketTransport);
  pipeline.addLast(SOCKETIO_ENCODER,socketIOEncoder);
  return pipeline;
}
 

Example 53

From project netty-xmpp, under directory /src/main/java/es/udc/pfc/xmpp/component/.

Source file: ComponentService.java

  21 
vote

@Override protected void startUp() throws Exception {
  executionHandler=new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(4,0,0));
  bootstrap=new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    @Override public ChannelPipeline getPipeline() throws Exception {
      final ChannelPipeline pipeline=Channels.pipeline();
      pipeline.addLast("xmlFramer",new XMLFrameDecoder());
      pipeline.addLast("xmlDecoder",new XMLElementDecoder());
      pipeline.addLast("xmppDecoder",new XEP0114Decoder(xmppHost,xmppSecret));
      pipeline.addLast("executor",executionHandler);
      pipeline.addLast("xmppHandler",new XMPPStreamHandler(component));
      return pipeline;
    }
  }
);
  final ChannelFuture future=bootstrap.connect(serverAddress).await();
  if (!future.isSuccess()) {
    bootstrap.releaseExternalResources();
    executionHandler.releaseExternalResources();
    future.rethrowIfFailed();
  }
  channel=future.getChannel();
  component.init(channel,JID.jid("localhost"),JID.jid(xmppHost));
}
 

Example 54

From project Spout, under directory /src/main/java/org/spout/engine/listener/channel/.

Source file: SpoutProxyConnectListener.java

  21 
vote

@Override public void operationComplete(ChannelFuture future) throws Exception {
  if (!future.isDone()) {
    throw new IllegalStateException("Connect operation was not done when listener was triggered");
  }
 else {
    Channel c=future.getChannel();
    if (future.isSuccess()) {
      Spout.getLogger().info("Connect to server successful " + c.getRemoteAddress() + ", "+ playerName);
      session.bindAuxChannel(c);
      ChannelPipeline pipeline=c.getPipeline();
      if (pipeline != null) {
        CommonHandler d=pipeline.get(CommonHandler.class);
        if (d != null) {
          d.setSession(session);
        }
        Protocol protocol=session.getProtocol();
        if (protocol != null) {
          Message intro=protocol.getIntroductionMessage(playerName);
          c.write(intro);
          return;
        }
      }
      session.disconnect("Login failed for backend server");
    }
 else {
      Spout.getLogger().info("Failed to connect to server " + c.getRemoteAddress() + ", "+ playerName);
      session.disconnect("Unable to connect to backend server");
    }
  }
}
 

Example 55

From project WaarpGatewayFtp, under directory /src/main/java/org/waarp/gateway/ftp/adminssl/.

Source file: HttpSslPipelineFactory.java

  21 
vote

@Override public ChannelPipeline getPipeline(){
  final ChannelPipeline pipeline=Channels.pipeline();
  SslHandler sslhandler=waarpSslContextFactory.initPipelineFactory(true,false,enableRenegotiation,executorService);
  sslhandler.setIssueHandshake(true);
  pipeline.addLast("ssl",sslhandler);
  pipeline.addLast("decoder",new HttpRequestDecoder());
  pipeline.addLast("aggregator",new HttpChunkAggregator(1048576));
  pipeline.addLast("encoder",new HttpResponseEncoder());
  pipeline.addLast("pipelineExecutor",new ExecutionHandler(FileBasedConfiguration.fileBasedConfiguration.getHttpPipelineExecutor()));
  pipeline.addLast("streamer",new ChunkedWriteHandler());
  if (useHttpCompression) {
    pipeline.addLast("deflater",new HttpContentCompressor());
  }
  pipeline.addLast("handler",new HttpSslHandler());
  return pipeline;
}
 

Example 56

From project Agot-Java, under directory /src/main/java/got/client/.

Source file: Client.java

  19 
vote

public Client(){
  String host="127.0.0.1";
  int port=7890;
  ClientBootstrap bootstrap=new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(new ObjectEncoder(),new ObjectDecoder(ClassResolvers.weakCachingConcurrentResolver(null)),new ClientHandler(Client.this));
    }
  }
);
  ChannelFuture future=bootstrap.connect(new InetSocketAddress(host,port));
  future.getChannel().getCloseFuture().awaitUninterruptibly();
  bootstrap.releaseExternalResources();
}
 

Example 57

From project commons-j, under directory /src/main/java/nerds/antelax/commons/net/pubsub/.

Source file: PubSubClient.java

  19 
vote

PubSubClient(final ChannelHandler incomingInterceptor,final Predicate<Object> incomingFilter,final ExecutorService service,final NetworkConnectionLifecycleCallback lifecycleCallback,final int retryDelay,final TimeUnit retryUnits,final Collection<InetSocketAddress> servers){
  Preconditions.checkArgument((incomingInterceptor == null && incomingFilter == null) || (incomingInterceptor != null && incomingFilter != null));
  Preconditions.checkNotNull(service,"ExecutorService cannot be null");
  Preconditions.checkNotNull(servers,"Must give at least one server address to connect to");
  clientHandler=new ClientMessageHandler(service);
  bossService=Executors.newCachedThreadPool();
  workerService=Executors.newCachedThreadPool();
  factory=new NioClientSocketChannelFactory(bossService,workerService);
  bootstrap=new ClientBootstrap(factory);
  reconnectHandler=new RoundRobinReconnectHandler(bootstrap,retryDelay,retryUnits,lifecycleCallback,servers);
  final UpstreamMessageFilteringHandler filteringHandler=incomingFilter != null ? new UpstreamMessageFilteringHandler(incomingFilter) : null;
  final UUID ourSourceID=UUID.randomUUID();
  logger.info("New client created with ID: {}",ourSourceID);
  final ChannelDownstreamHandler uuidPopulatingHandler=new SimpleChannelDownstreamHandler(){
    @Override public void writeRequested(    final ChannelHandlerContext ctx,    final MessageEvent e) throws Exception {
      final Object o=e.getMessage();
      if (o instanceof Message) {
        final Message m=(Message)o;
        if (m.sourceID() == null || m.sourceID().equals(Message.NO_UUID))         m.sourceID(ourSourceID);
      }
      super.writeRequested(ctx,e);
    }
  }
;
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    @Override public ChannelPipeline getPipeline(){
      if (incomingInterceptor != null && filteringHandler != null)       return Channels.pipeline(reconnectHandler,MessageCodec.decoder(),MessageCodec.encoder(),uuidPopulatingHandler,filteringHandler,incomingInterceptor,clientHandler);
 else       return Channels.pipeline(reconnectHandler,MessageCodec.decoder(),MessageCodec.encoder(),uuidPopulatingHandler,clientHandler);
    }
  }
);
  bootstrap.setOption("tcpNoDelay",true);
  bootstrap.setOption("keepAlive",true);
  logger.trace("New pub/sub client created w/ intercepting handler[{}], incoming filter[{}], lifecycle callback[{}], retry delay[{} {}], servers[{}]",asArray(incomingInterceptor,incomingFilter,lifecycleCallback,retryDelay,retryUnits,servers));
}
 

Example 58

From project flume, under directory /flume-ng-core/src/main/java/org/apache/flume/source/.

Source file: SyslogTcpSource.java

  19 
vote

@Override public void start(){
  ChannelFactory factory=new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool());
  ServerBootstrap serverBootstrap=new ServerBootstrap(factory);
  serverBootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    @Override public ChannelPipeline getPipeline(){
      syslogTcpHandler handler=new syslogTcpHandler();
      handler.setEventSize(eventSize);
      handler.setFormater(formaterProp);
      return Channels.pipeline(handler);
    }
  }
);
  logger.info("Syslog TCP Source starting...");
  if (host == null) {
    nettyChannel=serverBootstrap.bind(new InetSocketAddress(port));
  }
 else {
    nettyChannel=serverBootstrap.bind(new InetSocketAddress(host,port));
  }
  super.start();
}
 

Example 59

From project MeQanTT, under directory /mqtt-library/src/main/java/org/meqantt/.

Source file: NettyClient.java

  19 
vote

public void connect(String host,int port){
  bootstrap=new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
  handler=new MqttMessageHandler();
  handler.setListener(listener);
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(new MqttMessageEncoder(),new MqttMessageDecoder(),handler);
    }
  }
);
  bootstrap.setOption("tcpNoDelay",true);
  bootstrap.setOption("keepAlive",true);
  ChannelFuture future=bootstrap.connect(new InetSocketAddress(host,port));
  channel=future.awaitUninterruptibly().getChannel();
  if (!future.isSuccess()) {
    future.getCause().printStackTrace();
    bootstrap.releaseExternalResources();
    return;
  }
  channel.write(new ConnectMessage(id,true,30));
}
 

Example 60

From project Racenet-for-Android, under directory /src/com/albin/mqtt/.

Source file: NettyClient.java

  19 
vote

public void connect(String host,int port){
  bootstrap=new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
  handler=new MqttMessageHandler();
  handler.setListener(listener);
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(new MqttMessageEncoder(),new MqttMessageDecoder(),handler);
    }
  }
);
  bootstrap.setOption("tcpNoDelay",true);
  bootstrap.setOption("keepAlive",true);
  ChannelFuture future=bootstrap.connect(new InetSocketAddress(host,port));
  channel=future.awaitUninterruptibly().getChannel();
  if (!future.isSuccess()) {
    future.getCause().printStackTrace();
    bootstrap.releaseExternalResources();
    return;
  }
  channel.write(new ConnectMessage(id,true,keepAlive));
}
 

Example 61

From project SpoutAPI, under directory /src/main/java/org/spout/api/protocol/.

Source file: CommonPipelineFactory.java

  19 
vote

@Override public ChannelPipeline getPipeline() throws Exception {
  CommonEncoder encoder=new CommonEncoder(upstream);
  CommonDecoder decoder=new CommonDecoder(upstream);
  CommonHandler handler=new CommonHandler(engine,encoder,decoder,upstream);
  DynamicMessageDecoder dynamicDecoder=new DynamicMessageDecoder();
  DynamicMessageEncoder dynamicEncoder=new DynamicMessageEncoder();
  return Channels.pipeline(decoder,encoder,dynamicDecoder,dynamicEncoder,handler);
}
 

Example 62

From project traccar, under directory /src/org/traccar/.

Source file: Server.java

  19 
vote

/** 
 * Init Xexun server
 */
private void initXexunServer(Properties properties) throws SQLException {
  String protocol="xexun";
  if (isProtocolEnabled(properties,protocol)) {
    TrackerServer server=new TrackerServer(getProtocolPort(properties,protocol));
    final Integer resetDelay=getProtocolResetDelay(properties,protocol);
    server.setPipelineFactory(new GenericPipelineFactory(server,dataManager,isLoggerEnabled(),geocoder){
      protected void addSpecificHandlers(      ChannelPipeline pipeline){
        pipeline.addLast("frameDecoder",new XexunFrameDecoder());
        pipeline.addLast("stringDecoder",new StringDecoder());
        pipeline.addLast("objectDecoder",new XexunProtocolDecoder(getDataManager(),resetDelay));
      }
    }
);
    serverList.add(server);
  }
}
 

Example 63

From project vanilla, under directory /src/main/java/org/spout/vanilla/protocol/rcon/.

Source file: RemoteConnectionServer.java

  19 
vote

public RemoteConnectionServer(Logger logger,File dataFolder){
  super(logger);
  this.config=new RconConfiguration(new YamlConfiguration(new File(dataFolder,"rcon.yml")));
  bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
    public ChannelPipeline getPipeline() throws Exception {
      RemoteConnectionSession session=new RemoteConnectionSession(RemoteConnectionServer.this);
      return Channels.pipeline(new RconEncoder(session),new RconDecoder(session),new ChannelTracker(),new RconHandler(session));
    }
  }
);
  NioServerSocketChannelFactory factory=new NioServerSocketChannelFactory(){
    @Override public ServerSocketChannel newChannel(    ChannelPipeline pipeline){
      ServerSocketChannel channel=super.newChannel(pipeline);
      channel.getConfig().setBufferFactory(HeapChannelBufferFactory.getInstance(ByteOrder.LITTLE_ENDIAN));
      return channel;
    }
  }
;
  bootstrap.setFactory(factory);
}