diff --git a/bom/pom.xml b/bom/pom.xml index f7af29caa1..d211436fbe 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -24,7 +24,7 @@ org.eclipse.ee4j project - 1.0.6 + 1.0.7 @@ -63,11 +63,11 @@ jersey-apache-connector ${project.version} - - - - - + + org.glassfish.jersey.connectors + jersey-helidon-connector + ${project.version} + org.glassfish.jersey.connectors jersey-grizzly-connector diff --git a/connectors/helidon-connector/pom.xml b/connectors/helidon-connector/pom.xml index 775535b4ec..2da4ae3b9b 100644 --- a/connectors/helidon-connector/pom.xml +++ b/connectors/helidon-connector/pom.xml @@ -30,11 +30,19 @@ jar jersey-connectors-helidon + + UTF-8 + ${project.basedir}/target + ${project.basedir}/src/main/java8 + ${project.basedir}/target17 + ${project.basedir}/src/main/java17 + + io.helidon.jersey helidon-jersey-connector - 2.2.1 + 3.0.0-M1 provided @@ -67,10 +75,6 @@ org.apache.maven.plugins maven-compiler-plugin false - - 11 - 11 - org.apache.maven.plugins @@ -81,4 +85,142 @@ + + + + HelidonExclude + + [1.8,17) + + + ${java8.build.outputDirectory} + + + org.codehaus.mojo + build-helper-maven-plugin + + + generate-sources + + add-source + + + + ${java8.sourceDirectory} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org/glassfish/jersey/helidon/connector/sse/*.java + org/glassfish/jersey/helidon/connector/*.java + + + + + + + + HelidonInclude + + [17,) + + + ${java17.build.outputDirectory} + + + org.codehaus.mojo + build-helper-maven-plugin + + + generate-sources + + add-source + + + + ${java17.sourceDirectory} + + + + + + + + + + copyJDK17FilesToMultiReleaseJar + + + + target17/classes/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.class + + [1.8,17) + + + + + org.apache.felix + maven-bundle-plugin + true + true + + + true + + + + + org.apache.maven.plugins + maven-resources-plugin + true + + + copy-jdk17-classes + prepare-package + + copy-resources + + + ${java8.build.outputDirectory}/classes/META-INF/versions/17 + + + ${java17.build.outputDirectory}/classes + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + copy-jdk17-sources + package + + + + sources-jar: ${sources-jar} + + + + + + + run + + + + + + + + diff --git a/connectors/helidon-connector/src/main/java/org/glassfish/jersey/helidon/connector/HelidonClientProperties.java b/connectors/helidon-connector/src/main/java17/org/glassfish/jersey/helidon/connector/HelidonClientProperties.java similarity index 82% rename from connectors/helidon-connector/src/main/java/org/glassfish/jersey/helidon/connector/HelidonClientProperties.java rename to connectors/helidon-connector/src/main/java17/org/glassfish/jersey/helidon/connector/HelidonClientProperties.java index 7e7c10de0c..93baa42135 100644 --- a/connectors/helidon-connector/src/main/java/org/glassfish/jersey/helidon/connector/HelidonClientProperties.java +++ b/connectors/helidon-connector/src/main/java17/org/glassfish/jersey/helidon/connector/HelidonClientProperties.java @@ -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 @@ -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 @@ -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; } diff --git a/connectors/helidon-connector/src/main/java/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.java b/connectors/helidon-connector/src/main/java17/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.java similarity index 96% rename from connectors/helidon-connector/src/main/java/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.java rename to connectors/helidon-connector/src/main/java17/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.java index 1da44f9744..aa1540a6e5 100644 --- a/connectors/helidon-connector/src/main/java/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.java +++ b/connectors/helidon-connector/src/main/java17/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.java @@ -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 @@ -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); diff --git a/connectors/helidon-connector/src/main/java8/org/glassfish/jersey/helidon/connector/HelidonClientProperties.java b/connectors/helidon-connector/src/main/java8/org/glassfish/jersey/helidon/connector/HelidonClientProperties.java new file mode 100644 index 0000000000..d1e8ee14ad --- /dev/null +++ b/connectors/helidon-connector/src/main/java8/org/glassfish/jersey/helidon/connector/HelidonClientProperties.java @@ -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"; +} diff --git a/connectors/helidon-connector/src/main/java8/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.java b/connectors/helidon-connector/src/main/java8/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.java new file mode 100644 index 0000000000..932155a058 --- /dev/null +++ b/connectors/helidon-connector/src/main/java8/org/glassfish/jersey/helidon/connector/HelidonConnectorProvider.java @@ -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; + } +} diff --git a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/HelidonPropertiesTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/HelidonPropertiesTest.java new file mode 100644 index 0000000000..a858e6732a --- /dev/null +++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/HelidonPropertiesTest.java @@ -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); + } +} diff --git a/connectors/pom.xml b/connectors/pom.xml index ba3844a075..d2face2f8d 100644 --- a/connectors/pom.xml +++ b/connectors/pom.xml @@ -36,6 +36,7 @@ apache-connector grizzly-connector + helidon-connector jdk-connector jetty-connector netty-connector