Class CdiSpiDecorator

  • All Implemented Interfaces:
    Decorator

    public class CdiSpiDecorator
    extends java.lang.Object
    implements 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 MethodHandles 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

      Fields 
      Modifier and Type Field Description
      static java.lang.String MODE  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T decorate​(T o)
      Decorate an object.
      void destroy​(java.lang.Object o)
      Destroy a decorated object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CdiSpiDecorator

        public CdiSpiDecorator​(ServletContextHandler context)
                        throws java.lang.UnsupportedOperationException
        Throws:
        java.lang.UnsupportedOperationException
    • Method Detail

      • 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.

        Specified by:
        decorate in interface Decorator
        Type Parameters:
        T - The type of the object to be decorated
        Parameters:
        o - The object to be decorated
        Returns:
        The decorated object
      • destroy

        public void destroy​(java.lang.Object o)
        Destroy a decorated object.

        The signature of this method must match what is introspected for by the Jetty DecoratingListener class. It is invoked dynamically.

        Specified by:
        destroy in interface Decorator
        Parameters:
        o - The object to be destroyed