Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 41973c7

Browse files
author
Adam Lindenthal
committed
Move JdkConnector from incubator to connectors
Change-Id: Ief17d249a746aac328dc9659c15e69ae2c973b7f
1 parent b37dfa1 commit 41973c7

File tree

95 files changed

+874
-320
lines changed

Some content is hidden

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

95 files changed

+874
-320
lines changed

bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
<artifactId>jersey-jetty-connector</artifactId>
102102
<version>${project.version}</version>
103103
</dependency>
104+
<dependency>
105+
<groupId>org.glassfish.jersey.connectors</groupId>
106+
<artifactId>jersey-jdk-connector</artifactId>
107+
<version>${project.version}</version>
108+
</dependency>
104109
<dependency>
105110
<groupId>org.glassfish.jersey.containers</groupId>
106111
<artifactId>jersey-container-jetty-http</artifactId>

connectors/grizzly-connector/src/main/java/org/glassfish/jersey/grizzly/connector/GrizzlyConnector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ class GrizzlyConnector implements Connector {
122122
builder = builder.setExecutorService(executorService);
123123

124124
builder.setConnectTimeout(ClientProperties.getValue(config.getProperties(),
125-
ClientProperties.CONNECT_TIMEOUT, 0));
125+
ClientProperties.CONNECT_TIMEOUT, 10000));
126126

127127
builder.setRequestTimeout(ClientProperties.getValue(config.getProperties(),
128-
ClientProperties.READ_TIMEOUT, 0));
128+
ClientProperties.READ_TIMEOUT, 10000));
129129

130130
Object proxyUri;
131131
proxyUri = config.getProperty(ClientProperties.PROXY_URI);

incubator/jdk-connector/pom.xml renamed to connectors/jdk-connector/pom.xml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55
6-
Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2011-2017 Oracle and/or its affiliates. All rights reserved.
77
88
The contents of this file are subject to the terms of either the GNU
99
General Public License Version 2 only ("GPL") or the Common Development
@@ -44,7 +44,7 @@
4444
<modelVersion>4.0.0</modelVersion>
4545

4646
<parent>
47-
<groupId>org.glassfish.jersey.incubator</groupId>
47+
<groupId>org.glassfish.jersey.connectors</groupId>
4848
<artifactId>project</artifactId>
4949
<version>2.26-SNAPSHOT</version>
5050
</parent>
@@ -53,12 +53,28 @@
5353
<packaging>jar</packaging>
5454
<name>jersey-connectors-jdk</name>
5555

56-
<description>Jersey Client Transport via JDK AIO</description>
56+
<description>Jersey Client Transport via JDK connector</description>
5757

5858
<properties>
5959
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6060
</properties>
6161

62+
<dependencies>
63+
<dependency>
64+
<groupId>org.glassfish.jersey.containers</groupId>
65+
<artifactId>jersey-container-grizzly2-http</artifactId>
66+
<version>${project.version}</version>
67+
<scope>test</scope>
68+
</dependency>
69+
70+
<dependency>
71+
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
72+
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
73+
<version>${project.version}</version>
74+
<scope>test</scope>
75+
</dependency>
76+
</dependencies>
77+
6278
<build>
6379
<plugins>
6480
<plugin>
@@ -71,26 +87,16 @@
7187
<artifactId>build-helper-maven-plugin</artifactId>
7288
<inherited>true</inherited>
7389
</plugin>
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-compiler-plugin</artifactId>
93+
</plugin>
94+
<plugin>
95+
<groupId>org.apache.felix</groupId>
96+
<artifactId>maven-bundle-plugin</artifactId>
97+
<inherited>true</inherited>
98+
</plugin>
7499
</plugins>
75100
</build>
76101

77-
<dependencies>
78-
<dependency>
79-
<groupId>org.glassfish.jersey.core</groupId>
80-
<artifactId>jersey-client</artifactId>
81-
<version>${project.version}</version>
82-
</dependency>
83-
<dependency>
84-
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
85-
<artifactId>jersey-test-framework-provider-bundle</artifactId>
86-
<version>${project.version}</version>
87-
<type>pom</type>
88-
<scope>test</scope>
89-
</dependency>
90-
<dependency>
91-
<groupId>junit</groupId>
92-
<artifactId>junit</artifactId>
93-
<scope>test</scope>
94-
</dependency>
95-
</dependencies>
96102
</project>
Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -37,26 +37,26 @@
3737
* only if the new code is made subject to such option by the copyright
3838
* holder.
3939
*/
40-
4140
package org.glassfish.jersey.jdk.connector;
4241

