public enum BeanManager extends Enum<BeanManager>
This configuration enum allows you to get the CDI BeanManager
anyway in cases where
@Inject
and/or CDI#current()
may not work, or when you'd like to test availability of
CDI without having any direct CDI dependency (as done in ApplicationListener
). It will during initialization
grab the CDI bean manager instance as generic object from JNDI.
Do not use it directly. Use Beans
utility class instead. It will under the covers use this
configuration enum. This configuration enum is basically a leftover from OmniFaces 1.x where the CDI dependency was
optional. The getReference(Class)
method is deprecated since OmniFaces 2.3 and will be removed in OmniFaces
3.0.
Enum Constant and Description |
---|
INSTANCE
Returns the lazily loaded enum singleton instance.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
get()
Returns the CDI bean manager.
|
<T> T |
getReference(Class<T> beanClass)
Deprecated.
Use
Beans.getReference(Class) instead. |
void |
init(ServletContext servletContext)
Perform manual initialization whereby the bean manager is looked up from servlet context when not available.
|
static BeanManager |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static BeanManager[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final BeanManager INSTANCE
IllegalStateException
when initialization fails.public static BeanManager[] values()
for (BeanManager c : BeanManager.values()) System.out.println(c);
public static BeanManager valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic void init(ServletContext servletContext)
servletContext
- The servlet context to obtain the BeanManager from, if necessary.IllegalStateException
- When initialization fails.public <T> T get()
Beans.getManager()
for this.T
- The javax.enterprise.inject.spi.BeanManager
.ClassCastException
- When you assign it to a variable which is not declared as CDI BeanManager.@Deprecated public <T> T getReference(Class<T> beanClass)
Beans.getReference(Class)
instead.T
- The expected return type.beanClass
- The CDI managed bean class.null
if there is none.UnsupportedOperationException
- When obtaining the CDI managed bean reference failed with an exception.Copyright © 2012–2016 OmniFaces. All rights reserved.