Skip to content

Commit

Permalink
Add Jetty 11.x client connector
Browse files Browse the repository at this point in the history
  • Loading branch information
zUniQueX committed Sep 2, 2023
1 parent fd44001 commit 51671a5
Show file tree
Hide file tree
Showing 33 changed files with 3,857 additions and 9 deletions.
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
<artifactId>jersey-jetty-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty11-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jdk-connector</artifactId>
Expand Down
140 changes: 140 additions & 0 deletions connectors/jetty11-connector/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>project</artifactId>
<version>3.1.99-SNAPSHOT</version>
</parent>

<artifactId>jersey-jetty11-connector</artifactId>
<packaging>jar</packaging>
<name>jersey-connectors-jetty11</name>

<description>Jersey Client Transport via Jetty 11.x</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${jetty11.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty11.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-osgi</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.sun.istack</groupId>
<artifactId>istack-commons-maven-plugin</artifactId>
<inherited>true</inherited>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<inherited>true</inherited>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<instructions>
<Import-Package>
${jetty.osgi.version},
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty11.connector;

import java.util.Map;

import org.glassfish.jersey.internal.util.PropertiesClass;
import org.glassfish.jersey.internal.util.PropertiesHelper;

/**
* Configuration options specific to the Client API that utilizes {@link Jetty11ConnectorProvider}.
*
* @author Arul Dhesiaseelan (aruld at acm.org)
*/
@PropertiesClass
public final class Jetty11ClientProperties {

/**
* Prevents instantiation.
*/
private Jetty11ClientProperties() {
throw new AssertionError("No instances allowed.");
}

/**
* A value of {@code false} indicates the client should handle cookies
* automatically using HttpClient's default cookie policy. A value
* of {@code false} will cause the client to ignore all cookies.
* <p/>
* The value MUST be an instance of {@link Boolean}.
* If the property is absent the default value is {@code false}
*/
public static final String DISABLE_COOKIES =
"jersey.config.jetty11.client.disableCookies";

/**
* The credential provider that should be used to retrieve
* credentials from a user.
*
* If an {@link org.eclipse.jetty.client.api.Authentication} mechanism is found,
* it is then used for the given request, returning an {@link org.eclipse.jetty.client.api.Authentication.Result},
* which is then stored in the {@link org.eclipse.jetty.client.api.AuthenticationStore}
* so that subsequent requests can be preemptively authenticated.
* <p/>
* The value MUST be an instance of {@link
* org.eclipse.jetty.client.util.BasicAuthentication}. If
* the property is absent a default provider will be used.
*/
public static final String PREEMPTIVE_BASIC_AUTHENTICATION =
"jersey.config.jetty11.client.preemptiveBasicAuthentication";

/**
* A value of {@code false} indicates the client disable a hostname verification
* during SSL Handshake. A client will ignore CN value defined in a certificate
* that is stored in a truststore.
* <p/>
* The value MUST be an instance of {@link Boolean}.
* If the property is absent the default value is {@code true}.
*/
public static final String ENABLE_SSL_HOSTNAME_VERIFICATION =
"jersey.config.jetty11.client.enableSslHostnameVerification";

/**
* Overrides the default Jetty synchronous listener response max buffer size.
* In practise, this allows you to read larger responses.
* Size in bytes.
* <p/>
* If the property is absent, the value is such as specified by Jetty (currently 2MiB).
*/
public static final String SYNC_LISTENER_RESPONSE_MAX_SIZE =
"jersey.config.jetty11.client.syncListenerResponseMaxSize";

/**
* Total timeout interval for request/response conversation, in milliseconds.
* Opposed to {@link org.glassfish.jersey.client.ClientProperties#READ_TIMEOUT}.
* <p>
* The value MUST be an instance convertible to {@link Integer}. The
* value of zero (0) is equivalent to an interval of infinity.
* </p>
* <p>
* The default value is zero (infinity).
* </p>
* <p>
* The name of the configuration property is <tt>{@value}</tt>.
* </p>
*
* @since 2.37
*/
public static final String TOTAL_TIMEOUT = "jersey.config.jetty11.client.totalTimeout";

/**
* Get the value of the specified property.
*
* If the property is not set or the real value type is not compatible with the specified value type, returns {@code null}.
*
* @param properties Map of properties to get the property value from.
* @param key Name of the property.
* @param type Type to retrieve the value as.
* @param <T> Type of the property value.
* @return Value of the property or {@code null}.
*
* @since 2.8
*/
public static <T> T getValue(final Map<String, ?> properties, final String key, final Class<T> type) {
return PropertiesHelper.getValue(properties, key, type, null);
}

}
Loading

0 comments on commit 51671a5

Please sign in to comment.