Rename EnhancedInstantiator to DecoratedObjectFactory
This commit is contained in:
parent
c65e6aaab7
commit
0c930c8640
|
@ -60,7 +60,7 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
|
|||
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
import org.eclipse.jetty.servlet.BaseHolder.Source;
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
|
@ -88,7 +88,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
|
||||
public interface ServletContainerInitializerCaller extends LifeCycle {};
|
||||
|
||||
protected final EnhancedInstantiator _instantiator= new EnhancedInstantiator();
|
||||
protected final DecoratedObjectFactory _instantiator= new DecoratedObjectFactory();
|
||||
protected Class<? extends SecurityHandler> _defaultSecurityHandlerClass=org.eclipse.jetty.security.ConstraintSecurityHandler.class;
|
||||
protected SessionHandler _sessionHandler;
|
||||
protected SecurityHandler _securityHandler;
|
||||
|
@ -252,7 +252,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
setAttribute(EnhancedInstantiator.ATTR, _instantiator);
|
||||
setAttribute(DecoratedObjectFactory.ATTR, _instantiator);
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
|
@ -651,7 +651,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The decorator list used to resource inject new Filters, Servlets and EventListeners
|
||||
* @deprecated use getAttribute("org.eclipse.jetty.util.EnhancedInstantiator") instead
|
||||
* @deprecated use getAttribute("org.eclipse.jetty.util.DecoratedObjectFactory") instead
|
||||
*/
|
||||
@Deprecated
|
||||
public List<Decorator> getDecorators()
|
||||
|
|
|
@ -27,50 +27,21 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* An instantiator enhanced by {@link Decorator} instances.
|
||||
* An ObjectFactory enhanced by {@link Decorator} instances.
|
||||
* <p>
|
||||
* Consistent single location for all Decorator behavior, with equal behavior in a ServletContext and also for a stand
|
||||
* alone client.
|
||||
* <p>
|
||||
* Used by WebAppContext, WebSocketServerFactory, or WebSocketClient.
|
||||
*/
|
||||
public class EnhancedInstantiator implements Iterable<Decorator>
|
||||
public class DecoratedObjectFactory implements Iterable<Decorator>
|
||||
{
|
||||
private static final ThreadLocal<EnhancedInstantiator> CURRENT_INSTANTIATOR = new ThreadLocal<>();
|
||||
private static final Logger LOG = Log.getLogger(DecoratedObjectFactory.class);
|
||||
|
||||
/**
|
||||
* Get the current EnhancedInstantiator that this thread is dispatched to.
|
||||
* <p>
|
||||
* This exists because of various {@link java.util.ServiceLoader} use that makes passing in an EnhancedInstantiator
|
||||
* difficult.
|
||||
*
|
||||
* @return the current EnhancedInstantiator or null
|
||||
* ServletContext attribute for the active DecoratedObjectFactory
|
||||
*/
|
||||
public static EnhancedInstantiator getCurrentInstantiator()
|
||||
{
|
||||
return CURRENT_INSTANTIATOR.get();
|
||||
}
|
||||
|
||||
public static EnhancedInstantiator setCurrentInstantiator(EnhancedInstantiator instantiator)
|
||||
{
|
||||
EnhancedInstantiator last = CURRENT_INSTANTIATOR.get();
|
||||
if (instantiator == null)
|
||||
{
|
||||
CURRENT_INSTANTIATOR.remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
CURRENT_INSTANTIATOR.set(instantiator);
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
private static final Logger LOG = Log.getLogger(EnhancedInstantiator.class);
|
||||
|
||||
/**
|
||||
* ServletContext attribute for the active EnhancedInstantiator
|
||||
*/
|
||||
public static final String ATTR = EnhancedInstantiator.class.getName();
|
||||
public static final String ATTR = DecoratedObjectFactory.class.getName();
|
||||
|
||||
private List<Decorator> decorators = new ArrayList<>();
|
||||
|
|
@ -40,7 +40,7 @@ import javax.websocket.Extension;
|
|||
import javax.websocket.Session;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -85,21 +85,21 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
|
|||
/** The jetty websocket client in use for this container */
|
||||
private WebSocketClient client;
|
||||
|
||||
protected EnhancedInstantiator enhancedInstantiator;
|
||||
protected DecoratedObjectFactory objectFactory;
|
||||
|
||||
public ClientContainer()
|
||||
{
|
||||
// This constructor is used with Standalone JSR Client usage.
|
||||
this(null,new EnhancedInstantiator());
|
||||
this(null,new DecoratedObjectFactory());
|
||||
client.setDaemon(true);
|
||||
}
|
||||
|
||||
public ClientContainer(Executor executor, EnhancedInstantiator enhancedInstantiator)
|
||||
public ClientContainer(Executor executor, DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
this.enhancedInstantiator = enhancedInstantiator;
|
||||
this.objectFactory = objectFactory;
|
||||
this.endpointClientMetadataCache = new ConcurrentHashMap<>();
|
||||
this.decoderFactory = new DecoderFactory(PrimitiveDecoderMetadataSet.INSTANCE,null,enhancedInstantiator);
|
||||
this.encoderFactory = new EncoderFactory(PrimitiveEncoderMetadataSet.INSTANCE,null,enhancedInstantiator);
|
||||
this.decoderFactory = new DecoderFactory(PrimitiveDecoderMetadataSet.INSTANCE,null,objectFactory);
|
||||
this.encoderFactory = new EncoderFactory(PrimitiveEncoderMetadataSet.INSTANCE,null,objectFactory);
|
||||
|
||||
EmptyClientEndpointConfig empty = new EmptyClientEndpointConfig();
|
||||
this.decoderFactory.init(empty);
|
||||
|
@ -110,7 +110,7 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
|
|||
client = new WebSocketClient(new SslContextFactory(trustAll), executor);
|
||||
client.setEventDriverFactory(new JsrEventDriverFactory(client.getPolicy()));
|
||||
SessionFactory sessionFactory = new JsrSessionFactory(this,this,client);
|
||||
sessionFactory.setEnhancedInstantiator(enhancedInstantiator);
|
||||
sessionFactory.setEnhancedInstantiator(objectFactory);
|
||||
client.setSessionFactory(sessionFactory);
|
||||
addBean(client);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import javax.websocket.Decoder;
|
||||
import javax.websocket.EndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata;
|
||||
|
@ -74,23 +74,23 @@ public class DecoderFactory implements Configurable
|
|||
private static final Logger LOG = Log.getLogger(DecoderFactory.class);
|
||||
|
||||
private final DecoderMetadataSet metadatas;
|
||||
private final EnhancedInstantiator enhancedInstantiator;
|
||||
private final DecoratedObjectFactory objectFactory;
|
||||
private DecoderFactory parentFactory;
|
||||
private Map<Class<?>, Wrapper> activeWrappers;
|
||||
|
||||
public DecoderFactory(DecoderMetadataSet metadatas)
|
||||
{
|
||||
this(metadatas, null, new EnhancedInstantiator());
|
||||
this(metadatas, null, new DecoratedObjectFactory());
|
||||
}
|
||||
|
||||
public DecoderFactory(DecoderMetadataSet metadatas, DecoderFactory parentFactory, EnhancedInstantiator enhancedInstantiator)
|
||||
public DecoderFactory(DecoderMetadataSet metadatas, DecoderFactory parentFactory, DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
this.metadatas = metadatas;
|
||||
this.activeWrappers = new ConcurrentHashMap<>();
|
||||
this.parentFactory = parentFactory;
|
||||
|
||||
Objects.requireNonNull(enhancedInstantiator,"EnhancedInitiator cannot be null");
|
||||
this.enhancedInstantiator = enhancedInstantiator;
|
||||
Objects.requireNonNull(objectFactory,"EnhancedInitiator cannot be null");
|
||||
this.objectFactory = objectFactory;
|
||||
}
|
||||
|
||||
public Decoder getDecoderFor(Class<?> type)
|
||||
|
@ -179,7 +179,7 @@ public class DecoderFactory implements Configurable
|
|||
Class<? extends Decoder> decoderClass = metadata.getCoderClass();
|
||||
try
|
||||
{
|
||||
Decoder decoder = enhancedInstantiator.createInstance(decoderClass);
|
||||
Decoder decoder = objectFactory.createInstance(decoderClass);
|
||||
return new Wrapper(decoder,metadata);
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException e)
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import javax.websocket.Encoder;
|
||||
import javax.websocket.EndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.jsr356.metadata.EncoderMetadata;
|
||||
|
@ -67,23 +67,23 @@ public class EncoderFactory implements Configurable
|
|||
private static final Logger LOG = Log.getLogger(EncoderFactory.class);
|
||||
|
||||
private final EncoderMetadataSet metadatas;
|
||||
private final EnhancedInstantiator enhancedInstantiator;
|
||||
private final DecoratedObjectFactory objectFactory;
|
||||
private EncoderFactory parentFactory;
|
||||
private Map<Class<?>, Wrapper> activeWrappers;
|
||||
|
||||
public EncoderFactory(EncoderMetadataSet metadatas)
|
||||
{
|
||||
this(metadatas,null,new EnhancedInstantiator());
|
||||
this(metadatas,null,new DecoratedObjectFactory());
|
||||
}
|
||||
|
||||
public EncoderFactory(EncoderMetadataSet metadatas, EncoderFactory parentFactory, EnhancedInstantiator enhancedInstantiator)
|
||||
public EncoderFactory(EncoderMetadataSet metadatas, EncoderFactory parentFactory, DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
this.metadatas = metadatas;
|
||||
this.activeWrappers = new ConcurrentHashMap<>();
|
||||
this.parentFactory = parentFactory;
|
||||
|
||||
Objects.requireNonNull(enhancedInstantiator,"EnhancedInitiator cannot be null");
|
||||
this.enhancedInstantiator = enhancedInstantiator;
|
||||
Objects.requireNonNull(objectFactory,"EnhancedInitiator cannot be null");
|
||||
this.objectFactory = objectFactory;
|
||||
}
|
||||
|
||||
public Encoder getEncoderFor(Class<?> type)
|
||||
|
@ -173,7 +173,7 @@ public class EncoderFactory implements Configurable
|
|||
Class<? extends Encoder> encoderClass = metadata.getCoderClass();
|
||||
try
|
||||
{
|
||||
Encoder encoder = enhancedInstantiator.createInstance(encoderClass);
|
||||
Encoder encoder = objectFactory.createInstance(encoderClass);
|
||||
return new Wrapper(encoder,metadata);
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException e)
|
||||
|
|
|
@ -39,7 +39,7 @@ import javax.websocket.RemoteEndpoint.Basic;
|
|||
import javax.websocket.Session;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.BatchMode;
|
||||
|
@ -75,7 +75,7 @@ public class JsrSession extends WebSocketSession implements javax.websocket.Sess
|
|||
private JsrAsyncRemote asyncRemote;
|
||||
private JsrBasicRemote basicRemote;
|
||||
|
||||
public JsrSession(URI requestURI, EventDriver websocket, LogicalConnection connection, ClientContainer container, String id, EnhancedInstantiator enhancedInstantiator, SessionListener... sessionListeners)
|
||||
public JsrSession(URI requestURI, EventDriver websocket, LogicalConnection connection, ClientContainer container, String id, DecoratedObjectFactory objectFactory, SessionListener... sessionListeners)
|
||||
{
|
||||
super(requestURI, websocket, connection, sessionListeners);
|
||||
if (!(websocket instanceof AbstractJsrEventDriver))
|
||||
|
@ -87,8 +87,8 @@ public class JsrSession extends WebSocketSession implements javax.websocket.Sess
|
|||
this.metadata = jsr.getMetadata();
|
||||
this.container = container;
|
||||
this.id = id;
|
||||
this.decoderFactory = new DecoderFactory(metadata.getDecoders(),container.getDecoderFactory(),enhancedInstantiator);
|
||||
this.encoderFactory = new EncoderFactory(metadata.getEncoders(),container.getEncoderFactory(),enhancedInstantiator);
|
||||
this.decoderFactory = new DecoderFactory(metadata.getDecoders(),container.getDecoderFactory(),objectFactory);
|
||||
this.encoderFactory = new EncoderFactory(metadata.getEncoders(),container.getEncoderFactory(),objectFactory);
|
||||
this.messageHandlerFactory = new MessageHandlerFactory();
|
||||
this.wrappers = new MessageHandlerWrapper[MessageType.values().length];
|
||||
this.messageHandlerSet = new HashSet<>();
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.eclipse.jetty.websocket.jsr356;
|
|||
import java.net.URI;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.common.LogicalConnection;
|
||||
import org.eclipse.jetty.websocket.common.SessionFactory;
|
||||
import org.eclipse.jetty.websocket.common.SessionListener;
|
||||
|
@ -32,7 +32,7 @@ import org.eclipse.jetty.websocket.jsr356.endpoints.AbstractJsrEventDriver;
|
|||
public class JsrSessionFactory implements SessionFactory
|
||||
{
|
||||
private AtomicLong idgen = new AtomicLong(0);
|
||||
private EnhancedInstantiator enhancedInstantiator;
|
||||
private DecoratedObjectFactory objectFactory;
|
||||
private final ClientContainer container;
|
||||
private final SessionListener[] listeners;
|
||||
|
||||
|
@ -40,13 +40,13 @@ public class JsrSessionFactory implements SessionFactory
|
|||
{
|
||||
this.container = container;
|
||||
this.listeners = sessionListeners;
|
||||
this.enhancedInstantiator = new EnhancedInstantiator();
|
||||
this.objectFactory = new DecoratedObjectFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketSession createSession(URI requestURI, EventDriver websocket, LogicalConnection connection)
|
||||
{
|
||||
return new JsrSession(requestURI,websocket,connection,container,getNextId(),enhancedInstantiator,listeners);
|
||||
return new JsrSession(requestURI,websocket,connection,container,getNextId(),objectFactory,listeners);
|
||||
}
|
||||
|
||||
public String getNextId()
|
||||
|
@ -61,8 +61,8 @@ public class JsrSessionFactory implements SessionFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setEnhancedInstantiator(EnhancedInstantiator enhancedInstantiator)
|
||||
public void setEnhancedInstantiator(DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
this.enhancedInstantiator = enhancedInstantiator;
|
||||
this.objectFactory = objectFactory;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Date;
|
|||
|
||||
import javax.websocket.Decoder;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.jsr356.decoders.ByteArrayDecoder;
|
||||
import org.eclipse.jetty.websocket.jsr356.decoders.ByteBufferDecoder;
|
||||
import org.eclipse.jetty.websocket.jsr356.decoders.DateDecoder;
|
||||
|
@ -59,7 +59,7 @@ public class DecoderFactoryTest
|
|||
{
|
||||
DecoderFactory primitivesFactory = new DecoderFactory(PrimitiveDecoderMetadataSet.INSTANCE);
|
||||
metadatas = new DecoderMetadataSet();
|
||||
factory = new DecoderFactory(metadatas,primitivesFactory,new EnhancedInstantiator());
|
||||
factory = new DecoderFactory(metadatas,primitivesFactory,new DecoratedObjectFactory());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.hamcrest.Matchers.*;
|
|||
|
||||
import javax.websocket.Encoder;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.jsr356.encoders.IntegerEncoder;
|
||||
import org.eclipse.jetty.websocket.jsr356.encoders.LongEncoder;
|
||||
import org.eclipse.jetty.websocket.jsr356.encoders.PrimitiveEncoderMetadataSet;
|
||||
|
@ -56,7 +56,7 @@ public class EncoderFactoryTest
|
|||
{
|
||||
EncoderFactory primitivesFactory = new EncoderFactory(PrimitiveEncoderMetadataSet.INSTANCE);
|
||||
metadatas = new EncoderMetadataSet();
|
||||
factory = new EncoderFactory(metadatas,primitivesFactory,new EnhancedInstantiator());
|
||||
factory = new EncoderFactory(metadatas,primitivesFactory,new DecoratedObjectFactory());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,7 +25,7 @@ import javax.websocket.ClientEndpointConfig;
|
|||
import javax.websocket.DeploymentException;
|
||||
import javax.websocket.MessageHandler;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.common.events.EventDriver;
|
||||
import org.eclipse.jetty.websocket.jsr356.client.EmptyClientEndpointConfig;
|
||||
|
@ -65,7 +65,7 @@ public class JsrSessionTest
|
|||
|
||||
EventDriver driver = new JsrEndpointEventDriver(policy,ei);
|
||||
DummyConnection connection = new DummyConnection();
|
||||
session = new JsrSession(requestURI,driver,connection,container,id, new EnhancedInstantiator());
|
||||
session = new JsrSession(requestURI,driver,connection,container,id, new DecoratedObjectFactory());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
|
||||
import javax.websocket.DeploymentException;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.jsr356.decoders.PrimitiveDecoderMetadataSet;
|
||||
import org.eclipse.jetty.websocket.jsr356.handlers.ByteArrayPartialHandler;
|
||||
import org.eclipse.jetty.websocket.jsr356.handlers.StringPartialHandler;
|
||||
|
@ -47,7 +47,7 @@ public class MessageHandlerFactoryTest
|
|||
{
|
||||
DecoderFactory primitivesFactory = new DecoderFactory(PrimitiveDecoderMetadataSet.INSTANCE);
|
||||
metadatas = new DecoderMetadataSet();
|
||||
decoders = new DecoderFactory(metadatas,primitivesFactory,new EnhancedInstantiator());
|
||||
decoders = new DecoderFactory(metadatas,primitivesFactory,new DecoratedObjectFactory());
|
||||
factory = new MessageHandlerFactory();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import javax.websocket.Extension;
|
|||
import javax.websocket.server.ServerEndpoint;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
|
||||
public class AnnotatedServerEndpointConfig implements ServerEndpointConfig
|
||||
{
|
||||
|
@ -46,12 +46,12 @@ public class AnnotatedServerEndpointConfig implements ServerEndpointConfig
|
|||
private Map<String, Object> userProperties;
|
||||
private List<Extension> extensions;
|
||||
|
||||
public AnnotatedServerEndpointConfig(Class<?> endpointClass, ServerEndpoint anno, EnhancedInstantiator enhancedInstantiator) throws DeploymentException
|
||||
public AnnotatedServerEndpointConfig(Class<?> endpointClass, ServerEndpoint anno, DecoratedObjectFactory objectFactory) throws DeploymentException
|
||||
{
|
||||
this(endpointClass,anno,enhancedInstantiator,null);
|
||||
this(endpointClass,anno,objectFactory,null);
|
||||
}
|
||||
|
||||
public AnnotatedServerEndpointConfig(Class<?> endpointClass, ServerEndpoint anno, EnhancedInstantiator enhancedInstantiator, ServerEndpointConfig baseConfig) throws DeploymentException
|
||||
public AnnotatedServerEndpointConfig(Class<?> endpointClass, ServerEndpoint anno, DecoratedObjectFactory objectFactory, ServerEndpointConfig baseConfig) throws DeploymentException
|
||||
{
|
||||
ServerEndpointConfig.Configurator configr = null;
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class AnnotatedServerEndpointConfig implements ServerEndpointConfig
|
|||
}
|
||||
else
|
||||
{
|
||||
this.configurator = new BasicServerEndpointConfigurator(enhancedInstantiator);
|
||||
this.configurator = new BasicServerEndpointConfigurator(objectFactory);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -24,7 +24,7 @@ import javax.websocket.DeploymentException;
|
|||
import javax.websocket.server.ServerEndpoint;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointMetadata;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.IJsrParamId;
|
||||
|
@ -34,7 +34,7 @@ public class AnnotatedServerEndpointMetadata extends AnnotatedEndpointMetadata<S
|
|||
private final ServerEndpoint endpoint;
|
||||
private final AnnotatedServerEndpointConfig config;
|
||||
|
||||
protected AnnotatedServerEndpointMetadata(Class<?> websocket, ServerEndpointConfig baseConfig, EnhancedInstantiator enhancedInstantiator) throws DeploymentException
|
||||
protected AnnotatedServerEndpointMetadata(Class<?> websocket, ServerEndpointConfig baseConfig, DecoratedObjectFactory objectFactory) throws DeploymentException
|
||||
{
|
||||
super(websocket);
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class AnnotatedServerEndpointMetadata extends AnnotatedEndpointMetadata<S
|
|||
}
|
||||
|
||||
this.endpoint = anno;
|
||||
this.config = new AnnotatedServerEndpointConfig(websocket,anno,enhancedInstantiator,baseConfig);
|
||||
this.config = new AnnotatedServerEndpointConfig(websocket,anno,objectFactory,baseConfig);
|
||||
|
||||
getDecoders().addAll(anno.decoders());
|
||||
getEncoders().addAll(anno.encoders());
|
||||
|
|
|
@ -28,7 +28,7 @@ import javax.websocket.Encoder;
|
|||
import javax.websocket.Extension;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
|
||||
public class BasicServerEndpointConfig implements ServerEndpointConfig
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ public class BasicServerEndpointConfig implements ServerEndpointConfig
|
|||
private final String path;
|
||||
private Map<String, Object> userProperties;
|
||||
|
||||
public BasicServerEndpointConfig(Class<?> endpointClass, String path, EnhancedInstantiator enhancedInstantiator)
|
||||
public BasicServerEndpointConfig(Class<?> endpointClass, String path, DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
this.endpointClass = endpointClass;
|
||||
this.path = path;
|
||||
|
@ -51,10 +51,10 @@ public class BasicServerEndpointConfig implements ServerEndpointConfig
|
|||
this.subprotocols = new ArrayList<>();
|
||||
this.extensions = new ArrayList<>();
|
||||
this.userProperties = new HashMap<>();
|
||||
this.configurator = new BasicServerEndpointConfigurator(enhancedInstantiator);
|
||||
this.configurator = new BasicServerEndpointConfigurator(objectFactory);
|
||||
}
|
||||
|
||||
public BasicServerEndpointConfig(ServerEndpointConfig copy, EnhancedInstantiator enhancedInstantiator)
|
||||
public BasicServerEndpointConfig(ServerEndpointConfig copy, DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
// immutable concepts
|
||||
this.endpointClass = copy.getEndpointClass();
|
||||
|
@ -70,7 +70,7 @@ public class BasicServerEndpointConfig implements ServerEndpointConfig
|
|||
}
|
||||
else
|
||||
{
|
||||
this.configurator = new BasicServerEndpointConfigurator(enhancedInstantiator);
|
||||
this.configurator = new BasicServerEndpointConfigurator(objectFactory);
|
||||
}
|
||||
|
||||
// mutable concepts
|
||||
|
|
|
@ -26,7 +26,7 @@ import javax.websocket.HandshakeResponse;
|
|||
import javax.websocket.server.HandshakeRequest;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.util.QuoteUtil;
|
||||
|
@ -35,7 +35,7 @@ public class BasicServerEndpointConfigurator extends ServerEndpointConfig.Config
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(BasicServerEndpointConfigurator.class);
|
||||
private static final String NO_SUBPROTOCOL = "";
|
||||
private final EnhancedInstantiator enhancedInstantiator;
|
||||
private final DecoratedObjectFactory objectFactory;
|
||||
|
||||
/**
|
||||
* Default Constructor required, as
|
||||
|
@ -44,13 +44,13 @@ public class BasicServerEndpointConfigurator extends ServerEndpointConfig.Config
|
|||
*/
|
||||
public BasicServerEndpointConfigurator()
|
||||
{
|
||||
this(EnhancedInstantiator.getCurrentInstantiator());
|
||||
this(DecoratedObjectFactory.getCurrentInstantiator());
|
||||
}
|
||||
|
||||
public BasicServerEndpointConfigurator(EnhancedInstantiator enhancedInstantiator)
|
||||
public BasicServerEndpointConfigurator(DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
Objects.requireNonNull(enhancedInstantiator,"EnhancedInstantiator cannot be null");
|
||||
this.enhancedInstantiator = enhancedInstantiator;
|
||||
Objects.requireNonNull(objectFactory,"DecoratedObjectFactory cannot be null");
|
||||
this.objectFactory = objectFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +69,7 @@ public class BasicServerEndpointConfigurator extends ServerEndpointConfig.Config
|
|||
|
||||
try
|
||||
{
|
||||
return enhancedInstantiator.createInstance(endpointClass);
|
||||
return objectFactory.createInstance(endpointClass);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ import javax.websocket.Extension;
|
|||
import javax.websocket.Extension.Parameter;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -47,13 +47,13 @@ public class JsrCreator implements WebSocketCreator
|
|||
private static final Logger LOG = Log.getLogger(JsrCreator.class);
|
||||
private final ServerEndpointMetadata metadata;
|
||||
private final ExtensionFactory extensionFactory;
|
||||
private final EnhancedInstantiator enhancedInstantiator;
|
||||
private final DecoratedObjectFactory objectFactory;
|
||||
|
||||
public JsrCreator(ServerEndpointMetadata metadata, ExtensionFactory extensionFactory, EnhancedInstantiator enhancedInstantiator)
|
||||
public JsrCreator(ServerEndpointMetadata metadata, ExtensionFactory extensionFactory, DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
this.metadata = metadata;
|
||||
this.extensionFactory = extensionFactory;
|
||||
this.enhancedInstantiator = enhancedInstantiator;
|
||||
this.objectFactory = objectFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,7 +67,7 @@ public class JsrCreator implements WebSocketCreator
|
|||
|
||||
// Establish a copy of the config, so that the UserProperties are unique
|
||||
// per upgrade request.
|
||||
config = new BasicServerEndpointConfig(config, enhancedInstantiator);
|
||||
config = new BasicServerEndpointConfig(config, objectFactory);
|
||||
|
||||
// Bug 444617 - Expose localAddress and remoteAddress for jsr modify handshake to use
|
||||
// This is being implemented as an optional set of userProperties so that
|
||||
|
@ -145,7 +145,7 @@ public class JsrCreator implements WebSocketCreator
|
|||
WebSocketPathSpec wspathSpec = (WebSocketPathSpec)pathSpec;
|
||||
String requestPath = req.getRequestPath();
|
||||
// Wrap the config with the path spec information
|
||||
config = new PathParamServerEndpointConfig(config,enhancedInstantiator,wspathSpec,requestPath);
|
||||
config = new PathParamServerEndpointConfig(config,objectFactory,wspathSpec,requestPath);
|
||||
}
|
||||
return new EndpointInstance(endpoint,config,metadata);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.jsr356.server.pathmap.WebSocketPathSpec;
|
||||
|
||||
/**
|
||||
|
@ -33,9 +33,9 @@ public class PathParamServerEndpointConfig extends BasicServerEndpointConfig imp
|
|||
{
|
||||
private final Map<String, String> pathParamMap;
|
||||
|
||||
public PathParamServerEndpointConfig(ServerEndpointConfig config, EnhancedInstantiator enhancedInstantiator, WebSocketPathSpec pathSpec, String requestPath)
|
||||
public PathParamServerEndpointConfig(ServerEndpointConfig config, DecoratedObjectFactory objectFactory, WebSocketPathSpec pathSpec, String requestPath)
|
||||
{
|
||||
super(config, enhancedInstantiator);
|
||||
super(config, objectFactory);
|
||||
|
||||
Map<String, String> pathMap = pathSpec.getPathParams(requestPath);
|
||||
pathParamMap = new HashMap<String, String>();
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
|
|||
}
|
||||
else
|
||||
{
|
||||
cec = new BasicServerEndpointConfig(endpoint.getClass(),path,enhancedInstantiator);
|
||||
cec = new BasicServerEndpointConfig(endpoint.getClass(),path,objectFactory);
|
||||
}
|
||||
}
|
||||
return new EndpointInstance(endpoint,cec,metadata);
|
||||
|
@ -82,7 +82,7 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
|
|||
|
||||
public void addEndpoint(ServerEndpointMetadata metadata) throws DeploymentException
|
||||
{
|
||||
JsrCreator creator = new JsrCreator(metadata,webSocketServerFactory.getExtensionFactory(),enhancedInstantiator);
|
||||
JsrCreator creator = new JsrCreator(metadata,webSocketServerFactory.getExtensionFactory(),objectFactory);
|
||||
mappedCreator.addMapping(new WebSocketPathSpec(metadata.getPath()),creator);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
|
|||
if (anno != null)
|
||||
{
|
||||
// Annotated takes precedence here
|
||||
AnnotatedServerEndpointMetadata ametadata = new AnnotatedServerEndpointMetadata(endpoint,config,enhancedInstantiator);
|
||||
AnnotatedServerEndpointMetadata ametadata = new AnnotatedServerEndpointMetadata(endpoint,config,objectFactory);
|
||||
AnnotatedEndpointScanner<ServerEndpoint, ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(ametadata);
|
||||
metadata = ametadata;
|
||||
scanner.scan();
|
||||
|
|
|
@ -33,7 +33,7 @@ import javax.websocket.server.ServerEndpointConfig;
|
|||
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -168,16 +168,16 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
|
|||
// Store a reference to the ServerContainer per javax.websocket spec 1.0 final section 6.4 Programmatic Server Deployment
|
||||
context.setAttribute(javax.websocket.server.ServerContainer.class.getName(),jettyContainer);
|
||||
|
||||
// Establish the EnhancedInstantiator thread local
|
||||
// Establish the DecoratedObjectFactory thread local
|
||||
// for various ServiceLoader initiated components to use.
|
||||
EnhancedInstantiator instantiator = (EnhancedInstantiator)context.getAttribute(EnhancedInstantiator.ATTR);
|
||||
DecoratedObjectFactory instantiator = (DecoratedObjectFactory)context.getAttribute(DecoratedObjectFactory.ATTR);
|
||||
if (instantiator == null)
|
||||
{
|
||||
LOG.info("Using WebSocket local EnhancedInstantiator - none found in ServletContext");
|
||||
instantiator = new EnhancedInstantiator();
|
||||
LOG.info("Using WebSocket local DecoratedObjectFactory - none found in ServletContext");
|
||||
instantiator = new DecoratedObjectFactory();
|
||||
}
|
||||
|
||||
EnhancedInstantiator.setCurrentInstantiator(instantiator);
|
||||
DecoratedObjectFactory.setCurrentInstantiator(instantiator);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
import javax.websocket.server.ServerEndpoint;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketFrame;
|
||||
import org.eclipse.jetty.websocket.common.events.EventDriver;
|
||||
|
@ -68,7 +68,7 @@ public class OnPartialTest
|
|||
ServerEndpoint anno = endpoint.getAnnotation(ServerEndpoint.class);
|
||||
Assert.assertThat("Endpoint: " + endpoint + " should be annotated with @ServerEndpoint",anno,notNullValue());
|
||||
|
||||
EnhancedInstantiator instantiator = new EnhancedInstantiator();
|
||||
DecoratedObjectFactory instantiator = new DecoratedObjectFactory();
|
||||
|
||||
ServerEndpointConfig config = new BasicServerEndpointConfig(endpoint,"/",instantiator);
|
||||
AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(endpoint,config,instantiator);
|
||||
|
@ -84,7 +84,7 @@ public class OnPartialTest
|
|||
DummyConnection connection = new DummyConnection();
|
||||
ClientContainer container = new ClientContainer();
|
||||
@SuppressWarnings("resource")
|
||||
JsrSession session = new JsrSession(requestURI,driver,connection,container,id, new EnhancedInstantiator());
|
||||
JsrSession session = new JsrSession(requestURI,driver,connection,container,id, new DecoratedObjectFactory());
|
||||
session.setPolicy(policy);
|
||||
session.open();
|
||||
return driver;
|
||||
|
|
|
@ -34,7 +34,7 @@ import javax.websocket.Session;
|
|||
import javax.websocket.server.ServerEndpoint;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner;
|
||||
import org.eclipse.jetty.websocket.jsr356.annotations.JsrCallable;
|
||||
import org.eclipse.jetty.websocket.jsr356.server.samples.BasicBinaryMessageByteBufferSocket;
|
||||
|
@ -183,7 +183,7 @@ public class ServerAnnotatedEndpointScanner_GoodSignaturesTest
|
|||
@Test
|
||||
public void testScan_Basic() throws Exception
|
||||
{
|
||||
AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(testcase.pojo,null,new EnhancedInstantiator());
|
||||
AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(testcase.pojo,null,new DecoratedObjectFactory());
|
||||
AnnotatedEndpointScanner<ServerEndpoint, ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(metadata);
|
||||
scanner.scan();
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import javax.websocket.OnOpen;
|
|||
import javax.websocket.server.ServerEndpoint;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
|
||||
|
@ -95,7 +95,7 @@ public class ServerAnnotatedEndpointScanner_InvalidSignaturesTest
|
|||
@Test
|
||||
public void testScan_InvalidSignature() throws DeploymentException
|
||||
{
|
||||
AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(pojo,null,new EnhancedInstantiator());
|
||||
AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(pojo,null,new DecoratedObjectFactory());
|
||||
AnnotatedEndpointScanner<ServerEndpoint,ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(metadata);
|
||||
|
||||
try
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.eclipse.jetty.websocket.common;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.common.events.EventDriver;
|
||||
|
||||
/**
|
||||
|
@ -32,5 +32,5 @@ public interface SessionFactory
|
|||
|
||||
public WebSocketSession createSession(URI requestURI, EventDriver websocket, LogicalConnection connection);
|
||||
|
||||
public void setEnhancedInstantiator(EnhancedInstantiator enhancedInstantiator);
|
||||
public void setEnhancedInstantiator(DecoratedObjectFactory objectFactory);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.eclipse.jetty.websocket.common;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.common.events.EventDriver;
|
||||
import org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver;
|
||||
import org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver;
|
||||
|
@ -50,7 +50,7 @@ public class WebSocketSessionFactory implements SessionFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setEnhancedInstantiator(EnhancedInstantiator enhancedInstantiator)
|
||||
public void setEnhancedInstantiator(DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
/* does nothing here */
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.eclipse.jetty.websocket.common.extensions;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
|
@ -31,7 +31,7 @@ public class WebSocketExtensionFactory extends ExtensionFactory
|
|||
{
|
||||
private WebSocketPolicy policy;
|
||||
private ByteBufferPool bufferPool;
|
||||
private EnhancedInstantiator enhancedInstantiator;
|
||||
private DecoratedObjectFactory objectFactory;
|
||||
|
||||
public WebSocketExtensionFactory(WebSocketPolicy policy, ByteBufferPool bufferPool)
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ public class WebSocketExtensionFactory extends ExtensionFactory
|
|||
|
||||
try
|
||||
{
|
||||
Extension ext = enhancedInstantiator.createInstance(extClass);
|
||||
Extension ext = objectFactory.createInstance(extClass);
|
||||
if (ext instanceof AbstractExtension)
|
||||
{
|
||||
AbstractExtension aext = (AbstractExtension)ext;
|
||||
|
@ -78,8 +78,8 @@ public class WebSocketExtensionFactory extends ExtensionFactory
|
|||
}
|
||||
}
|
||||
|
||||
public void setEnhancedInstantiator(EnhancedInstantiator enhancedInstantiator)
|
||||
public void setEnhancedInstantiator(DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
this.enhancedInstantiator = enhancedInstantiator;
|
||||
this.objectFactory = objectFactory;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.*;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
|
@ -57,7 +57,7 @@ public class ExtensionStackTest
|
|||
{
|
||||
WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();
|
||||
WebSocketExtensionFactory factory = new WebSocketExtensionFactory(policy,bufferPool);
|
||||
factory.setEnhancedInstantiator(new EnhancedInstantiator());
|
||||
factory.setEnhancedInstantiator(new DecoratedObjectFactory());
|
||||
return new ExtensionStack(factory);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.nio.ByteBuffer;
|
|||
import java.util.Collections;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Extension;
|
||||
|
@ -128,7 +128,7 @@ public class ExtensionTool
|
|||
{
|
||||
this.policy = policy;
|
||||
WebSocketExtensionFactory extFactory = new WebSocketExtensionFactory(policy,bufferPool);
|
||||
extFactory.setEnhancedInstantiator(new EnhancedInstantiator());
|
||||
extFactory.setEnhancedInstantiator(new DecoratedObjectFactory());
|
||||
this.factory = extFactory;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.eclipse.jetty.io.ByteBufferPool;
|
|||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
import org.eclipse.jetty.toolchain.test.EventQueue;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -229,7 +229,7 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
|
|||
this.parser = new Parser(policy,bufferPool);
|
||||
|
||||
this.extensionFactory = new WebSocketExtensionFactory(policy,bufferPool);
|
||||
this.extensionFactory.setEnhancedInstantiator(new EnhancedInstantiator());
|
||||
this.extensionFactory.setEnhancedInstantiator(new DecoratedObjectFactory());
|
||||
this.ioState = new IOState();
|
||||
this.ioState.addListener(this);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
import org.eclipse.jetty.server.HttpConnection;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.util.EnhancedInstantiator;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -90,7 +90,7 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
private Set<WebSocketSession> openSessions = new CopyOnWriteArraySet<>();
|
||||
private WebSocketCreator creator;
|
||||
private List<Class<?>> registeredSocketClasses;
|
||||
private EnhancedInstantiator enhancedInstantiator;
|
||||
private DecoratedObjectFactory objectFactory;
|
||||
|
||||
public WebSocketServerFactory()
|
||||
{
|
||||
|
@ -165,15 +165,16 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
{
|
||||
Thread.currentThread().setContextClassLoader(contextClassloader);
|
||||
|
||||
// Establish the EnhancedInstantiator thread local
|
||||
// Establish the DecoratedObjectFactory thread local
|
||||
// for various ServiceLoader initiated components to use.
|
||||
EnhancedInstantiator.setCurrentInstantiator(getEnhancedInstantiator(request));
|
||||
DecoratedObjectFactory.setCurrentInstantiator(getEnhancedInstantiator(request));
|
||||
|
||||
// Create Servlet Specific Upgrade Request/Response objects
|
||||
ServletUpgradeRequest sockreq = new ServletUpgradeRequest(request);
|
||||
ServletUpgradeResponse sockresp = new ServletUpgradeResponse(response);
|
||||
|
||||
Object websocketPojo = creator.createWebSocket(sockreq, sockresp);
|
||||
websocketPojo = objectFactory.decorate(websocketPojo);
|
||||
|
||||
// Handle response forbidden (and similar paths)
|
||||
if (sockresp.isCommitted())
|
||||
|
@ -298,7 +299,7 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
Class<?> firstClass = registeredSocketClasses.get(0);
|
||||
try
|
||||
{
|
||||
return enhancedInstantiator.createInstance(firstClass);
|
||||
return objectFactory.createInstance(firstClass);
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException e)
|
||||
{
|
||||
|
@ -309,15 +310,15 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
if(this.enhancedInstantiator == null)
|
||||
if(this.objectFactory == null)
|
||||
{
|
||||
this.enhancedInstantiator = new EnhancedInstantiator();
|
||||
this.objectFactory = new DecoratedObjectFactory();
|
||||
}
|
||||
|
||||
this.extensionFactory.setEnhancedInstantiator(this.enhancedInstantiator);
|
||||
this.extensionFactory.setEnhancedInstantiator(this.objectFactory);
|
||||
for(SessionFactory sessionFactory: this.sessionFactories)
|
||||
{
|
||||
sessionFactory.setEnhancedInstantiator(this.enhancedInstantiator);
|
||||
sessionFactory.setEnhancedInstantiator(this.objectFactory);
|
||||
}
|
||||
|
||||
super.doStart();
|
||||
|
@ -336,48 +337,48 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
return this.creator;
|
||||
}
|
||||
|
||||
public EnhancedInstantiator getEnhancedInstantiator()
|
||||
public DecoratedObjectFactory getEnhancedInstantiator()
|
||||
{
|
||||
return enhancedInstantiator;
|
||||
return objectFactory;
|
||||
}
|
||||
|
||||
public EnhancedInstantiator getEnhancedInstantiator(HttpServletRequest request)
|
||||
public DecoratedObjectFactory getEnhancedInstantiator(HttpServletRequest request)
|
||||
{
|
||||
if (enhancedInstantiator != null)
|
||||
if (objectFactory != null)
|
||||
{
|
||||
return enhancedInstantiator;
|
||||
return objectFactory;
|
||||
}
|
||||
|
||||
if (request == null)
|
||||
{
|
||||
LOG.debug("Using default EnhancedInstantiator (HttpServletRequest is null)");
|
||||
return new EnhancedInstantiator();
|
||||
LOG.debug("Using default DecoratedObjectFactory (HttpServletRequest is null)");
|
||||
return new DecoratedObjectFactory();
|
||||
}
|
||||
|
||||
return getEnhancedInstantiator(request.getServletContext());
|
||||
}
|
||||
|
||||
public EnhancedInstantiator getEnhancedInstantiator(ServletContext context)
|
||||
public DecoratedObjectFactory getEnhancedInstantiator(ServletContext context)
|
||||
{
|
||||
if (enhancedInstantiator != null)
|
||||
if (objectFactory != null)
|
||||
{
|
||||
return enhancedInstantiator;
|
||||
return objectFactory;
|
||||
}
|
||||
|
||||
if (context == null)
|
||||
{
|
||||
LOG.debug("Using default EnhancedInstantiator (ServletContext is null)");
|
||||
return new EnhancedInstantiator();
|
||||
LOG.debug("Using default DecoratedObjectFactory (ServletContext is null)");
|
||||
return new DecoratedObjectFactory();
|
||||
}
|
||||
|
||||
enhancedInstantiator = (EnhancedInstantiator)context.getAttribute(EnhancedInstantiator.ATTR);
|
||||
if (enhancedInstantiator == null)
|
||||
objectFactory = (DecoratedObjectFactory)context.getAttribute(DecoratedObjectFactory.ATTR);
|
||||
if (objectFactory == null)
|
||||
{
|
||||
LOG.debug("Using default EnhancedInstantiator (ServletContext attribute is null)");
|
||||
enhancedInstantiator = new EnhancedInstantiator();
|
||||
LOG.debug("Using default DecoratedObjectFactory (ServletContext attribute is null)");
|
||||
objectFactory = new DecoratedObjectFactory();
|
||||
}
|
||||
|
||||
return enhancedInstantiator;
|
||||
return objectFactory;
|
||||
}
|
||||
|
||||
public EventDriverFactory getEventDriverFactory()
|
||||
|
@ -404,20 +405,20 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
|
|||
|
||||
public void init(ServletContextHandler context) throws ServletException
|
||||
{
|
||||
this.enhancedInstantiator = (EnhancedInstantiator)context.getAttribute(EnhancedInstantiator.ATTR);
|
||||
if (this.enhancedInstantiator == null)
|
||||
this.objectFactory = (DecoratedObjectFactory)context.getAttribute(DecoratedObjectFactory.ATTR);
|
||||
if (this.objectFactory == null)
|
||||
{
|
||||
this.enhancedInstantiator = new EnhancedInstantiator();
|
||||
this.objectFactory = new DecoratedObjectFactory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ServletContext context) throws ServletException
|
||||
{
|
||||
this.enhancedInstantiator = (EnhancedInstantiator)context.getAttribute(EnhancedInstantiator.ATTR);
|
||||
if (this.enhancedInstantiator == null)
|
||||
this.objectFactory = (DecoratedObjectFactory)context.getAttribute(DecoratedObjectFactory.ATTR);
|
||||
if (this.objectFactory == null)
|
||||
{
|
||||
this.enhancedInstantiator = new EnhancedInstantiator();
|
||||
this.objectFactory = new DecoratedObjectFactory();
|
||||
}
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue