diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketServerComponents.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketServerComponents.java index c8717bacb16..c5c8bf77a6c 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketServerComponents.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketServerComponents.java @@ -40,9 +40,9 @@ public class WebSocketServerComponents extends WebSocketComponents public static final String WEBSOCKET_DEFLATER_POOL_ATTRIBUTE = "jetty.websocket.deflater"; public static final String WEBSOCKET_BUFFER_POOL_ATTRIBUTE = "jetty.websocket.bufferPool"; - WebSocketServerComponents(InflaterPool inflaterPool, DeflaterPool deflaterPool, ByteBufferPool bufferPool) + WebSocketServerComponents(InflaterPool inflaterPool, DeflaterPool deflaterPool, ByteBufferPool bufferPool, DecoratedObjectFactory objectFactory) { - super(null, null, bufferPool, inflaterPool, deflaterPool); + super(null, objectFactory, bufferPool, inflaterPool, deflaterPool); } /** @@ -79,7 +79,10 @@ public class WebSocketServerComponents extends WebSocketComponents if (bufferPool == null) bufferPool = server.getBean(ByteBufferPool.class); - WebSocketComponents serverComponents = new WebSocketServerComponents(inflaterPool, deflaterPool, bufferPool); + DecoratedObjectFactory objectFactory = (DecoratedObjectFactory)servletContext.getAttribute(DecoratedObjectFactory.ATTR); + WebSocketComponents serverComponents = new WebSocketServerComponents(inflaterPool, deflaterPool, bufferPool, objectFactory); + if (objectFactory != null) + serverComponents.unmanage(objectFactory); // These components may be managed by the server but not yet started. // In this case we don't want them to be managed by the components as well. diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java index 21c6e28a533..8df5ed06703 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java @@ -168,6 +168,9 @@ public class JavaxWebSocketFrameHandler implements FrameHandler binaryMetadata = actualBinaryMetadata; } + // Decorate the endpointInstance directly before calling the onOpen method. + coreSession.getWebSocketComponents().getObjectFactory().decorate(endpointInstance); + if (openHandle != null) openHandle.invoke(); diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java index d3235ad0ed7..db9f34bb039 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java @@ -169,6 +169,9 @@ public class JettyWebSocketFrameHandler implements FrameHandler if (binaryHandle != null) binarySink = JettyWebSocketFrameHandlerFactory.createMessageSink(binaryHandle, binarySinkClass, executor, session); + // Decorate the endpointInstance directly before calling the onOpen method. + coreSession.getWebSocketComponents().getObjectFactory().decorate(endpointInstance); + if (openHandle != null) openHandle.invoke(); diff --git a/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/JavaxWebSocketCdiTest.java b/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/JavaxWebSocketCdiTest.java index 07565fa27dc..08fdfd0dd14 100644 --- a/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/JavaxWebSocketCdiTest.java +++ b/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/JavaxWebSocketCdiTest.java @@ -1,16 +1,11 @@ // // ======================================================================== -// Copyright (c) Webtide LLC and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://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: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. // // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 // ======================================================================== diff --git a/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/JettyWebSocketCdiTest.java b/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/JettyWebSocketCdiTest.java index 0c0b9694cb3..794950e85d5 100644 --- a/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/JettyWebSocketCdiTest.java +++ b/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/JettyWebSocketCdiTest.java @@ -1,16 +1,11 @@ // // ======================================================================== -// Copyright (c) Webtide LLC and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://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: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. // // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 // ======================================================================== diff --git a/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/LogFactory.java b/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/LogFactory.java index b201259e636..1e683c874ec 100644 --- a/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/LogFactory.java +++ b/tests/test-cdi/src/test/java/org/eclipse/jetty/cdi/tests/websocket/LogFactory.java @@ -1,16 +1,11 @@ // // ======================================================================== -// Copyright (c) Webtide LLC and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://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: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. // // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 // ========================================================================