try {
ManagedBean managedBeanAnn = clazz.getAnnotation(ManagedBean.class);
ManagedBeanManager managedBeanMgr = habitat.getService(ManagedBeanManager.class);
if( managedBeanAnn != null ) {
// EE style @ManagedBean
// Create , inject, and call PostConstruct (if necessary) via managed bean manager
managedObject = managedBeanMgr.createManagedBean(clazz, invokePostConstruct);
} else {
JCDIService jcdiService = habitat.getService(JCDIService.class);
if( (jcdiService != null) && jcdiService.isCurrentModuleJCDIEnabled() ) {
// Create , inject, and call PostConstruct (if necessary) via managed bean manager
managedObject = managedBeanMgr.createManagedBean(clazz, invokePostConstruct);
} else {
// Not in a 299-enabled module and not annoated with @ManagedBean, so
// just instantiate using new and perform injection
Constructor<T> noArgCtor = clazz.getConstructor();