Permalink
Browse files

Make sure server uses only single ComponentProviderService instance w…

…hen using TyrusServerEndpointConfigurator.

Change-Id: I8f2aa4868ee9949fefe322e172cc6bb692380c81
  • Loading branch information...
pavelbucek committed Aug 23, 2016
1 parent ebe0d1c commit 358ff55e4d8c411208d2084c91d6c505338a90f6
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011-2016 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -143,12 +143,26 @@ private AnnotatedEndpoint(Class<?> annotatedClass, Object instance, ComponentPro
this.annotatedInstance = instance;
this.annotatedClass = annotatedClass;
this.endpointEventListener = endpointEventListener;
this.componentProvider = isServerEndpoint ? new ComponentProviderService(componentProvider) {
@Override
public <T> Object getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
return ((ServerEndpointConfig) configuration).getConfigurator().getEndpointInstance(endpointClass);
if (isServerEndpoint) {
if (TyrusServerEndpointConfigurator.class
.equals(((ServerEndpointConfig) configuration).getConfigurator().getClass())) {
// if the platform Configurator is Tyrus provided, it doesn't need to be called to get an endpoint
// instance, since it uses ComponentProviderService anyway.
this.componentProvider = componentProvider;
} else {
// if the platform Configurator is not tyrus one, it needs to be used for instance lookups.
this.componentProvider = new ComponentProviderService(componentProvider) {
@Override
public <T> Object getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
return ((ServerEndpointConfig) configuration).getConfigurator()
.getEndpointInstance(endpointClass);
}
};
}
} : componentProvider;
} else {
this.componentProvider = componentProvider;
}
Method onOpen = null;
Method onClose = null;
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2013-2015 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013-2016 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
package org.glassfish.tyrus.server;
package org.glassfish.tyrus.core;
import java.util.ArrayList;
import java.util.List;
@@ -47,7 +47,6 @@
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import org.glassfish.tyrus.core.ComponentProviderService;
import org.glassfish.tyrus.core.extension.ExtendedExtension;
import org.glassfish.tyrus.core.frame.Frame;
@@ -90,7 +89,7 @@ public String getNegotiatedSubprotocol(List<String> supported, List<String> requ
if (name != null && name.equals(requestedExtension.getName())) {
/**
/*
* Per message compression - draft 19
* https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-19
*
@@ -0,0 +1 @@
org.glassfish.tyrus.core.TyrusServerEndpointConfigurator
@@ -1 +0,0 @@
org.glassfish.tyrus.server.TyrusServerEndpointConfigurator

0 comments on commit 358ff55

Please sign in to comment.