What exactly does the BeanManager in java enterprise do? -



What exactly does the BeanManager in java enterprise do? -

in spring, can utilize application context create beans dynamically.

searching code similar in java enterprise, ran across next snippet of code:

public class beanmanagingutils { private beanmanager beanmanager; public beanmanagingutils() { seek { initialcontext initialcontext = new initialcontext(); beanmanager = (beanmanager) initialcontext.lookup("java:comp/beanmanager"); } grab (namingexception e) { //log.error("couldn't beanmanager through jndi"); e.printstacktrace(); } } @suppresswarnings("unchecked") public <t> t getcontextualinstance(final class<t> type) { t result = null; bean<t> bean = (bean<t>) beanmanager.resolve(beanmanager.getbeans(type)); if (bean != null) { creationalcontext<t> context = beanmanager.createcreationalcontext(bean); if (context != null) { result = (t) beanmanager.getreference(bean, type, context); } } homecoming result; } }

by calling getcontextualinstance class, can (sort of) generate bean, i've no thought sort of bean it's generating, eg whether it's stateless ejb, stateful ejb, managed bean, etc. seems create happily if bean in question not annotated @ all, , gives error if annotate bean '@stateful'. don't understand documentation on beanmanager here http://docs.oracle.com/javaee/6/api/javax/enterprise/inject/spi/beanmanager.html

can shed lite on doing , kind of beans creates, or point me fuller documentation?

many thanks!

java java-ee

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -