public enum BeanManager extends Enum<BeanManager>
This configuration enum allows you to get a reference to CDI managed beans without having any direct CDI dependency.
It will during initialization grab the CDI bean manager instance from JNDI and if it's not null
, then
it's using reflection to get and store the necessary methods in the enum instance which are then invoked on instance
methods such as getReference()
.
// Get the CDI managed bean instance of the given bean class. SomeBean someBean = BeanManager.INSTANCE.getReference(SomeBean.class);
Enum Constant and Description |
---|
INSTANCE
Returns the lazily loaded enum singleton instance.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
getReference(Class<T> beanClass)
Returns the CDI managed bean instance of the given class, or
null if there is none. |
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 <T> T getReference(Class<T> beanClass)
null
if there is none.T
- The generic bean type.beanClass
- The type of the CDI managed bean instance.null
if there is none.Copyright © 2012–2015 OmniFaces. All rights reserved.