Class SupplierThreadScopeBean

java.lang.Object
org.glassfish.jersey.inject.cdi.se.bean.JerseyBean<Object>
org.glassfish.jersey.inject.cdi.se.bean.SupplierThreadScopeBean
All Implemented Interfaces:
jakarta.enterprise.context.spi.Contextual<Object>, jakarta.enterprise.inject.spi.Bean<Object>, jakarta.enterprise.inject.spi.BeanAttributes<Object>, jakarta.enterprise.inject.spi.PassivationCapable

public class SupplierThreadScopeBean extends JerseyBean<Object>
Creates an implementation of Bean interface using Jersey's SupplierInstanceBinding. Binding provides the information about the bean also called BeanAttributes information. The Bean does not use JerseyInjectionTarget because serves already created proxy, therefore the create operation just return provided instance without any other contextual operation (produce, inject, destroy).

This bean is special and is used only for service registered as a PerThread and works through the proxy which serves the correct instance per the given thread.

Register example:

 AbstractBinder {
     @Override
     protected void configure() {
         bindFactory(new MyFactoryInjectionProvider())
              .to(MyBean.class)
              .in(PerThread.class);
     }
 }
 
Inject example:
 @Path("/")
 public class MyResource {
   @Inject
   private MyBean myBean;
 }
 
  • Method Details

    • getScope

      public Class<? extends Annotation> getScope()
      Specified by:
      getScope in interface jakarta.enterprise.inject.spi.BeanAttributes<Object>
      Overrides:
      getScope in class JerseyBean<Object>
    • create

      public Object create(jakarta.enterprise.context.spi.CreationalContext<Object> ctx)
    • destroy

      public void destroy(Object instance, jakarta.enterprise.context.spi.CreationalContext<Object> creationalContext)
      Specified by:
      destroy in interface jakarta.enterprise.context.spi.Contextual<Object>
      Overrides:
      destroy in class JerseyBean<Object>
    • getBeanClass

      public Class<?> getBeanClass()
      Specified by:
      getBeanClass in interface jakarta.enterprise.inject.spi.Bean<Object>
      Overrides:
      getBeanClass in class JerseyBean<Object>