public class SessionBeanInjectionPoint extends Object
The spec requires that an InjectionPoint
of a session bean returns:
Bean
object representing the session bean if the session bean is a contextual instance (obtained using
Inject
)Each time a contextual instance of a session bean is created we add its bean class to a thread local collection. The class is removed from the collection after instance creation.
If an InjectionPoint
of a session bean is about to be injected using InjectionPointBean
and the session bean
class is present in the thread local collection (indicating that it is a contextual instance), we leave the
InjectionPoint
untouched and inject it. Otherwise, we wrap the InjectionPoint
within
NonContextualSessionBeanInjectionPoint
which always returns null from getBean().
The only known limitation of this approach is that if the same session bean is used both in its contextual and non-contextual
form within a single dependency chain (non-contextual instance of Foo injecting another Foo instance using Inject
),
the behavior will not be reliable.
Modifier and Type | Method and Description |
---|---|
static void |
registerContextualInstance(org.jboss.weld.ejb.spi.EjbDescriptor<?> descriptor)
Indicates that a contextual instance of a session bean is about to be constructed.
|
static void |
unregisterContextualInstance(org.jboss.weld.ejb.spi.EjbDescriptor<?> descriptor)
Indicates that contextual session bean instance has been constructed.
|
static javax.enterprise.inject.spi.InjectionPoint |
wrapIfNecessary(javax.enterprise.inject.spi.InjectionPoint ip)
Returns the
InjectionPoint passed in as a parameter if this InjectionPoint belongs to a contextual
instance of a session bean. |
public static void registerContextualInstance(org.jboss.weld.ejb.spi.EjbDescriptor<?> descriptor)
public static void unregisterContextualInstance(org.jboss.weld.ejb.spi.EjbDescriptor<?> descriptor)
public static javax.enterprise.inject.spi.InjectionPoint wrapIfNecessary(javax.enterprise.inject.spi.InjectionPoint ip)
InjectionPoint
passed in as a parameter if this InjectionPoint
belongs to a contextual
instance of a session bean. Otherwise, the method wraps the InjectionPoint
to guarantee that getBean() always
returns null.Copyright © 2016. All rights reserved.