34
34
/**
35
35
* Provides {@link EventLoopGroup} and {@link ChannelFactory} for {@link NettyNioAsyncHttpClient}.
36
36
* <p>
37
- * There are three ways to create a new instance.
37
+ * There are four ways to create a new instance.
38
38
*
39
39
* <ul>
40
40
* <li>using {@link #builder()} to provide custom configuration of {@link EventLoopGroup}.
49
49
*
50
50
* <li>Using {@link #create(EventLoopGroup, ChannelFactory)} to provide a custom {@link EventLoopGroup} and
51
51
* {@link ChannelFactory}
52
+ *
53
+ * <li>Using {@link #create(EventLoopGroup, ChannelFactory, ChannelFactory)} to provide a custom {@link EventLoopGroup}, and
54
+ * socket and datagram {@link ChannelFactory}'s.
52
55
* </ul>
53
56
*
54
57
* <p>
@@ -78,6 +81,16 @@ public final class SdkEventLoopGroup {
78
81
this .datagramChannelFactory = ChannelResolver .resolveDatagramChannelFactory (eventLoopGroup );
79
82
}
80
83
84
+ SdkEventLoopGroup (EventLoopGroup eventLoopGroup , ChannelFactory <? extends Channel > socketChannelFactory ,
85
+ ChannelFactory <? extends DatagramChannel > datagramChannelFactory ) {
86
+ Validate .paramNotNull (eventLoopGroup , "eventLoopGroup" );
87
+ Validate .paramNotNull (socketChannelFactory , "socketChannelFactory" );
88
+ Validate .paramNotNull (datagramChannelFactory , "datagramChannelFactory" );
89
+ this .eventLoopGroup = eventLoopGroup ;
90
+ this .channelFactory = socketChannelFactory ;
91
+ this .datagramChannelFactory = datagramChannelFactory ;
92
+ }
93
+
81
94
/**
82
95
* Create an instance of {@link SdkEventLoopGroup} from the builder
83
96
*/
@@ -109,15 +122,30 @@ public ChannelFactory<? extends DatagramChannel> datagramChannelFactory() {
109
122
}
110
123
111
124
/**
112
- * Creates a new instance of SdkEventLoopGroup with {@link EventLoopGroup} and {@link ChannelFactory}
125
+ * Creates a new instance of SdkEventLoopGroup with {@link EventLoopGroup} and socket {@link ChannelFactory}
113
126
* to be used with {@link NettyNioAsyncHttpClient}.
114
127
*
115
128
* @param eventLoopGroup the EventLoopGroup to be used
116
- * @param channelFactory the channel factor to be used
129
+ * @param socketChannelFactory the socket channel factory to be used
117
130
* @return a new instance of SdkEventLoopGroup
118
131
*/
119
- public static SdkEventLoopGroup create (EventLoopGroup eventLoopGroup , ChannelFactory <? extends Channel > channelFactory ) {
120
- return new SdkEventLoopGroup (eventLoopGroup , channelFactory );
132
+ public static SdkEventLoopGroup create (EventLoopGroup eventLoopGroup ,
133
+ ChannelFactory <? extends Channel > socketChannelFactory ) {
134
+ return new SdkEventLoopGroup (eventLoopGroup , socketChannelFactory );
135
+ }
136
+
137
+ /**
138
+ * Creates a new instance of SdkEventLoopGroup with {@link EventLoopGroup}, and socket and datagram
139
+ * {@link ChannelFactory}'s to be used with {@link NettyNioAsyncHttpClient}.
140
+ *
141
+ * @param eventLoopGroup the EventLoopGroup to be used
142
+ * @param socketChannelFactory the socket channel factory to be used
143
+ * @param datagramChannelFactory the datagram channel factory to be used
144
+ * @return a new instance of SdkEventLoopGroup
145
+ */
146
+ public static SdkEventLoopGroup create (EventLoopGroup eventLoopGroup , ChannelFactory <? extends Channel > socketChannelFactory ,
147
+ ChannelFactory <? extends DatagramChannel > datagramChannelFactory ) {
148
+ return new SdkEventLoopGroup (eventLoopGroup , socketChannelFactory , datagramChannelFactory );
121
149
}
122
150
123
151
/**
@@ -128,8 +156,11 @@ public static SdkEventLoopGroup create(EventLoopGroup eventLoopGroup, ChannelFac
128
156
* be thrown for any unknown EventLoopGroup type.
129
157
* <p>
130
158
* If {@link MultiThreadIoEventLoopGroup} is passed in, {@link NioSocketChannel} and {@link NioDatagramChannel} will be
131
- * resolved, regardless of the transport {@link IoHandlerFactory} passed in. This is because it is not possible to
132
- * determine the type of transport factory from a given {@link MultiThreadIoEventLoopGroup}.
159
+ * resolved, regardless of the transport {@link IoHandlerFactory} set on the {@link MultiThreadIoEventLoopGroup}. This is
160
+ * because it is not possible to determine the type of transport factory from a given {@link MultiThreadIoEventLoopGroup}.
161
+ * <p>
162
+ * To use a {@link MultiThreadIoEventLoopGroup} with a non-Nio transport factory, use
163
+ * {@link #create(EventLoopGroup, ChannelFactory, ChannelFactory)}, specifying the socket and datagram channels.
133
164
*
134
165
* @param eventLoopGroup the EventLoopGroup to be used
135
166
* @return a new instance of SdkEventLoopGroup
0 commit comments