diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionInterceptorFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionInterceptorFactory.java
index c580d73f83..a256e1dad8 100644
--- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionInterceptorFactory.java
+++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionInterceptorFactory.java
@@ -17,15 +17,20 @@ package org.springframework.integration.ip.tcp.connection;
/**
- * Base class for TcpConnectionInterceptorFactories. Subclasses create prototype beans by
- * default.
+ * Interface for TCP connection interceptor factories.
*
* @author Gary Russell
* @since 2.0
*
*/
-public abstract class TcpConnectionInterceptorFactory {
+public interface TcpConnectionInterceptorFactory {
+ /**
+ * Called for each new connection - if an interceptor is
+ * stateful, a new interceptor must be returned on each call.
+ *
+ * @return the TcpInterceptor
+ */
public abstract TcpConnectionInterceptor getInterceptor();
}
diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptorFactory.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptorFactory.java
index f67f786e51..1f4dc8978a 100644
--- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptorFactory.java
+++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptorFactory.java
@@ -21,7 +21,7 @@ package org.springframework.integration.ip.tcp.connection;
* @since 2.0
*
*/
-public class HelloWorldInterceptorFactory extends
+public class HelloWorldInterceptorFactory implements
TcpConnectionInterceptorFactory {
private String hello = "Hello";
@@ -41,7 +41,6 @@ public class HelloWorldInterceptorFactory extends
}
- @Override
public TcpConnectionInterceptor getInterceptor() {
return new HelloWorldInterceptor(hello, world);
}
diff --git a/src/docbkx/ip.xml b/src/docbkx/ip.xml
index 8d75ba1834..552e6be8da 100644
--- a/src/docbkx/ip.xml
+++ b/src/docbkx/ip.xml
@@ -250,15 +250,78 @@
A server connection factory that uses java.net.Socket
connections and uses Java serialization on the wire.
+
+ For full details of the attributes available on connection factories, see the
+ reference at the end of this section.
+
+
+
+ Tcp Connection Interceptors
Connection factories can be configured with a reference to a
TcpConnectionInterceptorFactoryChain. Interceptors can be used
to add behavior to connections, such as negotiation, security, and other setup.
- Further documentation to follow.
+ No interceptors are currently provided by the framework but, for an example,
+ see the InterceptedSharedConnectionTests in the source
+ repository.
- For full details of the attributes available on connection factories, see the
- reference at the end of this section.
+ The HelloWorldInterceptor used in the test case works as follows:
+
+
+ When configured with a client connection factory,
+ when the first message is sent over a connection that is intercepted, the interceptor
+ sends 'Hello' over the connection, and expects to receive 'world!'. When that occurs,
+ the negotiation is complete and the original message is sent; further messages
+ that use the same connection are sent without any additional negotiation.
+
+
+ When configured with a server connection factory, the interceptor requires the first
+ message to be 'Hello' and, if it is, returns 'world!'. Otherwise it throws an exception causing
+ the connection to be closed.
+
+
+ All TcpConnection methods are intercepted.
+ Interceptor instances are created for each connection by an interceptor factory.
+ If an interceptor is stateful, the factory should create a new instance for each connection.
+ Interceptor
+ factories are added to the configuration of an interceptor factory chain, which is provided
+ to a connection factory using the interceptor-factory attribute.
+ Interceptors must implement the TcpConnectionInterceptor interface;
+ factories
+ must implement the TcpConnectionInterceptorFactory interface. A
+ convenience class AbstractTcpConnectionInterceptor is provided
+ with passthrough methods; by extending this class, you only need to implement those
+ methods you wish to intercept.
+
+
+
+
+
+
+
+
+
+
+
+
+]]>
+ Configuring a connection interceptor factory chain.