use of org.osgi.service.component.ComponentInstance in project felix by apache.
the class ComponentFactoryImpl method newInstance.
/* (non-Javadoc)
* @see org.osgi.service.component.ComponentFactory#newInstance(java.util.Dictionary)
*/
public ComponentInstance newInstance(Dictionary<String, ?> dictionary) {
final SingleComponentManager<S> cm = createComponentManager();
log(LogService.LOG_DEBUG, "Creating new instance from component factory {0} with configuration {1}", new Object[] { getComponentMetadata().getName(), dictionary }, null);
cm.setFactoryProperties(dictionary);
// configure the properties
cm.reconfigure(m_configuration, false, null);
// enable
cm.enableInternal();
ComponentInstance instance;
if (getComponentMetadata().isPersistentFactoryComponent()) {
instance = new ModifyComponentInstance<S>(cm);
} else {
instance = cm.getComponentInstance();
if (instance == null || instance.getInstance() == null) {
// activation failed, clean up component manager
cm.dispose(ComponentConstants.DEACTIVATION_REASON_DISPOSED);
throw new ComponentException("Failed activating component");
}
}
synchronized (m_componentInstances) {
m_componentInstances.put(cm, cm);
}
return instance;
}
Aggregations