Package org.ocpsoft.rewrite.cdi.manager
Class BeanManagerLocator
java.lang.Object
org.ocpsoft.rewrite.cdi.manager.BeanManagerLocator
A utility for use in non-managed classes, which are not able to obtain a reference to the BeanManager using
injection.
BeanManagerProvider is an SPI that may be implemented to allow third parties to register custom methods of
looking up the BeanManager in an external context. This class will consult implementations according to precedence.
**WARNING** This class is NOT a clever way to get the BeanManager, and should be avoided at all
costs. If you need a handle to the BeanManager you should probably register an Extension instead
of using this class; have you tried using @Inject?
If you think you need to use this class, chat to the community and make sure you aren't missing a trick!
- Author:
- Pete Muir, Nicklas Karlsson, Dan Allen, Stuart Douglas
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjakarta.enterprise.inject.spi.BeanManagerIf a lookup has not yet been performed, consult registeredBeanManagerProviderimplementations to locate theBeanManagerand return the result.Return theBeanManagerProviderthat was used to locate the BeanManager.booleanIf a lookup has not yet been performed, consult registeredBeanManagerProviderimplementations to locate theBeanManagerand return whether it was found, caching the result.
-
Constructor Details
-
BeanManagerLocator
public BeanManagerLocator()
-
-
Method Details
-
getBeanManager
public jakarta.enterprise.inject.spi.BeanManager getBeanManager()If a lookup has not yet been performed, consult registeredBeanManagerProviderimplementations to locate theBeanManagerand return the result. If theBeanManagercannot be resolved, throw aBeanManagerUnavailableException.- Returns:
- the BeanManager for the current bean archive
- Throws:
BeanManagerUnavailableException- if the BeanManager cannot be resolved
-
isBeanManagerAvailable
public boolean isBeanManagerAvailable()If a lookup has not yet been performed, consult registeredBeanManagerProviderimplementations to locate theBeanManagerand return whether it was found, caching the result.- Returns:
trueif the bean manager has been found, otherwisefalse
-
getLocatingProvider
Return theBeanManagerProviderthat was used to locate the BeanManager. This method will not attempt a lookup.- Returns:
- the BeanManagerProvider implementation
-