5
5
import org .jboss .netty .channel .Channels ;
6
6
import org .jboss .netty .handler .codec .frame .LengthFieldBasedFrameDecoder ;
7
7
import org .jboss .netty .handler .codec .frame .LengthFieldPrepender ;
8
+ import org .jboss .netty .handler .execution .ExecutionHandler ;
8
9
import org .menacheri .jetclient .app .ISession ;
9
10
import org .menacheri .jetclient .communication .IMessageBuffer ;
10
11
import org .menacheri .jetclient .event .IEvent ;
@@ -38,20 +39,29 @@ public class TCPPipelineFactory implements ChannelPipelineFactory
38
39
* {@link IEvent} instance to the next decoder/handler in the chain.
39
40
*/
40
41
private static final MessageBufferEventEncoder EVENT_ENCODER = new MessageBufferEventEncoder ();
42
+ private final ExecutionHandler executionHandler ;
41
43
/**
42
44
* Used to transmit the message to {@link ISession}.
43
45
*/
44
46
private final DefaultToClientHandler defaultToClientHandler ;
45
47
46
48
public TCPPipelineFactory (ISession session )
47
49
{
48
- this (new DefaultToClientHandler (session ));
50
+ this (new DefaultToClientHandler (session ), null );
49
51
}
50
52
51
53
public TCPPipelineFactory (
52
- final DefaultToClientHandler defaultToClientHandler )
54
+ final DefaultToClientHandler defaultToClientHandler , final ExecutionHandler executionHandler )
53
55
{
54
56
this .defaultToClientHandler = defaultToClientHandler ;
57
+ if (null == executionHandler )
58
+ {
59
+ this .executionHandler = ExecutionHandlerSingleton .getExecutionHandler ();
60
+ }
61
+ else
62
+ {
63
+ this .executionHandler = executionHandler ;
64
+ }
55
65
}
56
66
57
67
@ Override
@@ -60,6 +70,7 @@ public ChannelPipeline getPipeline() throws Exception
60
70
ChannelPipeline pipeline = Channels .pipeline ();
61
71
pipeline .addLast ("lengthDecoder" , new LengthFieldBasedFrameDecoder (
62
72
Integer .MAX_VALUE , 0 , 2 , 0 , 2 ));
73
+ pipeline .addLast ("executionHandler" , executionHandler );
63
74
pipeline .addLast ("eventDecoder" , EVENT_DECODER );
64
75
pipeline .addLast (DefaultToClientHandler .getName (),
65
76
defaultToClientHandler );
0 commit comments