private void construct() throws OpenEJBException {
if (instance != null) throw new IllegalStateException("Instance already constructed");
Class<? extends T> clazz = beanClass;
ObjectRecipe objectRecipe;
if (suppliedInstance != null) {
clazz = (Class<? extends T>) suppliedInstance.getClass();
objectRecipe = PassthroughFactory.recipe(suppliedInstance);
} else {
objectRecipe = new ObjectRecipe(clazz);
}
objectRecipe.allow(Option.FIELD_INJECTION);
objectRecipe.allow(Option.PRIVATE_PROPERTIES);
objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
objectRecipe.allow(Option.NAMED_PARAMETERS);
fillInjectionProperties(objectRecipe);
for (Entry<String, Object> entry : properties.entrySet()) {
objectRecipe.setProperty(entry.getKey(), entry.getValue());
}
Object object;
try {
object = objectRecipe.create(clazz.getClassLoader());
} catch (Exception e) {
throw new OpenEJBException("Error while creating bean " + clazz.getName(), e);
}
Map unsetProperties = objectRecipe.getUnsetProperties();
if (unsetProperties.size() > 0) {
for (Object property : unsetProperties.keySet()) {
logger.warning("Injection: No such property '" + property + "' in class " + clazz.getName());
}
}