}
if (bean == null) {
Class beanClass = deploymentInfo.getBeanClass();
ObjectRecipe objectRecipe = new ObjectRecipe(beanClass);
objectRecipe.allow(Option.FIELD_INJECTION);
objectRecipe.allow(Option.PRIVATE_PROPERTIES);
objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
Operation originalOperation = callContext.getCurrentOperation();
BaseContext.State[] originalAllowedStates = callContext.getCurrentAllowedStates();
try {
Context ctx = deploymentInfo.getJndiEnc();
SessionContext sessionContext;
// This needs to be synchronized as this code is multi-threaded.
// In between the lookup and the bind a bind may take place in another Thread.
// This is a fix for GERONIMO-3444
synchronized(this){
try {
sessionContext = (SessionContext) ctx.lookup("java:comp/EJBContext");
} catch (NamingException e1) {
sessionContext = createSessionContext();
// TODO: This should work
ctx.bind("java:comp/EJBContext", sessionContext);
}
}
if (javax.ejb.SessionBean.class.isAssignableFrom(beanClass) || hasSetSessionContext(beanClass)) {
callContext.setCurrentOperation(Operation.INJECTION);
callContext.setCurrentAllowedStates(StatelessContext.getStates());
objectRecipe.setProperty("sessionContext", new StaticRecipe(sessionContext));
}
WebServiceContext wsContext;
// This is a fix for GERONIMO-3444
synchronized(this){
try {
wsContext = (WebServiceContext) ctx.lookup("java:comp/WebServiceContext");
} catch (NamingException e) {
wsContext = new EjbWebServiceContext(sessionContext);
ctx.bind("java:comp/WebServiceContext", wsContext);
}
}
fillInjectionProperties(objectRecipe, beanClass, deploymentInfo, ctx);
bean = objectRecipe.create(beanClass.getClassLoader());
Map unsetProperties = objectRecipe.getUnsetProperties();
if (unsetProperties.size() > 0) {
for (Object property : unsetProperties.keySet()) {
logger.warning("Injection: No such property '" + property + "' in class " + beanClass.getName());
}
}
HashMap<String, Object> interceptorInstances = new HashMap<String, Object>();
for (InterceptorData interceptorData : deploymentInfo.getAllInterceptors()) {
if (interceptorData.getInterceptorClass().equals(beanClass)) continue;
Class clazz = interceptorData.getInterceptorClass();
ObjectRecipe interceptorRecipe = new ObjectRecipe(clazz);
interceptorRecipe.allow(Option.FIELD_INJECTION);
interceptorRecipe.allow(Option.PRIVATE_PROPERTIES);
interceptorRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
fillInjectionProperties(interceptorRecipe, clazz, deploymentInfo, ctx);
try {
Object interceptorInstance = interceptorRecipe.create(clazz.getClassLoader());
interceptorInstances.put(clazz.getName(), interceptorInstance);
} catch (ConstructionException e) {
throw new Exception("Failed to create interceptor: " + clazz.getName(), e);
}
}