Author: davsclaus
Date: Wed Jun 13 09:59:12 2012
New Revision: 1349715
URL: http://svn.apache.org/viewvc?rev=1349715&view=rev
Log:
CAMEL-5225: Configured encoders and decoders must be shareable or implement
ChannelHandlerFactory to be safely used with Netty.
Added:
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactories.java
- copied, changed from r1349704,
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactories.java
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactory.java
- copied unchanged from r1349704,
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactory.java
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/ShareableChannelHandlerFactory.java
- copied unchanged from r1349704,
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/ShareableChannelHandlerFactory.java
camel/branches/camel-2.9.x/components/camel-netty/src/test/java/org/apache/camel/component/netty/UnsharableCodecsConflicts2Test.java
- copied unchanged from r1349704,
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/UnsharableCodecsConflicts2Test.java
Modified:
camel/branches/camel-2.9.x/ (props changed)
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
camel/branches/camel-2.9.x/components/camel-netty/src/test/java/org/apache/camel/component/netty/MultipleCodecsTest.java
camel/branches/camel-2.9.x/components/camel-netty/src/test/resources/org/apache/camel/component/netty/multiple-codecs.xml
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1349704
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Copied:
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactories.java
(from r1349704,
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactories.java)
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactories.java?p2=camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactories.java&p1=camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactories.java&r1=1349704&r2=1349715&rev=1349715&view=diff
==============================================================================
---
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactories.java
(original)
+++
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/ChannelHandlerFactories.java
Wed Jun 13 09:59:12 2012
@@ -22,7 +22,6 @@ import org.jboss.netty.buffer.ChannelBuf
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
-import org.jboss.netty.handler.codec.serialization.ClassResolvers;
import org.jboss.netty.handler.codec.serialization.ObjectDecoder;
import org.jboss.netty.handler.codec.serialization.ObjectEncoder;
import org.jboss.netty.handler.codec.string.StringDecoder;
@@ -48,7 +47,7 @@ public final class ChannelHandlerFactori
return new ChannelHandlerFactory() {
@Override
public ChannelHandler newChannelHandler() {
- return new
ObjectDecoder(ClassResolvers.weakCachingResolver(null));
+ return new ObjectDecoder();
}
};
}
Modified:
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java?rev=1349715&r1=1349714&r2=1349715&view=diff
==============================================================================
---
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
(original)
+++
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultClientPipelineFactory.java
Wed Jun 13 09:59:12 2012
@@ -22,9 +22,8 @@ import javax.net.ssl.SSLEngine;
import org.apache.camel.component.netty.handlers.ClientChannelHandler;
import org.apache.camel.component.netty.ssl.SSLEngineFactory;
-import org.jboss.netty.channel.ChannelDownstreamHandler;
+import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelUpstreamHandler;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.handler.ssl.SslHandler;
import org.slf4j.Logger;
@@ -46,25 +45,40 @@ public class DefaultClientPipelineFactor
SslHandler sslHandler = configureClientSSLOnDemand(producer);
if (sslHandler != null) {
LOG.debug("Client SSL handler configured and added to the
ChannelPipeline");
- channelPipeline.addLast("ssl", sslHandler);
+ addToPipeline("ssl", channelPipeline, sslHandler);
}
- List<ChannelUpstreamHandler> decoders =
producer.getConfiguration().getDecoders();
+ List<ChannelHandler> decoders =
producer.getConfiguration().getDecoders();
for (int x = 0; x < decoders.size(); x++) {
- channelPipeline.addLast("decoder-" + x, decoders.get(x));
+ ChannelHandler decoder = decoders.get(x);
+ if (decoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as
it may not be shareable
+ decoder = ((ChannelHandlerFactory)
decoder).newChannelHandler();
+ }
+ addToPipeline("decoder-" + x, channelPipeline, decoder);
}
- List<ChannelDownstreamHandler> encoders =
producer.getConfiguration().getEncoders();
+ List<ChannelHandler> encoders =
producer.getConfiguration().getEncoders();
for (int x = 0; x < encoders.size(); x++) {
- channelPipeline.addLast("encoder-" + x, encoders.get(x));
+ ChannelHandler encoder = encoders.get(x);
+ if (encoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as
it may not be shareable
+ encoder = ((ChannelHandlerFactory)
encoder).newChannelHandler();
+ }
+ addToPipeline("encoder-" + x, channelPipeline, encoder);
}
// our handler must be added last
- channelPipeline.addLast("handler", new ClientChannelHandler(producer));
+ addToPipeline("handler", channelPipeline, new
ClientChannelHandler(producer));
+ LOG.trace("Created ChannelPipeline: {}", channelPipeline);
return channelPipeline;
}
+ private void addToPipeline(String name, ChannelPipeline pipeline,
ChannelHandler handler) {
+ pipeline.addLast(name, handler);
+ }
+
private SslHandler configureClientSSLOnDemand(NettyProducer producer)
throws Exception {
if (!producer.getConfiguration().isSsl()) {
return null;
Modified:
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java?rev=1349715&r1=1349714&r2=1349715&view=diff
==============================================================================
---
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java
(original)
+++
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/DefaultServerPipelineFactory.java
Wed Jun 13 09:59:12 2012
@@ -22,9 +22,8 @@ import javax.net.ssl.SSLEngine;
import org.apache.camel.component.netty.handlers.ServerChannelHandler;
import org.apache.camel.component.netty.ssl.SSLEngineFactory;
-import org.jboss.netty.channel.ChannelDownstreamHandler;
+import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelUpstreamHandler;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.handler.ssl.SslHandler;
import org.slf4j.Logger;
@@ -46,24 +45,40 @@ public class DefaultServerPipelineFactor
SslHandler sslHandler = configureServerSSLOnDemand(consumer);
if (sslHandler != null) {
LOG.debug("Server SSL handler configured and added as an
interceptor against the ChannelPipeline");
- channelPipeline.addLast("ssl", sslHandler);
+ addToPipeline("ssl", channelPipeline, sslHandler);
}
- List<ChannelDownstreamHandler> encoders =
consumer.getConfiguration().getEncoders();
+
+ List<ChannelHandler> encoders =
consumer.getConfiguration().getEncoders();
for (int x = 0; x < encoders.size(); x++) {
- channelPipeline.addLast("encoder-" + x, encoders.get(x));
+ ChannelHandler encoder = encoders.get(x);
+ if (encoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as
it may not be shareable
+ encoder = ((ChannelHandlerFactory)
encoder).newChannelHandler();
+ }
+ addToPipeline("encoder-" + x, channelPipeline, encoder);
}
- List<ChannelUpstreamHandler> decoders =
consumer.getConfiguration().getDecoders();
+ List<ChannelHandler> decoders =
consumer.getConfiguration().getDecoders();
for (int x = 0; x < decoders.size(); x++) {
- channelPipeline.addLast("decoder-" + x, decoders.get(x));
+ ChannelHandler decoder = decoders.get(x);
+ if (decoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as
it may not be shareable
+ decoder = ((ChannelHandlerFactory)
decoder).newChannelHandler();
+ }
+ addToPipeline("decoder-" + x, channelPipeline, decoder);
}
// our handler must be added last
- channelPipeline.addLast("handler", new ServerChannelHandler(consumer));
+ addToPipeline("handler", channelPipeline, new
ServerChannelHandler(consumer));
+ LOG.trace("Created ChannelPipeline: {}", channelPipeline);
return channelPipeline;
}
-
+
+ private void addToPipeline(String name, ChannelPipeline pipeline,
ChannelHandler handler) {
+ pipeline.addLast(name, handler);
+ }
+
private SslHandler configureServerSSLOnDemand(NettyConsumer consumer)
throws Exception {
if (!consumer.getConfiguration().isSsl()) {
return null;
Modified:
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java?rev=1349715&r1=1349714&r2=1349715&view=diff
==============================================================================
---
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
(original)
+++
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
Wed Jun 13 09:59:12 2012
@@ -48,6 +48,9 @@ public class NettyComponent extends Defa
config.parseURI(new URI(remaining), parameters, this);
+ // validate config
+ config.validateConfiguration();
+
NettyEndpoint nettyEndpoint = new NettyEndpoint(remaining, this,
config);
nettyEndpoint.setTimer(getTimer());
setProperties(nettyEndpoint.getConfiguration(), parameters);
Modified:
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java?rev=1349715&r1=1349714&r2=1349715&view=diff
==============================================================================
---
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
(original)
+++
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
Wed Jun 13 09:59:12 2012
@@ -26,15 +26,11 @@ import java.util.Map;
import org.apache.camel.LoggingLevel;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.util.EndpointHelper;
+import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.jsse.SSLContextParameters;
-import org.jboss.netty.channel.ChannelDownstreamHandler;
-import org.jboss.netty.channel.ChannelUpstreamHandler;
-import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.handler.codec.frame.Delimiters;
-import org.jboss.netty.handler.codec.serialization.ObjectDecoder;
-import org.jboss.netty.handler.codec.serialization.ObjectEncoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
import org.jboss.netty.handler.ssl.SslHandler;
import org.jboss.netty.util.CharsetUtil;
import org.slf4j.Logger;
@@ -62,8 +58,8 @@ public class NettyConfiguration implemen
private File keyStoreFile;
private File trustStoreFile;
private SslHandler sslHandler;
- private List<ChannelDownstreamHandler> encoders = new
ArrayList<ChannelDownstreamHandler>();
- private List<ChannelUpstreamHandler> decoders = new
ArrayList<ChannelUpstreamHandler>();
+ private List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
+ private List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
private boolean ssl;
private long sendBufferSize = 65536;
private long receiveBufferSize = 65536;
@@ -84,13 +80,14 @@ public class NettyConfiguration implemen
/**
* Returns a copy of this configuration
*/
+ @SuppressWarnings("unchecked")
public NettyConfiguration copy() {
try {
NettyConfiguration answer = (NettyConfiguration) clone();
// make sure the lists is copied in its own instance
- List<ChannelDownstreamHandler> encodersCopy = new
ArrayList<ChannelDownstreamHandler>(encoders);
+ List encodersCopy = new ArrayList(encoders);
answer.setEncoders(encodersCopy);
- List<ChannelUpstreamHandler> decodersCopy = new
ArrayList<ChannelUpstreamHandler>(decoders);
+ List decodersCopy = new ArrayList(decoders);
answer.setDecoders(decodersCopy);
return answer;
} catch (CloneNotSupportedException e) {
@@ -98,6 +95,37 @@ public class NettyConfiguration implemen
}
}
+ public void validateConfiguration() {
+ // validate that the encoders is either shareable or is a handler
factory
+ for (ChannelHandler encoder : encoders) {
+ if (encoder instanceof ChannelHandlerFactory) {
+ continue;
+ }
+ if (ObjectHelper.getAnnotation(encoder,
ChannelHandler.Sharable.class) != null) {
+ continue;
+ }
+ LOG.warn("The encoder {} is not @Shareable or an
ChannelHandlerFactory instance. The encoder cannot safely be used.", encoder);
+ }
+
+ // validate that the decoders is either shareable or is a handler
factory
+ for (ChannelHandler decoder : decoders) {
+ if (decoder instanceof ChannelHandlerFactory) {
+ continue;
+ }
+ if (ObjectHelper.getAnnotation(decoder,
ChannelHandler.Sharable.class) != null) {
+ continue;
+ }
+ LOG.warn("The decoder {} is not @Shareable or an
ChannelHandlerFactory instance. The decoder cannot safely be used.", decoder);
+ }
+ if (sslHandler != null) {
+ boolean factory = sslHandler instanceof ChannelHandlerFactory;
+ boolean shareable = ObjectHelper.getAnnotation(sslHandler,
ChannelHandler.Sharable.class) != null;
+ if (!factory && !shareable) {
+ LOG.warn("The sslHandler {} is not @Shareable or an
ChannelHandlerFactory instance. The sslHandler cannot safely be used.",
sslHandler);
+ }
+ }
+ }
+
public void parseURI(URI uri, Map<String, Object> parameters,
NettyComponent component) throws Exception {
protocol = uri.getScheme();
@@ -118,10 +146,10 @@ public class NettyConfiguration implemen
serverPipelineFactory =
component.resolveAndRemoveReferenceParameter(parameters,
"serverPipelineFactory", ServerPipelineFactory.class, null);
// set custom encoders and decoders first
- List<ChannelDownstreamHandler> referencedEncoders =
component.resolveAndRemoveReferenceListParameter(parameters, "encoders",
ChannelDownstreamHandler.class, null);
- addToHandlersList(encoders, referencedEncoders,
ChannelDownstreamHandler.class);
- List<ChannelUpstreamHandler> referencedDecoders =
component.resolveAndRemoveReferenceListParameter(parameters, "decoders",
ChannelUpstreamHandler.class, null);
- addToHandlersList(decoders, referencedDecoders,
ChannelUpstreamHandler.class);
+ List<ChannelHandler> referencedEncoders =
component.resolveAndRemoveReferenceListParameter(parameters, "encoders",
ChannelHandler.class, null);
+ addToHandlersList(encoders, referencedEncoders, ChannelHandler.class);
+ List<ChannelHandler> referencedDecoders =
component.resolveAndRemoveReferenceListParameter(parameters, "decoders",
ChannelHandler.class, null);
+ addToHandlersList(decoders, referencedDecoders, ChannelHandler.class);
// then set parameters with the help of the camel context type
converters
EndpointHelper.setReferenceProperties(component.getCamelContext(),
this, parameters);
@@ -133,9 +161,10 @@ public class NettyConfiguration implemen
// are we textline or object?
if (isTextline()) {
Charset charset = getEncoding() != null ?
Charset.forName(getEncoding()) : CharsetUtil.UTF_8;
- encoders.add(new StringEncoder(charset));
- decoders.add(new
DelimiterBasedFrameDecoder(decoderMaxLineLength, true, delimiter ==
TextLineDelimiter.LINE ? Delimiters.lineDelimiter() :
Delimiters.nulDelimiter()));
- decoders.add(new StringDecoder(charset));
+
encoders.add(ChannelHandlerFactories.newStringEncoder(charset));
+ ChannelBuffer[] delimiters = delimiter ==
TextLineDelimiter.LINE ? Delimiters.lineDelimiter() : Delimiters.nulDelimiter();
+
decoders.add(ChannelHandlerFactories.newDelimiterBasedFrameDecoder(decoderMaxLineLength,
delimiters));
+
decoders.add(ChannelHandlerFactories.newStringDecoder(charset));
if (LOG.isDebugEnabled()) {
LOG.debug("Using textline encoders and decoders with
charset: {}, delimiter: {} and decoderMaxLineLength: {}",
@@ -143,9 +172,8 @@ public class NettyConfiguration implemen
}
} else {
// object serializable is then used
- encoders.add(new ObjectEncoder());
- decoders.add(new ObjectDecoder());
-
+ encoders.add(ChannelHandlerFactories.newObjectEncoder());
+ decoders.add(ChannelHandlerFactories.newObjectDecoder());
LOG.debug("Using object encoders and decoders");
}
} else {
@@ -291,42 +319,42 @@ public class NettyConfiguration implemen
this.sslHandler = sslHandler;
}
- public List<ChannelDownstreamHandler> getEncoders() {
+ public List<ChannelHandler> getDecoders() {
+ return decoders;
+ }
+
+ public void setDecoders(List<ChannelHandler> decoders) {
+ this.decoders = decoders;
+ }
+
+ public List<ChannelHandler> getEncoders() {
return encoders;
}
- public List<ChannelUpstreamHandler> getDecoders() {
- return decoders;
+ public void setEncoders(List<ChannelHandler> encoders) {
+ this.encoders = encoders;
}
- public ChannelDownstreamHandler getEncoder() {
+ public ChannelHandler getEncoder() {
return encoders.isEmpty() ? null : encoders.get(0);
}
- public void setEncoder(ChannelDownstreamHandler encoder) {
+ public void setEncoder(ChannelHandler encoder) {
if (!encoders.contains(encoder)) {
encoders.add(encoder);
}
}
- public void setEncoders(List<ChannelDownstreamHandler> encoders) {
- this.encoders = encoders;
- }
-
- public ChannelUpstreamHandler getDecoder() {
+ public ChannelHandler getDecoder() {
return decoders.isEmpty() ? null : decoders.get(0);
}
- public void setDecoder(ChannelUpstreamHandler decoder) {
+ public void setDecoder(ChannelHandler decoder) {
if (!decoders.contains(decoder)) {
decoders.add(decoder);
}
}
- public void setDecoders(List<ChannelUpstreamHandler> decoders) {
- this.decoders = decoders;
- }
-
public long getSendBufferSize() {
return sendBufferSize;
}
@@ -451,17 +479,6 @@ public class NettyConfiguration implemen
return host + ":" + port;
}
- private <T> void addToHandlersList(List configured, List handlers, Class<?
extends T> handlerType) {
- if (handlers != null) {
- for (int x = 0; x < handlers.size(); x++) {
- Object handler = handlers.get(x);
- if (handlerType.isInstance(handler)) {
- configured.add(handler);
- }
- }
- }
- }
-
public void setClientPipelineFactory(ClientPipelineFactory
clientPipelineFactory) {
this.clientPipelineFactory = clientPipelineFactory;
}
@@ -477,7 +494,7 @@ public class NettyConfiguration implemen
public ServerPipelineFactory getServerPipelineFactory() {
return serverPipelineFactory;
}
-
+
public int getWorkerCount() {
return workerCount;
}
@@ -493,4 +510,15 @@ public class NettyConfiguration implemen
public void setSslContextParameters(SSLContextParameters
sslContextParameters) {
this.sslContextParameters = sslContextParameters;
}
+
+ private static <T> void addToHandlersList(List<T> configured, List<T>
handlers, Class<T> handlerType) {
+ if (handlers != null) {
+ for (int x = 0; x < handlers.size(); x++) {
+ T handler = handlers.get(x);
+ if (handlerType.isInstance(handler)) {
+ configured.add(handler);
+ }
+ }
+ }
+ }
}
Modified:
camel/branches/camel-2.9.x/components/camel-netty/src/test/java/org/apache/camel/component/netty/MultipleCodecsTest.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/test/java/org/apache/camel/component/netty/MultipleCodecsTest.java?rev=1349715&r1=1349714&r2=1349715&view=diff
==============================================================================
---
camel/branches/camel-2.9.x/components/camel-netty/src/test/java/org/apache/camel/component/netty/MultipleCodecsTest.java
(original)
+++
camel/branches/camel-2.9.x/components/camel-netty/src/test/java/org/apache/camel/component/netty/MultipleCodecsTest.java
Wed Jun 13 09:59:12 2012
@@ -24,6 +24,7 @@ import org.apache.camel.builder.RouteBui
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
import org.jboss.netty.channel.ChannelDownstreamHandler;
+import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelUpstreamHandler;
import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
import org.jboss.netty.handler.codec.frame.LengthFieldPrepender;
@@ -38,7 +39,8 @@ public class MultipleCodecsTest extends
JndiRegistry registry = super.createRegistry();
// START SNIPPET: registry-beans
- LengthFieldBasedFrameDecoder lengthDecoder = new
LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4);
+ ChannelHandlerFactory lengthDecoder =
ChannelHandlerFactories.newLengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4);
+
StringDecoder stringDecoder = new StringDecoder();
registry.bind("length-decoder", lengthDecoder);
registry.bind("string-decoder", stringDecoder);
@@ -48,11 +50,11 @@ public class MultipleCodecsTest extends
registry.bind("length-encoder", lengthEncoder);
registry.bind("string-encoder", stringEncoder);
- List<ChannelUpstreamHandler> decoders = new
ArrayList<ChannelUpstreamHandler>();
+ List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
decoders.add(lengthDecoder);
decoders.add(stringDecoder);
- List<ChannelDownstreamHandler> encoders = new
ArrayList<ChannelDownstreamHandler>();
+ List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
encoders.add(lengthEncoder);
encoders.add(stringEncoder);
Modified:
camel/branches/camel-2.9.x/components/camel-netty/src/test/resources/org/apache/camel/component/netty/multiple-codecs.xml
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/test/resources/org/apache/camel/component/netty/multiple-codecs.xml?rev=1349715&r1=1349714&r2=1349715&view=diff
==============================================================================
---
camel/branches/camel-2.9.x/components/camel-netty/src/test/resources/org/apache/camel/component/netty/multiple-codecs.xml
(original)
+++
camel/branches/camel-2.9.x/components/camel-netty/src/test/resources/org/apache/camel/component/netty/multiple-codecs.xml
Wed Jun 13 09:59:12 2012
@@ -37,7 +37,7 @@
<!-- START SNIPPET: registry-beans -->
<util:list id="decoders" list-class="java.util.LinkedList">
- <bean
class="org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder">
+ <bean class="org.apache.camel.component.netty.ChannelHandlerFactories"
factory-method="newLengthFieldBasedFrameDecoder">
<constructor-arg value="1048576"/>
<constructor-arg value="0"/>
<constructor-arg value="4"/>
@@ -59,7 +59,7 @@
</bean>
<bean id="string-encoder"
class="org.jboss.netty.handler.codec.string.StringEncoder"/>
- <bean id="length-decoder"
class="org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder">
+ <bean id="length-decoder"
class="org.apache.camel.component.netty.ChannelHandlerFactories"
factory-method="newLengthFieldBasedFrameDecoder">
<constructor-arg value="1048576"/>
<constructor-arg value="0"/>
<constructor-arg value="4"/>