From d216206fcd6c7f16326f91a8c2503dca8171caff Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 27 Apr 2017 13:18:14 -0700 Subject: [PATCH] Issue #207 - Adding missing JSR356 Server @PathParam ArgIdentifier --- .../test/resources/jetty-logging.properties | 1 + .../jsr356/server/PathParamArgIdentifier.java | 40 +++++++++++++++++++ ...tty.websocket.common.reflect.ArgIdentifier | 1 + .../websocket/jsr356/server/WSServer.java | 1 + .../jetty/websocket/api/util/WSURI.java | 4 -- 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/PathParamArgIdentifier.java create mode 100644 jetty-websocket/javax-websocket-server-impl/src/main/resources/META-INF/services/org.eclipse.jetty.websocket.common.reflect.ArgIdentifier diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties b/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties index 3acadb6cade..4c8d0c1f376 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties +++ b/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties @@ -3,4 +3,5 @@ org.eclipse.jetty.LEVEL=WARN # org.eclipse.jetty.websocket.LEVEL=INFO # org.eclipse.jetty.websocket.LEVEL=ALL +# org.eclipse.jetty.websocket.LEVEL=DEBUG # org.eclipse.jetty.websocket.jsr356.LEVEL=DEBUG diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/PathParamArgIdentifier.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/PathParamArgIdentifier.java new file mode 100644 index 00000000000..437ecfe01ea --- /dev/null +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/PathParamArgIdentifier.java @@ -0,0 +1,40 @@ +// +// ======================================================================== +// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.websocket.jsr356.server; + +import javax.websocket.server.PathParam; + +import org.eclipse.jetty.websocket.common.reflect.Arg; +import org.eclipse.jetty.websocket.common.reflect.ArgIdentifier; + +/** + * Method argument identifier for {@link javax.websocket.server.PathParam} annotations. + */ +@SuppressWarnings("unused") +public class PathParamArgIdentifier implements ArgIdentifier +{ + @Override + public Arg apply(Arg arg) + { + PathParam pathParam = arg.getAnnotation(PathParam.class); + if (pathParam != null) + arg.setTag(pathParam.value()); + return arg; + } +} diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/resources/META-INF/services/org.eclipse.jetty.websocket.common.reflect.ArgIdentifier b/jetty-websocket/javax-websocket-server-impl/src/main/resources/META-INF/services/org.eclipse.jetty.websocket.common.reflect.ArgIdentifier new file mode 100644 index 00000000000..15c3ac10f82 --- /dev/null +++ b/jetty-websocket/javax-websocket-server-impl/src/main/resources/META-INF/services/org.eclipse.jetty.websocket.common.reflect.ArgIdentifier @@ -0,0 +1 @@ +org.eclipse.jetty.websocket.jsr356.server.PathParamArgIdentifier \ No newline at end of file diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java index 6b9fcaf5922..ec3799f463a 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java +++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java @@ -133,6 +133,7 @@ public class WSServer { contexts.addHandler(webapp); contexts.manage(webapp); + webapp.setThrowUnavailableOnStartupException(true); webapp.start(); if (LOG.isDebugEnabled()) { diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/WSURI.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/WSURI.java index 3ccc0d628fa..5fc3404ca7f 100644 --- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/WSURI.java +++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/WSURI.java @@ -139,25 +139,21 @@ public final class WSURI { // keep as-is wsScheme = httpScheme; - port = 80; } else if ("wss".equalsIgnoreCase(httpScheme)) { // keep as-is wsScheme = httpScheme; - port = 443; } else if ("http".equalsIgnoreCase(httpScheme)) { // convert to ws wsScheme = "ws"; - port = 80; } else if ("https".equalsIgnoreCase(httpScheme)) { // convert to wss wsScheme = "wss"; - port = 443; } else {