Package org.eclipse.jetty.cdi
Class CdiSpiDecorator
java.lang.Object
org.eclipse.jetty.cdi.CdiSpiDecorator
- All Implemented Interfaces:
Decorator
A Decorator that invokes the CDI provider within a webapp to decorate objects created by
the contexts
DecoratedObjectFactory
(typically Listeners, Filters and Servlets).
The CDI provider is invoked using MethodHandle
s to avoid any CDI instance
or dependencies within the server scope. The code invoked is equivalent to:
public <T> T decorate(T o) { BeanManager manager = CDI.current().getBeanManager(); manager.createInjectionTarget(manager.createAnnotatedType((Class<T>)o.getClass())) .inject(o,manager.createCreationalContext(null)); return o; }
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addUndecoratable
(String... classname) <T> T
decorate
(T o) Decorate an object.void
Destroy a decorated object.Get the set of classes that will not be decorated.protected boolean
isDecoratable
(Class<?> clazz) Test if a class can be decorated.void
setUndecoratable
(Set<String> classnames)
-
Field Details
-
MODE
- See Also:
-
-
Constructor Details
-
CdiSpiDecorator
- Throws:
UnsupportedOperationException
-
-
Method Details
-
isDecoratable
Test if a class can be decorated. The default implementation checks the set fromgetUndecoratable()
on the class and all it's super classes.- Parameters:
clazz
- The class to check- Returns:
- True if the class and all it's super classes can be decorated
-
getUndecoratable
Get the set of classes that will not be decorated. The default set includes the listener from Weld that will itself setup decoration.- Returns:
- The modifiable set of class names that will not be decorated (ie
isDecoratable(Class)
will return false. - See Also:
-
setUndecoratable
- Parameters:
classnames
- The set of class names that will not be decorated.- See Also:
-
addUndecoratable
- Parameters:
classname
- A class name that will be added to the undecoratable classes set.- See Also:
-
decorate
public <T> T decorate(T o) Decorate an object.The signature of this method must match what is introspected for by the Jetty DecoratingListener class. It is invoked dynamically.
-
destroy
Destroy a decorated object.The signature of this method must match what is introspected for by the Jetty DecoratingListener class. It is invoked dynamically.
-