From 3a3cbb2d3d98dfc06ab16e720dea27163cc0fc75 Mon Sep 17 00:00:00 2001 From: jansupol Date: Tue, 19 Dec 2023 21:28:13 +0100 Subject: [PATCH] Support JDK 7 Signed-off-by: jansupol --- .../glassfish/tyrus/client/ClientManager.java | 39 ++++++++++++++----- .../tyrus/core/AnnotatedEndpoint.java | 6 +-- .../core/TyrusServerEndpointConfigurator.java | 10 ++++- ext/client-java8/pom.xml | 9 ++++- pom.xml | 6 ++- tests/release-test/pom.xml | 7 ++++ tests/tools/pom.xml | 9 ++++- 7 files changed, 68 insertions(+), 18 deletions(-) diff --git a/client/src/main/java/org/glassfish/tyrus/client/ClientManager.java b/client/src/main/java/org/glassfish/tyrus/client/ClientManager.java index 6469f742..987722da 100755 --- a/client/src/main/java/org/glassfish/tyrus/client/ClientManager.java +++ b/client/src/main/java/org/glassfish/tyrus/client/ClientManager.java @@ -290,31 +290,52 @@ public boolean evaluate() { } @Override - public Session connectToServer(Class annotatedEndpointClass, URI path) throws DeploymentException, IOException { + public Session connectToServer(final Class annotatedEndpointClass, final URI path) throws DeploymentException, IOException { if (annotatedEndpointClass.getAnnotation(ClientEndpoint.class) == null) { throw new DeploymentException( String.format( "Class argument in connectToServer(Class, URI) is to be annotated endpoint class. Class " + "%s does not have @ClientEndpoint", annotatedEndpointClass.getName())); } - return tryCatchInterruptedExecutionEx(() -> connectToServer(annotatedEndpointClass, null, path.toString(), true)); + return tryCatchInterruptedExecutionEx(new SupplierWithEx, DeploymentException>() { + @Override + public Future get() throws DeploymentException { + return connectToServer(annotatedEndpointClass, null, path.toString(), true); + } + }); } @Override - public Session connectToServer(Class endpointClass, ClientEndpointConfig cec, URI path) throws - DeploymentException, IOException { - return tryCatchInterruptedExecutionEx(() -> connectToServer(endpointClass, cec, path.toString(), true)); + public Session connectToServer(final Class endpointClass, + final ClientEndpointConfig cec, + final URI path) throws DeploymentException, IOException { + return tryCatchInterruptedExecutionEx(new SupplierWithEx, DeploymentException>() { + @Override + public Future get() throws DeploymentException { + return connectToServer(endpointClass, cec, path.toString(), true); + } + }); } @Override - public Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws + public Session connectToServer(final Endpoint endpointInstance, final ClientEndpointConfig cec, final URI path) throws DeploymentException, IOException { - return tryCatchInterruptedExecutionEx(() -> connectToServer(endpointInstance, cec, path.toString(), true)); + return tryCatchInterruptedExecutionEx(new SupplierWithEx, DeploymentException>() { + @Override + public Future get() throws DeploymentException { + return connectToServer(endpointInstance, cec, path.toString(), true); + } + }); } @Override - public Session connectToServer(Object obj, URI path) throws DeploymentException, IOException { - return tryCatchInterruptedExecutionEx(() -> connectToServer(obj, null, path.toString(), true)); + public Session connectToServer(final Object obj, final URI path) throws DeploymentException, IOException { + return tryCatchInterruptedExecutionEx(new SupplierWithEx, DeploymentException>() { + @Override + public Future get() throws DeploymentException { + return connectToServer(obj, null, path.toString(), true); + } + }); } private Session tryCatchInterruptedExecutionEx(SupplierWithEx, DeploymentException> supplier) diff --git a/core/src/main/java/org/glassfish/tyrus/core/AnnotatedEndpoint.java b/core/src/main/java/org/glassfish/tyrus/core/AnnotatedEndpoint.java index 8ae82b0e..caedc28b 100755 --- a/core/src/main/java/org/glassfish/tyrus/core/AnnotatedEndpoint.java +++ b/core/src/main/java/org/glassfish/tyrus/core/AnnotatedEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -94,7 +94,7 @@ public static AnnotatedEndpoint fromClass(Class annotatedClass, ComponentProv boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector, EndpointEventListener endpointEventListener) { return fromClass(annotatedClass, componentProvider, isServerEndpoint, incomingBufferSize, collector, - endpointEventListener, Collections.emptySet()); + endpointEventListener, (Set) (Set) Collections.emptySet()); } /** @@ -131,7 +131,7 @@ public static AnnotatedEndpoint fromInstance( Object annotatedInstance, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector) { return fromInstance(annotatedInstance, componentProvider, isServerEndpoint, incomingBufferSize, - collector, Collections.emptySet()); + collector, (Set) (Set) Collections.emptySet()); } /** diff --git a/core/src/main/java/org/glassfish/tyrus/core/TyrusServerEndpointConfigurator.java b/core/src/main/java/org/glassfish/tyrus/core/TyrusServerEndpointConfigurator.java index f89c1daf..7c4094a0 100644 --- a/core/src/main/java/org/glassfish/tyrus/core/TyrusServerEndpointConfigurator.java +++ b/core/src/main/java/org/glassfish/tyrus/core/TyrusServerEndpointConfigurator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -28,6 +28,7 @@ import javax.websocket.server.ServerEndpointConfig; import org.glassfish.tyrus.core.collection.LazyValue; +import org.glassfish.tyrus.core.collection.Value; import org.glassfish.tyrus.core.collection.Values; import org.glassfish.tyrus.core.extension.ExtendedExtension; import org.glassfish.tyrus.core.frame.Frame; @@ -42,7 +43,12 @@ public class TyrusServerEndpointConfigurator extends ServerEndpointConfig.Config private LazyValue componentProviderService; public TyrusServerEndpointConfigurator() { - this.componentProviderService = Values.lazy(() -> ComponentProviderService.create()); + this.componentProviderService = Values.lazy(new Value() { + @Override + public ComponentProviderService get() { + return ComponentProviderService.create(); + } + }); } @Override diff --git a/ext/client-java8/pom.xml b/ext/client-java8/pom.xml index dc4e42cc..72379a4f 100644 --- a/ext/client-java8/pom.xml +++ b/ext/client-java8/pom.xml @@ -1,6 +1,6 @@