org.wamblee.cdi
Class BeanManagerLookup

java.lang.Object
  extended by org.wamblee.cdi.BeanManagerLookup

public class BeanManagerLookup
extends java.lang.Object

Class that encapsulates beanmanager lookup in a way so that the lookup can be explicitly overriden (for instance for unit test). In case no bean manager is found the beanmanager is set to null and the problem is logged. This class does caching of the obtained reference to the bean manager. As a result, it is necessary to call setBeanManager(BeanManager) in the setup phase of unit tests to make sure that the lookup is done again.

Author:
Erik Brakkee

Field Summary
static java.lang.String BEAN_MANAGER_JNDI
           
 
Constructor Summary
BeanManagerLookup()
           
 
Method Summary
static javax.enterprise.inject.spi.BeanManager lookup()
          Looks up the bean manager if not already cached and returns it.
static void setBeanManager(javax.enterprise.inject.spi.BeanManager aMgr)
          Sets the bean manager (mainly for testability).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEAN_MANAGER_JNDI

public static final java.lang.String BEAN_MANAGER_JNDI
See Also:
Constant Field Values
Constructor Detail

BeanManagerLookup

public BeanManagerLookup()
Method Detail

setBeanManager

public static void setBeanManager(javax.enterprise.inject.spi.BeanManager aMgr)
Sets the bean manager (mainly for testability).

Parameters:
aMgr - Bean manager.

lookup

public static javax.enterprise.inject.spi.BeanManager lookup()
Looks up the bean manager if not already cached and returns it.

Returns:
Bean manager.


Copyright © 2022. All Rights Reserved.