git://wamblee.org
/
utils
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(no commit message)
[utils]
/
support
/
cdi
/
src
/
main
/
java
/
org
/
wamblee
/
cdi
/
BeanManagerLookup.java
diff --git
a/support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java
b/support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java
index 2952653870e18ebcfbf974232bedafb10be522e5..8c9f2cb0916b793ba00b55dd3381fbefb8f0ebc6 100644
(file)
--- a/
support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java
+++ b/
support/cdi/src/main/java/org/wamblee/cdi/BeanManagerLookup.java
@@
-23,11
+23,15
@@
import javax.naming.NamingException;
/**
* Class that encapsulates beanmanager lookup in a way so that the lookup can be
/**
* Class that encapsulates beanmanager lookup in a way so that the lookup can be
- * explicitly overriden (
e.g.
for unit test).
+ * 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.
*
*
* 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 {@link #setBeanManager(BeanManager)} in the
+ * setup phase of unit tests to make sure that the lookup is done again.
+ *
* @author Erik Brakkee
*/
public class BeanManagerLookup {
* @author Erik Brakkee
*/
public class BeanManagerLookup {
@@
-35,8
+39,8
@@
public class BeanManagerLookup {
private static final Logger LOGGER = Logger
.getLogger(BeanManagerLookup.class.getName());
private static final Logger LOGGER = Logger
.getLogger(BeanManagerLookup.class.getName());
- p
rivate
static final String BEAN_MANAGER_JNDI = "java:comp/BeanManager";
- private static BeanManager
mgr
= null;
+ p
ublic
static final String BEAN_MANAGER_JNDI = "java:comp/BeanManager";
+ private static BeanManager
BEAN_MANAGER
= null;
/**
* Sets the bean manager (mainly for testability).
/**
* Sets the bean manager (mainly for testability).
@@
-45,7
+49,7
@@
public class BeanManagerLookup {
* Bean manager.
*/
public static void setBeanManager(BeanManager aMgr) {
* Bean manager.
*/
public static void setBeanManager(BeanManager aMgr) {
-
mgr
= aMgr;
+
BEAN_MANAGER
= aMgr;
}
/**
}
/**
@@
-54,16
+58,16
@@
public class BeanManagerLookup {
* @return Bean manager.
*/
public static BeanManager lookup() {
* @return Bean manager.
*/
public static BeanManager lookup() {
- if (
mgr
== null) {
+ if (
BEAN_MANAGER
== null) {
try {
InitialContext ctx = new InitialContext();
try {
InitialContext ctx = new InitialContext();
-
mgr
= (BeanManager) ctx.lookup(BEAN_MANAGER_JNDI);
+
BEAN_MANAGER
= (BeanManager) ctx.lookup(BEAN_MANAGER_JNDI);
LOGGER.info("Beanmanager successfully located");
} catch (NamingException e) {
LOGGER.warning("No beanmanager was found, using null");
LOGGER.info("Beanmanager successfully located");
} catch (NamingException e) {
LOGGER.warning("No beanmanager was found, using null");
-
mgr
= null;
+
BEAN_MANAGER
= null;
}
}
}
}
- return
mgr
;
+ return
BEAN_MANAGER
;
}
}
}
}