Skip to content

Commit d53b590

Browse files
author
Stephane Landelle
committed
Introduce Netty Commons module
1 parent d859e46 commit d53b590

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+214
-418
lines changed

providers/netty-commons/pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<parent>
4+
<groupId>org.asynchttpclient</groupId>
5+
<artifactId>async-http-client-providers-parent</artifactId>
6+
<version>2.0.0-SNAPSHOT</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
<artifactId>async-http-client-netty-commons</artifactId>
10+
<name>Asynchronous Http Client Netty Providers Common Classes</name>
11+
<description>
12+
The Async Http Client Netty Common Classes.
13+
</description>
14+
15+
<repositories>
16+
<repository>
17+
<id>sonatype-releases</id>
18+
<url>https://oss.sonatype.org/content/repositories/releases</url>
19+
<releases>
20+
<enabled>true</enabled>
21+
</releases>
22+
<snapshots>
23+
<enabled>false</enabled>
24+
</snapshots>
25+
</repository>
26+
<repository>
27+
<id>sonatype-snapshots</id>
28+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
29+
<releases>
30+
<enabled>false</enabled>
31+
</releases>
32+
<snapshots>
33+
<enabled>true</enabled>
34+
</snapshots>
35+
</repository>
36+
</repositories>
37+
</project>

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/DiscardEvent.java renamed to providers/netty-commons/src/main/java/org/asynchttpclient/providers/netty/commons/DiscardEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1313
*/
14-
package org.asynchttpclient.providers.netty3;
14+
package org.asynchttpclient.providers.netty.commons;
1515

1616
/**
1717
* Simple marker for stopping publishing bytes
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1313
*/
14-
package org.asynchttpclient.providers.netty3.channel.pool;
14+
package org.asynchttpclient.providers.netty.commons.channel.pool;
1515

