Class ComponentFactoryImpl<S>
- java.lang.Object
-
- org.apache.felix.scr.impl.manager.AbstractComponentManager<S>
-
- org.apache.felix.scr.impl.manager.ComponentFactoryImpl<S>
-
- All Implemented Interfaces:
ComponentContainer<S>,ComponentManager<S>,org.osgi.service.component.ComponentFactory<S>
public class ComponentFactoryImpl<S> extends AbstractComponentManager<S> implements org.osgi.service.component.ComponentFactory<S>, ComponentContainer<S>
TheComponentFactoryImplextends theAbstractComponentManagerclass to implement the component factory functionality. As such the OSGi Declarative ServicesComponentFactoryinterface is implemented.In addition the
ComponentHolderinterface is implemented to use this class directly as the holder for component instances created by thenewInstance(Dictionary)method.This class implements spec-compliant component factories and the felix "persistent" component factory, where the factory is always registered whether or not all dependencies are present and the created components also persist whether or not the dependencies are present to allow the component instance to exist.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.felix.scr.impl.manager.AbstractComponentManager
AbstractComponentManager.State
-
-
Field Summary
Fields Modifier and Type Field Description protected longm_changeCountConfiguration change count (R5) or imitation (R4)protected TargetedPIDm_targetedPID-
Fields inherited from class org.apache.felix.scr.impl.manager.AbstractComponentManager
m_activationLock, m_container, m_factoryInstance
-
Fields inherited from interface org.apache.felix.scr.impl.manager.ComponentManager
STATE_ACTIVE, STATE_DISPOSED, STATE_SATISFIED, STATE_UNSATISFIED_CONFIGURATION, STATE_UNSATISFIED_REFERENCE
-
-
Constructor Summary
Constructors Constructor Description ComponentFactoryImpl(ComponentContainer<S> container, ComponentMethods componentMethods)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancollectDependencies(ComponentContextImpl<S> componentContext)Collect and store in m_dependencies_map all the services for dependencies, outside of any locks.protected voiddeleteComponent(int reason)The component factory does not have a component to delete.voiddispose(int reason)Disposes off all components ever created by this component holder.voiddisposed(SingleComponentManager<S> component)Informs the holder that the component has been disposed as a result of calling the dispose method.booleanequals(Object object)Compares thisComponentFactoryImplobject to another object.voidgetComponentManagers(List<AbstractComponentManager<S>> cms)protected voidgetComponentManagers(Map<?,SingleComponentManager<S>> componentMap, List<AbstractComponentManager<S>> componentManagers)TargetedPIDgetConfigurationTargetedPID(TargetedPID pid, TargetedPID factoryPid)Map<String,Object>getProperties()For ComponentFactoryImpl, this is used only for updating targets on the dependency managers, so we don't need any other properties.protected String[]getProvidedServices()Dictionary<String,Object>getServiceProperties()Returns the subset of component properties to be used as service properties.booleanhasConfiguration()inthashCode()Returns a hash code value for the object.booleanisFactory()org.osgi.service.component.ComponentInstance<S>newInstance(Dictionary<String,?> dictionary)voidreconfigure(Map<String,Object> configuration, boolean configurationDeleted, TargetedPID factoryPid)voidsetServiceProperties(Dictionary<String,?> serviceProperties)protected booleanverifyDependencyManagers()-
Methods inherited from class org.apache.felix.scr.impl.manager.AbstractComponentManager
copyTo, copyToDictionary, copyToMap, disable, enable, getActivator, getBundle, getComponentMetadata, getFailureReason, getId, getLogger, getReferenceManagers, getRegisteredServiceReference, getServiceRegistration, getSpecState, isImmediate, registerService, setFailureReason, setServiceProperties, toString, unregisterService
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.felix.scr.impl.manager.ComponentContainer
getActivator, getComponentMetadata, getLogger
-
-
-
-
Field Detail
-
m_changeCount
protected volatile long m_changeCount
Configuration change count (R5) or imitation (R4)
-
m_targetedPID
protected TargetedPID m_targetedPID
-
-
Constructor Detail
-
ComponentFactoryImpl
public ComponentFactoryImpl(ComponentContainer<S> container, ComponentMethods componentMethods)
-
-
Method Detail
-
verifyDependencyManagers
protected boolean verifyDependencyManagers()
- Overrides:
verifyDependencyManagersin classAbstractComponentManager<S>
-
isFactory
public boolean isFactory()
- Overrides:
isFactoryin classAbstractComponentManager<S>
-
newInstance
public org.osgi.service.component.ComponentInstance<S> newInstance(Dictionary<String,?> dictionary)
- Specified by:
newInstancein interfaceorg.osgi.service.component.ComponentFactory<S>
-
equals
public boolean equals(Object object)
Compares thisComponentFactoryImplobject to another object.A component factory impl is considered to be equal to another component factory impl if the component names are equal(using
String.equals).
-
hashCode
public int hashCode()
Returns a hash code value for the object.
-
deleteComponent
protected void deleteComponent(int reason)
The component factory does not have a component to delete.But in the backwards compatible case any instances created for factory configuration instances are to disabled as a consequence of deactivating the component factory.
- Specified by:
deleteComponentin classAbstractComponentManager<S>
-
getProvidedServices
protected String[] getProvidedServices()
- Overrides:
getProvidedServicesin classAbstractComponentManager<S>
-
hasConfiguration
public boolean hasConfiguration()
-
getProperties
public Map<String,Object> getProperties()
For ComponentFactoryImpl, this is used only for updating targets on the dependency managers, so we don't need any other properties.- Specified by:
getPropertiesin interfaceComponentManager<S>- Specified by:
getPropertiesin classAbstractComponentManager<S>
-
setServiceProperties
public void setServiceProperties(Dictionary<String,?> serviceProperties)
- Specified by:
setServicePropertiesin classAbstractComponentManager<S>
-
getServiceProperties
public Dictionary<String,Object> getServiceProperties()
Description copied from class:AbstractComponentManagerReturns the subset of component properties to be used as service properties. These properties are all component properties where property name does not start with dot (.), properties which are considered private.- Overrides:
getServicePropertiesin classAbstractComponentManager<S>
-
collectDependencies
protected boolean collectDependencies(ComponentContextImpl<S> componentContext)
Description copied from class:AbstractComponentManagerCollect and store in m_dependencies_map all the services for dependencies, outside of any locks.- Overrides:
collectDependenciesin classAbstractComponentManager<S>- Parameters:
componentContext- possible instance key for prototype scope references- Returns:
- true if all references can be collected, false if some dependency is no longer available.
-
dispose
public void dispose(int reason)
Disposes off all components ever created by this component holder. This method is called if either the Declarative Services runtime is stopping or if the owning bundle is stopped. In both cases all components created by this holder must be disposed off.- Overrides:
disposein classAbstractComponentManager<S>
-
disposed
public void disposed(SingleComponentManager<S> component)
Description copied from interface:ComponentContainerInforms the holder that the component has been disposed as a result of calling the dispose method.- Specified by:
disposedin interfaceComponentContainer<S>
-
getComponentManagers
protected void getComponentManagers(Map<?,SingleComponentManager<S>> componentMap, List<AbstractComponentManager<S>> componentManagers)
-
getConfigurationTargetedPID
public TargetedPID getConfigurationTargetedPID(TargetedPID pid, TargetedPID factoryPid)
-
reconfigure
public void reconfigure(Map<String,Object> configuration, boolean configurationDeleted, TargetedPID factoryPid)
- Specified by:
reconfigurein classAbstractComponentManager<S>
-
getComponentManagers
public void getComponentManagers(List<AbstractComponentManager<S>> cms)
- Specified by:
getComponentManagersin classAbstractComponentManager<S>
-
-