public <T> T get(Contextual<T> contextual, CreationalContext<T> arg1) {
Bean<T> bean = (Bean<T>) contextual;
String variableName = bean.getName();
BusinessProcess businessProcess = getBusinessProcess();
Object variable = businessProcess.getVariable(variableName);
if (variable != null) {
if(logger.isDebugEnabled()) {
if(businessProcess.isAssociated()) {
logger.debug("Getting instance of bean '{}' from Execution[{}]", variableName, businessProcess.getExecutionId());
} else {
logger.debug("Getting instance of bean '{}' from transient bean store", variableName);
}
}
return (T) variable;
} else {
if(logger.isDebugEnabled()) {
if(businessProcess.isAssociated()) {
logger.debug("Creating instance of bean '{}' in business process context representing Execution[{}]", variableName, businessProcess.getExecutionId());
} else {
logger.debug("Creating instance of bean '{}' in transient bean store", variableName);
}
}
T beanInstance = bean.create(arg1);
businessProcess.setVariable(variableName, beanInstance);
return beanInstance;
}
}