key = pair.getKey();
}
if (key instanceof Class) {
Class clazz = (Class) key;
ComponentFactory component = null;
if (log.isLoggable(Level.FINE))
log.fine("Creating new instance from " + clazz);
synchronized (_componentMap) {
component = _componentMap.get(clazz);
if (component == null) {
component = _webBeans.resolveByType(clazz);
if (component == null)
component = _webBeans.createTransient(clazz);
_componentMap.put(clazz, component);
}
}
return component.get();
}
else if (key instanceof String) {
ComponentFactory component = _webBeans.findByName((String) key);
if (component == null) {
throw new ObjectNotFoundException(L.l("Cannot find component with name '{0}'", key));
}
return component.get();
}
else {
throw new ObjectNotFoundException(L.l("Component keys of type {0} are not understood", key.getClass().getName()));
}
}