Skip to content

Commit

Permalink
Bring back Helidon Connector
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <[email protected]>
  • Loading branch information
jansupol committed Mar 22, 2022
1 parent b4a8f93 commit b067da0
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 16 deletions.
12 changes: 6 additions & 6 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.eclipse.ee4j</groupId>
<artifactId>project</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -63,11 +63,11 @@
<artifactId>jersey-apache-connector</artifactId>
<version>${project.version}</version>
</dependency>
<!-- <dependency-->
<!-- <groupId>org.glassfish.jersey.connectors</groupId-->
<!-- <artifactId>jersey-helidon-connector</artifactId-->
<!-- <version>${project.version}</version-->
<!-- </dependency-->
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-helidon-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-grizzly-connector</artifactId>
Expand Down
152 changes: 147 additions & 5 deletions connectors/helidon-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,19 @@
<packaging>jar</packaging>
<name>jersey-connectors-helidon</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java8.build.outputDirectory>${project.basedir}/target</java8.build.outputDirectory>
<java8.sourceDirectory>${project.basedir}/src/main/java8</java8.sourceDirectory>
<java17.build.outputDirectory>${project.basedir}/target17</java17.build.outputDirectory>
<java17.sourceDirectory>${project.basedir}/src/main/java17</java17.sourceDirectory>
</properties>

<dependencies>
<dependency>
<groupId>io.helidon.jersey</groupId>
<artifactId>helidon-jersey-connector</artifactId>
<version>2.2.1</version>
<version>3.0.0-M1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -67,10 +75,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -81,4 +85,142 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>HelidonExclude</id>
<activation>
<jdk>[1.8,17)</jdk>
</activation>
<build>
<directory>${java8.build.outputDirectory}</directory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${java8.sourceDirectory}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<testExcludes>
<testExclude>org/glassfish/jersey/helidon/connector/sse/*.java</testExclude>
<testExclude>org/glassfish/jersey/helidon/connector/*.java</testExclude>
</testExcludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>HelidonInclude</id>
<activation>
<jdk>[17,)</jdk>
</activation>
<build>
<directory>${java17.build.outputDirectory}</directory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${java17.sourceDirectory}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>copyJDK17FilesToMultiReleaseJar</id>
<activation>
<file>
<!-- ${java17.build.outputDirectory} does not work here -->
<exists>target17/classes/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.class</exists>
</file>
<jdk>[1.8,17)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<inherited>true</inherited>
<extensions>true</extensions>
<configuration>
<instructions>
<Multi-Release>true</Multi-Release>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>copy-jdk17-classes</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${java8.build.outputDirectory}/classes/META-INF/versions/17</outputDirectory>
<resources>
<resource>
<directory>${java17.build.outputDirectory}/classes</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-jdk17-sources</id>
<phase>package</phase>
<configuration>
<target>
<property name="sources-jar" value="${java8.build.outputDirectory}/${project.artifactId}-${project.version}-sources.jar"/>
<echo>sources-jar: ${sources-jar}</echo>
<zip destfile="${sources-jar}" update="true">
<zipfileset dir="${java17.sourceDirectory}" prefix="META-INF/versions/17"/>
</zip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022 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
Expand All @@ -15,13 +15,14 @@
*/
package org.glassfish.jersey.helidon.connector;

import io.helidon.jersey.connector.HelidonProperties;
import org.glassfish.jersey.internal.util.PropertiesClass;

import io.helidon.config.Config;
import io.helidon.webclient.WebClient;

/**
* Configuration options specific to the Client API that utilizes {@link HelidonConnectorProvider}
* Configuration options specific to the Client API that utilizes {@code HelidonConnectorProvider}.
* @since 2.31
*/
@PropertiesClass
Expand All @@ -30,5 +31,5 @@ public final class HelidonClientProperties {
/**
* A Helidon {@link Config} instance that is passed to {@link WebClient.Builder#config(Config)} if available
*/
public static final String CONFIG = io.helidon.jersey.connector.HelidonProperties.CONFIG;
public static final String CONFIG = HelidonProperties.CONFIG;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022 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
Expand Down Expand Up @@ -68,7 +68,7 @@
public class HelidonConnectorProvider extends io.helidon.jersey.connector.HelidonConnectorProvider {
@Override
public Connector getConnector(Client client, Configuration runtimeConfig) {
if (JdkVersion.getJdkVersion().getMajor() < 11) {
if (JdkVersion.getJdkVersion().getMajor() < 17) {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}
return super.getConnector(client, runtimeConfig);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2020, 2022 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.helidon.connector;

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

/**
* Configuration options specific to the Client API that utilizes {@code HelidonConnectorProvider}
* @since 2.31
*/
@PropertiesClass
public final class HelidonClientProperties {

/**
* A Helidon {@code Config} instance that is passed to {@code WebClient.Builder#config(Config)} if available.
*/
public static final String CONFIG = "jersey.connector.helidon.config";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2022 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.helidon.connector;

import org.glassfish.jersey.client.spi.Connector;
import org.glassfish.jersey.client.spi.ConnectorProvider;
import org.glassfish.jersey.internal.util.JdkVersion;

import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.core.Configuration;
import java.io.OutputStream;

/**
* Helidon Connector stub which only throws exception when running on JDK prior to 17.
* New Helidon 3 does not support JDKs prior to 17.
*
* @since 3.0.5
*/
public class HelidonConnectorProvider implements ConnectorProvider {
@Override
public Connector getConnector(Client client, Configuration runtimeConfig) {
if (JdkVersion.getJdkVersion().getMajor() < 17) {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2022 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.helidon.connector;

import io.helidon.jersey.connector.HelidonProperties;
import org.junit.Assert;
import org.junit.Test;

public class HelidonPropertiesTest {

@Test
public void testHelidonStrings() {
String jerseyValue = HelidonClientProperties.CONFIG;
String helidonConfig = HelidonProperties.CONFIG;
Assert.assertEquals(jerseyValue, helidonConfig);
}
}
1 change: 1 addition & 0 deletions connectors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<modules>
<module>apache-connector</module>
<module>grizzly-connector</module>
<module>helidon-connector</module>
<module>jdk-connector</module>
<module>jetty-connector</module>
<module>netty-connector</module>
Expand Down

0 comments on commit b067da0

Please sign in to comment.