Issue #3804
more review changes Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
bcb4c59ab2
commit
bf1ece938f
|
@ -4,8 +4,9 @@
|
|||
Support for CDI inside the webapp.
|
||||
This module does not provide CDI, but configures jetty to support various
|
||||
integration modes with a CDI implementation on the webapp classpath.
|
||||
CDI integration modes can be selected per webapp with the "jetty.cdi.mode"
|
||||
init parameter or default to the mode set by the "jetty.cdi.mode" server attribute.
|
||||
CDI integration modes can be selected per webapp with the "org.eclipse.jetty.cdi"
|
||||
init parameter or defaults to the mode set by the "org.eclipse.jetty.cdi" server
|
||||
attribute (which is initialised from the "jetty.cdi.mode" start property).
|
||||
Supported modes are:
|
||||
CdiSpiDecorator - Jetty will call the CDI SPI within the webapp to decorate
|
||||
objects (default).
|
||||
|
|
|
@ -27,19 +27,16 @@ import javax.servlet.ServletContextAttributeEvent;
|
|||
import javax.servlet.ServletContextAttributeListener;
|
||||
|
||||
import org.eclipse.jetty.util.Decorator;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* A ServletContextAttributeListener that listens for a context
|
||||
* attribute to obtain a decorator instance. The instance is then either
|
||||
* coerced to a Decorator or reflected for decorator compatible methods so it can
|
||||
* be added to the {@link ServletContextHandler#getObjectFactory()} as a
|
||||
* coerced to a {@link Decorator} or reflected for decorator compatible methods
|
||||
* so it can be added to the {@link ServletContextHandler#getObjectFactory()} as a
|
||||
* {@link Decorator}.
|
||||
*/
|
||||
public class DecoratingListener implements ServletContextAttributeListener
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(DecoratingListener.class);
|
||||
private static final MethodType DECORATE_TYPE;
|
||||
private static final MethodType DESTROY_TYPE;
|
||||
|
||||
|
@ -48,7 +45,7 @@ public class DecoratingListener implements ServletContextAttributeListener
|
|||
try
|
||||
{
|
||||
DECORATE_TYPE = MethodType.methodType(Object.class, Object.class);
|
||||
DESTROY_TYPE = MethodType.methodType(Void.TYPE, Object.class);
|
||||
DESTROY_TYPE = MethodType.methodType(void.class, Object.class);
|
||||
|
||||
// Check we have the right MethodTypes for the current Decorator signatures
|
||||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
|
@ -100,7 +97,7 @@ public class DecoratingListener implements ServletContextAttributeListener
|
|||
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
MethodHandle decorate = lookup.findVirtual(clazz, "decorate", DECORATE_TYPE);
|
||||
MethodHandle destroy = lookup.findVirtual(clazz, "destroy", DESTROY_TYPE);
|
||||
return new DynamicDecorator(decorate, destroy, object);
|
||||
return new DynamicDecorator(object, decorate, destroy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -137,15 +134,15 @@ public class DecoratingListener implements ServletContextAttributeListener
|
|||
|
||||
private static class DynamicDecorator implements Decorator
|
||||
{
|
||||
private final Object _object;
|
||||
private final MethodHandle _decorate;
|
||||
private final MethodHandle _destroy;
|
||||
private final Object _object;
|
||||
|
||||
private DynamicDecorator(MethodHandle decorate, MethodHandle destroy, Object object)
|
||||
private DynamicDecorator(Object object, MethodHandle decorate, MethodHandle destroy)
|
||||
{
|
||||
_object = object;
|
||||
_decorate = decorate;
|
||||
_destroy = destroy;
|
||||
_object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,28 +19,19 @@
|
|||
package org.eclipse.jetty.webapp;
|
||||
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.util.Decorator;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* A ServletContextAttributeListener that listens for a specific context
|
||||
* attribute (default "org.eclipse.jetty.webapp.decorator") to obtain a
|
||||
* decorator instance from the webapp. The instance is then either coerced
|
||||
* to a Decorator or reflected for decorator compatible methods so it can
|
||||
* be added to the {@link WebAppContext#getObjectFactory()} as a
|
||||
* {@link Decorator}.
|
||||
* An extended org.eclipse.jetty.servlet.DecoratingListener.
|
||||
* The context attribute "org.eclipse.jetty.webapp.DecoratingListener" if
|
||||
* not set, is set to the name of the attribute this listener listens for.
|
||||
*/
|
||||
public class DecoratingListener extends org.eclipse.jetty.servlet.DecoratingListener
|
||||
{
|
||||
public static final String DECORATOR_ATTRIBUTE = "org.eclipse.jetty.webapp.decorator";
|
||||
private static final Logger LOG = Log.getLogger(DecoratingListener.class);
|
||||
|
||||
public DecoratingListener()
|
||||
{
|
||||
this((String)null);
|
||||
this(DECORATOR_ATTRIBUTE);
|
||||
}
|
||||
|
||||
public DecoratingListener(String attributeName)
|
||||
|
@ -50,7 +41,7 @@ public class DecoratingListener extends org.eclipse.jetty.servlet.DecoratingList
|
|||
|
||||
public DecoratingListener(ServletContextHandler context)
|
||||
{
|
||||
this(context, null);
|
||||
this(context, DECORATOR_ATTRIBUTE);
|
||||
}
|
||||
|
||||
public DecoratingListener(ServletContextHandler context, String attributeName)
|
||||
|
|
|
@ -60,7 +60,7 @@ public class CDITests extends AbstractDistributionTest
|
|||
Arguments.of("weld", "cdi2", null),
|
||||
Arguments.of("weld", "cdi-spi", null), // Weld >= 3.1.2
|
||||
Arguments.of("weld", "decorate", null), // Weld >= 3.1.2
|
||||
// Arguments.of("weld", "cdi-decorate", null), // Not supported
|
||||
// TODO Arguments.of("weld", "cdi-decorate", null), // Weld >= 3.1.3
|
||||
|
||||
// -- Apache OpenWebBeans --
|
||||
Arguments.of("owb", "cdi-spi", removeJettyWebXml),
|
||||
|
|
Loading…
Reference in New Issue