org.apache.camel.component.netty.http.handlers
Class HttpServerMultiplexChannelHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by org.apache.camel.component.netty.http.handlers.HttpServerMultiplexChannelHandler
All Implemented Interfaces:
HttpServerConsumerChannelFactory, org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class HttpServerMultiplexChannelHandler
extends org.jboss.netty.channel.SimpleChannelUpstreamHandler
implements HttpServerConsumerChannelFactory

A multiplex HttpServerPipelineFactory which keeps a list of handlers, and delegates to the target handler based on the http context path in the incoming request. This is used to allow to reuse the same Netty consumer, allowing to have multiple routes on the same netty ServerBootstrap


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Constructor Summary
HttpServerMultiplexChannelHandler()
           
 
Method Summary
 void addConsumer(NettyHttpConsumer consumer)
          Adds the given consumer.
 int consumers()
          Number of active consumers
 void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ExceptionEvent e)
           
 org.jboss.netty.channel.ChannelHandler getChannelHandler()
          Gets the ChannelHandler
 int getPort()
          The port number this consumer channel factory is using.
 void init(int port)
          Initializes this consumer channel factory with the given port.
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent messageEvent)
           
 void removeConsumer(NettyHttpConsumer consumer)
          Removes the given consumer
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpServerMultiplexChannelHandler

public HttpServerMultiplexChannelHandler()
Method Detail

init

public void init(int port)
Description copied from interface: HttpServerConsumerChannelFactory
Initializes this consumer channel factory with the given port.

Specified by:
init in interface HttpServerConsumerChannelFactory

addConsumer

public void addConsumer(NettyHttpConsumer consumer)
Description copied from interface: HttpServerConsumerChannelFactory
Adds the given consumer.

Specified by:
addConsumer in interface HttpServerConsumerChannelFactory

removeConsumer

public void removeConsumer(NettyHttpConsumer consumer)
Description copied from interface: HttpServerConsumerChannelFactory
Removes the given consumer

Specified by:
removeConsumer in interface HttpServerConsumerChannelFactory

consumers

public int consumers()
Description copied from interface: HttpServerConsumerChannelFactory
Number of active consumers

Specified by:
consumers in interface HttpServerConsumerChannelFactory

getPort

public int getPort()
Description copied from interface: HttpServerConsumerChannelFactory
The port number this consumer channel factory is using.

Specified by:
getPort in interface HttpServerConsumerChannelFactory

getChannelHandler

public org.jboss.netty.channel.ChannelHandler getChannelHandler()
Description copied from interface: HttpServerConsumerChannelFactory
Gets the ChannelHandler

Specified by:
getChannelHandler in interface HttpServerConsumerChannelFactory

messageReceived

public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.MessageEvent messageEvent)
                     throws Exception
Overrides:
messageReceived in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception

exceptionCaught

public void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.ExceptionEvent e)
                     throws Exception
Overrides:
exceptionCaught in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception


Apache Camel