EjbContainerServices containerServices = h.getService(EjbContainerServices.class);
JndiNameEnvironment componentEnv = compEnvManager.getCurrentJndiNameEnvironment();
ManagedBeanDescriptor mbDesc = null;
JndiNameEnvironment injectionEnv = (JndiNameEnvironment) bundleContext;
Object target = injectionContext.getTarget();
String targetClass = target.getClass().getName();
if( componentEnv == null ) {
//throw new IllegalStateException("No valid EE environment for injection of " + targetClass);
System.err.println("No valid EE environment for injection of " + targetClass);
injectionContext.proceed();
return;
}
// Perform EE-style injection on the target. Skip PostConstruct since
// in this case 299 impl is responsible for calling it.
if( componentEnv instanceof EjbDescriptor ) {
EjbDescriptor ejbDesc = (EjbDescriptor) componentEnv;
if( containerServices.isEjbManagedObject(ejbDesc, target.getClass())) {
injectionEnv = componentEnv;
} else {
if( bundleContext instanceof EjbBundleDescriptor ) {
// Check if it's a @ManagedBean class within an ejb-jar. In that case,
// special handling is needed to locate the EE env dependencies
mbDesc = bundleContext.getManagedBeanByBeanClass(targetClass);
}
}
}
if( mbDesc != null ) {
injectionManager.injectInstance(target, mbDesc.getGlobalJndiName(), false);
} else {
if( injectionEnv instanceof EjbBundleDescriptor ) {
// CDI-style managed bean that doesn't have @ManagedBean annotation but
// is injected within the context of an ejb. Need to explicitly