1616
public interface ChannelPoolPartitionSelector {
1717

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/future/StackTraceInspector.java renamed to providers/netty-commons/src/main/java/org/asynchttpclient/providers/netty/commons/future/StackTraceInspector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1212
*/
13-
package org.asynchttpclient.providers.netty4.future;
13+
package org.asynchttpclient.providers.netty.commons.future;
1414

1515
public class StackTraceInspector {
1616

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/handler/ConnectionStrategy.java renamed to providers/netty-commons/src/main/java/org/asynchttpclient/providers/netty/commons/handler/ConnectionStrategy.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,18 @@
1111
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1313
*/
14-
package org.asynchttpclient.providers.netty4.handler;
15-
16-
import io.netty.handler.codec.http.HttpRequest;
17-
import io.netty.handler.codec.http.HttpResponse;
14+
package org.asynchttpclient.providers.netty.commons.handler;
1815

1916
/**
2017
* Provides an interface for decisions about HTTP connections.
2118
*/
22-
public interface ConnectionStrategy {
19+
public interface ConnectionStrategy<REQUEST, RESPONSE> {
2320

2421
/**
2522
* Determines whether the connection should be kept alive after this HTTP message exchange.
2623
* @param request the HTTP request
2724
* @param response the HTTP response
2825
* @return true if the connection should be kept alive, false if it should be closed.
2926
*/
30-
boolean keepAlive(HttpRequest request, HttpResponse response);
27+
boolean keepAlive(REQUEST request, RESPONSE response);
3128
}

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/util/HttpUtils.java renamed to providers/netty-commons/src/main/java/org/asynchttpclient/providers/netty/commons/util/HttpUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@
33
*
44
* This program is licensed to you under the Apache License Version 2.0,
55
* and you may not use this file except in compliance with the Apache License Version 2.0.
6-
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at
7+
* http://www.apache.org/licenses/LICENSE-2.0.
78
*
89
* Unless required by applicable law or agreed to in writing,
910
* software distributed under the Apache License Version 2.0 is distributed on an
1011
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1112
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1213
*/
13-
package org.asynchttpclient.providers.netty4.util;
14+
package org.asynchttpclient.providers.netty.commons.util;
1415

1516
import java.util.List;
1617

1718
import org.asynchttpclient.uri.Uri;
1819

1920
public final class HttpUtils {
2021

21-
public static final String HTTPS = "https";
2222
public static final String HTTP = "http";
23+
public static final String HTTPS = "https";
2324
public static final String WEBSOCKET = "ws";
2425
public static final String WEBSOCKET_SSL = "wss";
2526

@@ -38,7 +39,7 @@ public static String getNTLM(List<String> authenticateHeaders) {
3839
}
3940

4041
public static boolean isWebSocket(String scheme) {
41-
return WEBSOCKET.equals(scheme) || WEBSOCKET_SSL.equals(scheme);
42+
return WEBSOCKET.equals(scheme) || WEBSOCKET_SSL.equalsIgnoreCase(scheme);
4243
}
4344

4445
public static boolean isSecure(String scheme) {

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/ws/WebSocketUtils.java renamed to providers/netty-commons/src/main/java/org/asynchttpclient/providers/netty/commons/util/WebSocketUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
1313
*/
14-
package org.asynchttpclient.providers.netty3.ws;
14+
package org.asynchttpclient.providers.netty.commons.util;
1515

1616
import java.io.UnsupportedEncodingException;
1717
import java.security.MessageDigest;

providers/netty3/pom.xml

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<parent>
4-
<groupId>org.asynchttpclient</groupId>
5-
<artifactId>async-http-client-providers-parent</artifactId>
6-
<version>2.0.0-SNAPSHOT</version>
7-
</parent>
8-
<modelVersion>4.0.0</modelVersion>
9-
<artifactId>async-http-client-netty3-provider</artifactId>
10-
<name>Asynchronous Http Client Netty 3 Provider</name>
11-
<description>
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<parent>
4+
<groupId>org.asynchttpclient</groupId>
5+
<artifactId>async-http-client-providers-parent</artifactId>
6+
<version>2.0.0-SNAPSHOT</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
<artifactId>async-http-client-netty3-provider</artifactId>
10+
<name>Asynchronous Http Client Netty 3 Provider</name>
11+
<description>
1212
The Async Http Client Netty 3 Provider.
1313
</description>
1414

15-
<repositories>
16-
<repository>
17-
<id>sonatype-releases</id>
18-
<url>https://oss.sonatype.org/content/repositories/releases</url>
19-
<releases>
20-
<enabled>true</enabled>
21-
</releases>
22-
<snapshots>
23-
<enabled>false</enabled>
24-
</snapshots>
25-
</repository>
26-
<repository>
27-
<id>sonatype-snapshots</id>
28-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
29-
<releases>
30-
<enabled>false</enabled>
31-
</releases>
32-
<snapshots>
33-
<enabled>true</enabled>
34-
</snapshots>
35-
</repository>
36-
</repositories>
15+
<repositories>
16+
<repository>
17+
<id>sonatype-releases</id>
18+
<url>https://oss.sonatype.org/content/repositories/releases</url>
19+
<releases>
20+
<enabled>true</enabled>
21+
</releases>
22+
<snapshots>
23+
<enabled>false</enabled>
24+
</snapshots>
25+
</repository>
26+
<repository>
27+
<id>sonatype-snapshots</id>
28+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
29+
<releases>
30+
<enabled>false</enabled>
31+
</releases>
32+
<snapshots>
33+
<enabled>true</enabled>
34+
</snapshots>
35+
</repository>
36+
</repositories>
3737

38-
<dependencies>
39-
<dependency>
40-
<groupId>io.netty</groupId>
41-
<artifactId>netty</artifactId>
42-
<version>3.9.5.Final</version>
43-
</dependency>
44-
</dependencies>
38+
<dependencies>
39+
<dependency>
40+
<groupId>io.netty</groupId>
41+
<artifactId>netty</artifactId>
42+
<version>3.9.5.Final</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.asynchttpclient</groupId>
46+
<artifactId>async-http-client-netty-commons</artifactId>
47+
<version>${project.version}</version>
48+
</dependency>
49+
</dependencies>
4550

4651
</project>

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/NettyAsyncHttpProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import org.asynchttpclient.AsyncHttpProvider;
2121
import org.asynchttpclient.ListenableFuture;
2222
import org.asynchttpclient.Request;
23+
import org.asynchttpclient.providers.netty.commons.channel.pool.ChannelPoolPartitionSelector;
2324
import org.asynchttpclient.providers.netty3.channel.ChannelManager;
24-
import org.asynchttpclient.providers.netty3.channel.pool.ChannelPoolPartitionSelector;
2525
import org.asynchttpclient.providers.netty3.request.NettyRequestSender;
2626
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
2727
import org.jboss.netty.util.HashedWheelTimer;

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/NettyAsyncHttpProviderConfig.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020

2121
import org.asynchttpclient.AsyncHttpProviderConfig;
2222
import org.asynchttpclient.SSLEngineFactory;
23+
import org.asynchttpclient.providers.netty.commons.handler.ConnectionStrategy;
2324
import org.asynchttpclient.providers.netty3.channel.pool.ChannelPool;
24-
import org.asynchttpclient.providers.netty3.handler.ConnectionStrategy;
2525
import org.asynchttpclient.providers.netty3.handler.Http1Point1ConnectionStrategy;
2626
import org.asynchttpclient.providers.netty3.ws.NettyWebSocket;
2727
import org.jboss.netty.channel.Channel;
2828
import org.jboss.netty.channel.ChannelPipeline;
2929
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
30+
import org.jboss.netty.handler.codec.http.HttpRequest;
31+
import org.jboss.netty.handler.codec.http.HttpResponse;
3032
import org.jboss.netty.util.Timer;
3133

3234
/**
@@ -146,7 +148,7 @@ public Set<Map.Entry<String, Object>> propertiesSet() {
146148

147149
private boolean keepEncodingHeader = false;
148150

149-
private ConnectionStrategy connectionStrategy = new Http1Point1ConnectionStrategy();
151+
private ConnectionStrategy<HttpRequest, HttpResponse> connectionStrategy = new Http1Point1ConnectionStrategy();
150152

151153
public boolean isUseDeadLockChecker() {
152154
return useDeadLockChecker;
@@ -308,11 +310,11 @@ public void setKeepEncodingHeader(boolean keepEncodingHeader) {
308310
this.keepEncodingHeader = keepEncodingHeader;
309311
}
310312

311-
public ConnectionStrategy getConnectionStrategy() {
313+
public ConnectionStrategy<HttpRequest, HttpResponse> getConnectionStrategy() {
312314
return connectionStrategy;
313315
}
314316

315-
public void setConnectionStrategy(ConnectionStrategy connectionStrategy) {
317+
public void setConnectionStrategy(ConnectionStrategy<HttpRequest, HttpResponse> connectionStrategy) {
316318
this.connectionStrategy = connectionStrategy;
317319
}
318320

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/channel/ChannelManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
*/
1414
package org.asynchttpclient.providers.netty3.channel;
1515

16-
import static org.asynchttpclient.providers.netty3.util.HttpUtils.WEBSOCKET;
17-
import static org.asynchttpclient.providers.netty3.util.HttpUtils.isSecure;
18-
import static org.asynchttpclient.providers.netty3.util.HttpUtils.isWebSocket;
16+
import static org.asynchttpclient.providers.netty.commons.util.HttpUtils.WEBSOCKET;
17+
import static org.asynchttpclient.providers.netty.commons.util.HttpUtils.isSecure;
18+
import static org.asynchttpclient.providers.netty.commons.util.HttpUtils.isWebSocket;
1919
import static org.jboss.netty.channel.Channels.pipeline;
2020
import static org.jboss.netty.handler.ssl.SslHandler.getDefaultBufferPool;
2121

@@ -34,10 +34,10 @@
3434
import org.asynchttpclient.ConnectionPoolPartitioning;
3535
import org.asynchttpclient.ProxyServer;
3636
import org.asynchttpclient.SSLEngineFactory;
37+
import org.asynchttpclient.providers.netty.commons.channel.pool.ChannelPoolPartitionSelector;
3738
import org.asynchttpclient.providers.netty3.Callback;
3839
import org.asynchttpclient.providers.netty3.NettyAsyncHttpProviderConfig;
3940
import org.asynchttpclient.providers.netty3.channel.pool.ChannelPool;
40-
import org.asynchttpclient.providers.netty3.channel.pool.ChannelPoolPartitionSelector;
4141
import org.asynchttpclient.providers.netty3.channel.pool.DefaultChannelPool;
4242
import org.asynchttpclient.providers.netty3.channel.pool.NoopChannelPool;
4343
import org.asynchttpclient.providers.netty3.future.NettyResponseFuture;

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/channel/Channels.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
package org.asynchttpclient.providers.netty3.channel;
1515

16-
import org.asynchttpclient.providers.netty3.DiscardEvent;
16+
import org.asynchttpclient.providers.netty.commons.DiscardEvent;
1717
import org.jboss.netty.channel.Channel;
1818
import org.slf4j.Logger;
1919
import org.slf4j.LoggerFactory;

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/channel/pool/ChannelPool.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
package org.asynchttpclient.providers.netty3.channel.pool;
1515

16+
import org.asynchttpclient.AsyncHttpProvider;
17+
import org.asynchttpclient.providers.netty.commons.channel.pool.ChannelPoolPartitionSelector;
1618
import org.jboss.netty.channel.Channel;
1719

1820
/**

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/channel/pool/DefaultChannelPool.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.concurrent.atomic.AtomicBoolean;
2626

2727
import org.asynchttpclient.AsyncHttpClientConfig;
28+
import org.asynchttpclient.providers.netty.commons.channel.pool.ChannelPoolPartitionSelector;
2829
import org.asynchttpclient.providers.netty3.channel.Channels;
2930
import org.asynchttpclient.providers.netty3.future.NettyResponseFuture;
3031
import org.jboss.netty.channel.Channel;

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/channel/pool/NoopChannelPool.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
package org.asynchttpclient.providers.netty3.channel.pool;
1515

16+
import org.asynchttpclient.providers.netty.commons.channel.pool.ChannelPoolPartitionSelector;
1617
import org.jboss.netty.channel.Channel;
1718

1819
public class NoopChannelPool implements ChannelPool {

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/future/StackTraceInspector.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)