In my Java EE aplication I use the following snippet to obtain BeanManager
public static BeanManager getBeanManager() {
try {
InitialContext initialContext = new InitialContext();
return (BeanManager) initialContext.lookup("java:comp/BeanManager");
} catch (NamingException e) {
throw new RuntimeException("Failed to retrieve BeanManager!", e);
}
}
Would it be safe to use BeanManager as singleton, so I would not have to lookup in initial context each time I need BeenManager?