4342
import java.net.CookiePolicy;
43+
import java.util.Map;
4444

45-
import javax.ws.rs.client.Client;
46-
import javax.ws.rs.core.Configuration;
47-
48-
import org.glassfish.jersey.client.spi.Connector;
49-
import org.glassfish.jersey.client.spi.ConnectorProvider;
45+
import org.glassfish.jersey.internal.util.PropertiesClass;
46+
import org.glassfish.jersey.internal.util.PropertiesHelper;
5047

5148
/**
52-
* @author Petr Janouch (petr.janouch at oracle.com)
49+
* Configuration options specific to {@link org.glassfish.jersey.jdk.connector.internal.JdkConnector}.
50+
*
51+
* @author Adam Lindenthal (adam.lindenthal at oracle.com)
5352
*/
54-
public class JdkConnectorProvider implements ConnectorProvider {
53+
@PropertiesClass
54+
public final class JdkConnectorProperties {
5555

5656
/**
5757
* Configuration of the connector thread pool.
5858
* <p/>
59-
* An instance of {@link ThreadPoolConfig} is expected.
59+
* An instance of {@link org.glassfish.jersey.jdk.connector.internal.ThreadPoolConfig} is expected.
6060
*/
6161
public static final String WORKER_THREAD_POOL_CONFIG = "jersey.config.client.JdkConnectorProvider.workerThreadPoolConfig";
6262

@@ -86,7 +86,7 @@ public class JdkConnectorProvider implements ConnectorProvider {
8686
* otherwise {@code MAX_HEADER_SIZE} is not applied.
8787
*
8888
* @see org.glassfish.jersey.client.ClientProperties#FOLLOW_REDIRECTS
89-
* @see RedirectException
89+
* @see org.glassfish.jersey.jdk.connector.internal.RedirectException
9090
*/
9191
public static final String MAX_REDIRECTS = "jersey.config.client.JdkConnectorProvider.maxRedirects";
9292

@@ -119,16 +119,53 @@ public class JdkConnectorProvider implements ConnectorProvider {
119119
*/
120120
public static final String CONNECTION_IDLE_TIMEOUT = "jersey.config.client.JdkConnectorProvider.connectionIdleTimeout";
121121

122-
static final int DEFAULT_HTTP_CHUNK_SIZE = 4096;
123-
static final int DEFAULT_MAX_HEADER_SIZE = 8192;
124-
static final int DEFAULT_MAX_REDIRECTS = 5;
125-
static final CookiePolicy DEFAULT_COOKIE_POLICY = CookiePolicy.ACCEPT_ORIGINAL_SERVER;
126-
static final int DEFAULT_MAX_CONNECTIONS_PER_DESTINATION = 20;
127-
static final int DEFAULT_CONNECTION_IDLE_TIMEOUT = 1000000;
128-
static final int DEFAULT_CONNECTION_CLOSE_WAIT = 30_000;
129-
130-
@Override
131-
public Connector getConnector(Client client, Configuration config) {
132-
return new JdkConnector(client, config);
122+
/**
123+
* Default value for the {@link org.glassfish.jersey.client.ClientProperties#CHUNKED_ENCODING_SIZE} property.
124+
*/
125+
public static final int DEFAULT_HTTP_CHUNK_SIZE = 4096;
126+
127+
/**
128+
* Default value for the {@link #MAX_HEADER_SIZE} property.
129+
*/
130+
public static final int DEFAULT_MAX_HEADER_SIZE = 8192;
131+
132+
/**
133+
* Default value for the {@link #MAX_REDIRECTS} property.
134+
*/
135+
public static final int DEFAULT_MAX_REDIRECTS = 5;
136+
137+
/**
138+
* Default value for the {@link #COOKIE_POLICY} property.
139+
*/
140+
public static final CookiePolicy DEFAULT_COOKIE_POLICY = CookiePolicy.ACCEPT_ORIGINAL_SERVER;
141+
142+
/**
143+
* Default value for the {@link #MAX_CONNECTIONS_PER_DESTINATION} property.
144+
*/
145+
public static final int DEFAULT_MAX_CONNECTIONS_PER_DESTINATION = 20;
146+
147+
/**
148+
* Default value for the {@link #CONNECTION_IDLE_TIMEOUT} property.
149+
*/
150+
public static final int DEFAULT_CONNECTION_IDLE_TIMEOUT = 1000000;
151+
152+
/**
153+
* Default value for the {@link #CONTAINER_IDLE_TIMEOUT} property.
154+
*/
155+
public static final int DEFAULT_CONNECTION_CLOSE_WAIT = 30_000;
156+
157+
public static <T> T getValue(final Map<String, ?> properties, final String key, final Class<T> type) {
158+
return PropertiesHelper.getValue(properties, key, type, null);
159+
}
160+
161+
public static <T> T getValue(final Map<String, ?> properties, final String key, T defaultValue, final Class<T> type) {
162+
return PropertiesHelper.getValue(properties, key, defaultValue, type, null);
163+
}
164+
165+
/**
166+
* Prevents instantiation.
167+
*/
168+
private JdkConnectorProperties() {
169+
throw new AssertionError("No instances allowed.");
133170
}
134171
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
12+
* or packager/legal/LICENSE.txt. See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at packager/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* Oracle designates this particular file as subject to the "Classpath"
20+
* exception as provided by Oracle in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*/
40+
41+
package org.glassfish.jersey.jdk.connector;
42+
43+
import javax.ws.rs.client.Client;
44+
import javax.ws.rs.core.Configuration;
45+
46+
import org.glassfish.jersey.client.spi.Connector;
47+
import org.glassfish.jersey.client.spi.ConnectorProvider;
48+
import org.glassfish.jersey.jdk.connector.internal.JdkConnector;
49+
50+
/**
51+
* @author Petr Janouch (petr.janouch at oracle.com)
52+
*/
53+
public class JdkConnectorProvider implements ConnectorProvider {
54+
@Override
55+
public Connector getConnector(Client client, Configuration config) {
56+
return new JdkConnector(client, config);
57+
}
58+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -38,7 +38,7 @@
3838
* holder.
3939
*/
4040

41-
package org.glassfish.jersey.jdk.connector;
41+
package org.glassfish.jersey.jdk.connector.internal;
4242

4343
import java.io.IOException;
4444
import java.nio.ByteBuffer;

incubator/jdk-connector/src/main/java/org/glassfish/jersey/jdk/connector/BodyInputStream.java renamed to connectors/jdk-connector/src/main/java/org/glassfish/jersey/jdk/connector/internal/BodyInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -37,7 +37,7 @@
3737
* only if the new code is made subject to such option by the copyright
3838
* holder.
3939
*/
40-
package org.glassfish.jersey.jdk.connector;
40+
package org.glassfish.jersey.jdk.connector.internal;
4141

4242
import org.glassfish.jersey.internal.util.collection.NonBlockingInputStream;
4343

incubator/jdk-connector/src/main/java/org/glassfish/jersey/jdk/connector/BodyOutputStream.java renamed to connectors/jdk-connector/src/main/java/org/glassfish/jersey/jdk/connector/internal/BodyOutputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -38,7 +38,7 @@
3838
* holder.
3939
*/
4040

41-
package org.glassfish.jersey.jdk.connector;
41+
package org.glassfish.jersey.jdk.connector.internal;
4242

4343
import java.io.OutputStream;
4444

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -38,7 +38,7 @@
3838
* holder.
3939
*/
4040

41-
package org.glassfish.jersey.jdk.connector;
41+
package org.glassfish.jersey.jdk.connector.internal;
4242

4343
import java.io.ByteArrayOutputStream;
4444
import java.io.IOException;
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -38,13 +38,14 @@
3838
* holder.
3939
*/
4040

41-
package org.glassfish.jersey.jdk.connector;
41+
package org.glassfish.jersey.jdk.connector.internal;
4242

4343
import java.io.IOException;
4444
import java.nio.ByteBuffer;
4545
import java.util.concurrent.CountDownLatch;
4646
import java.util.concurrent.atomic.AtomicReference;
4747

48+
4849
/**
4950
* Body stream that can operate either synchronously or asynchronously. See {@link BodyOutputStream} for details.
5051
*

0 commit comments

Comments
 (0)