org.apache.myfaces.cdi.util
Class BeanProvider
java.lang.Object
org.apache.myfaces.cdi.util.BeanProvider
@Typed
public final class BeanProvider
- extends Object
This class contains utility methods to resolve contextual references
in situations where no injection is available because the
current class is not managed by the CDI Container. This can happen
in e.g. a JPA-2.0 EntityListener, a ServletFilter, a Spring managed
Bean, etc.
Attention: This method is intended for being used in user code at runtime.
If this method gets used during Container boot (in an Extension), non-portable
behaviour results. The CDI specification only allows injection of the
BeanManager during CDI-Container boot time.
- See Also:
BeanManagerProvider
Method Summary |
static
|
getContextualReference(javax.enterprise.inject.spi.BeanManager beanManager,
Class<T> type,
boolean optional,
Annotation... qualifiers)
#getContextualReference(Class, Annotation...) which returns null if the
'optional' parameter is set to true . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
getContextualReference
public static <T> T getContextualReference(javax.enterprise.inject.spi.BeanManager beanManager,
Class<T> type,
boolean optional,
Annotation... qualifiers)
#getContextualReference(Class, Annotation...)
which returns null
if the
'optional' parameter is set to true
.
This method is intended for usage where the BeanManger is known, e.g. in Extensions.
- Type Parameters:
T
- target type- Parameters:
beanManager
- the BeanManager to usetype
- the type of the bean in questionoptional
- if true
it will return null
if no bean could be found or created.
Otherwise it will throw an IllegalStateException
qualifiers
- additional qualifiers which further distinct the resolved bean
- Returns:
- the resolved Contextual Reference
- See Also:
#getContextualReference(Class, Annotation...)
Copyright © 2014 The Apache Software Foundation. All rights reserved.