Class AbstractComponentManager<S>
- java.lang.Object
-
- org.apache.felix.scr.impl.manager.AbstractComponentManager<S>
-
- All Implemented Interfaces:
SimpleLogger,ComponentManager<S>
- Direct Known Subclasses:
ComponentFactoryImpl,SingleComponentManager
public abstract class AbstractComponentManager<S> extends Object implements SimpleLogger, ComponentManager<S>
The default ComponentManager. Objects of this class are responsible for managing implementation object's lifecycle.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractComponentManager.State
-
Field Summary
Fields Modifier and Type Field Description protected ReentrantReadWriteLockm_activationLockprotected ComponentContainer<S>m_containerprotected booleanm_factoryInstance-
Fields inherited from interface org.apache.felix.scr.impl.manager.ComponentManager
STATE_ACTIVE, STATE_DISABLED, STATE_DISPOSED, STATE_SATISFIED, STATE_UNSATISFIED_CONFIGURATION, STATE_UNSATISFIED_REFERENCE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractComponentManager(ComponentContainer<S> container, ComponentMethods componentMethods)The constructor receives both the activator and the metadataprotectedAbstractComponentManager(ComponentContainer<S> container, ComponentMethods componentMethods, boolean factoryInstance)
-
Method Summary
All Methods Static Methods Instance Methods Abstract 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 static Dictionary<String,Object>copyTo(Dictionary<String,Object> target, Map<String,?> source, boolean allProps)Copies the properties from thesourceDictionaryinto thetargetDictionaryexcept for private properties (whose name has a leading dot) which are only copied if theallPropsparameter istrue.protected static Dictionary<String,Object>copyToDictionary(Dictionary<String,?> source, boolean allProps)protected static Map<String,Object>copyToMap(Dictionary<String,?> source, boolean allProps)Copies the properties from thesourceDictionaryinto thetargetDictionaryexcept for private properties (whose name has a leading dot) which are only copied if theallPropsparameter istrue.protected abstract voiddeleteComponent(int reason)org.osgi.util.promise.Promise<Void>disable(boolean async)voiddispose(int reason)Disposes off this component deactivating and disabling it first as required.org.osgi.util.promise.Promise<Void>enable(boolean async)ComponentActivatorgetActivator()org.osgi.framework.BundlegetBundle()Returns theBundleproviding this component.abstract voidgetComponentManagers(List<AbstractComponentManager<S>> cms)ComponentMetadatagetComponentMetadata()longgetId()protected StringgetName()abstract Map<String,Object>getProperties()protected String[]getProvidedServices()List<? extends ReferenceManager<S,?>>getReferenceManagers()Dictionary<String,Object>getServiceProperties()Returns the subset of component properties to be used as service properties.intgetSpecState()booleanisFactory()protected booleanisImmediate()booleanisLogEnabled(int level)Returnstrueif logging for the given level is enabled.voidlog(int level, String message, Object[] arguments, Throwable ex)voidlog(int level, String message, Throwable ex)abstract voidreconfigure(Map<String,Object> configuration, boolean configurationDeleted, TargetedPID factoryPid)protected booleanregisterService()Registers the service on behalf of the component.abstract voidsetServiceProperties(Dictionary<String,?> serviceProperties)voidsetServiceProperties(MethodResult methodResult, Integer trackingCount)StringtoString()protected booleanunregisterService()protected booleanverifyDependencyManagers()
-
-
-
Field Detail
-
m_container
protected final ComponentContainer<S> m_container
-
m_factoryInstance
protected final boolean m_factoryInstance
-
m_activationLock
protected final ReentrantReadWriteLock m_activationLock
-
-
Constructor Detail
-
AbstractComponentManager
protected AbstractComponentManager(ComponentContainer<S> container, ComponentMethods componentMethods)
The constructor receives both the activator and the metadata- Parameters:
container-componentMethods-
-
AbstractComponentManager
protected AbstractComponentManager(ComponentContainer<S> container, ComponentMethods componentMethods, boolean factoryInstance)
-
-
Method Detail
-
enable
public final org.osgi.util.promise.Promise<Void> enable(boolean async)
-
disable
public final org.osgi.util.promise.Promise<Void> disable(boolean async)
-
dispose
public void dispose(int reason)
Disposes off this component deactivating and disabling it first as required. After disposing off the component, it may not be used anymore.This method unlike the other state change methods immediately takes action and disposes the component. The reason for this is, that this method has to actually complete before other actions like bundle stopping may continue.
-
getId
public long getId()
- Specified by:
getIdin interfaceComponentManager<S>
-
getName
protected String getName()
-
getBundle
public org.osgi.framework.Bundle getBundle()
Returns theBundleproviding this component. If the component as already been disposed off, this method returnsnull.
-
isImmediate
protected boolean isImmediate()
-
isFactory
public boolean isFactory()
-
deleteComponent
protected abstract void deleteComponent(int reason)
-
getProvidedServices
protected String[] getProvidedServices()
-
registerService
protected boolean registerService()
Registers the service on behalf of the component.
-
unregisterService
protected boolean unregisterService()
-
collectDependencies
protected boolean collectDependencies(ComponentContextImpl<S> componentContext)
Collect and store in m_dependencies_map all the services for dependencies, outside of any locks.- 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.
-
getActivator
public ComponentActivator getActivator()
-
isLogEnabled
public boolean isLogEnabled(int level)
Returnstrueif logging for the given level is enabled.- Specified by:
isLogEnabledin interfaceSimpleLogger
-
log
public void log(int level, String message, Throwable ex)- Specified by:
login interfaceSimpleLogger
-
log
public void log(int level, String message, Object[] arguments, Throwable ex)- Specified by:
login interfaceSimpleLogger
-
verifyDependencyManagers
protected boolean verifyDependencyManagers()
-
getReferenceManagers
public List<? extends ReferenceManager<S,?>> getReferenceManagers()
- Specified by:
getReferenceManagersin interfaceComponentManager<S>
-
getProperties
public abstract Map<String,Object> getProperties()
- Specified by:
getPropertiesin interfaceComponentManager<S>
-
setServiceProperties
public abstract void setServiceProperties(Dictionary<String,?> serviceProperties)
-
getServiceProperties
public Dictionary<String,Object> getServiceProperties()
Returns 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.
-
copyTo
protected static Dictionary<String,Object> copyTo(Dictionary<String,Object> target, Map<String,?> source, boolean allProps)
Copies the properties from thesourceDictionaryinto thetargetDictionaryexcept for private properties (whose name has a leading dot) which are only copied if theallPropsparameter istrue.- Parameters:
target- TheDictionaryinto which to copy the properties. Ifnulla newHashtableis created.source- TheDictionaryproviding the properties to copy. Ifnullor empty, nothing is copied.allProps- Whether all properties (true) or only the public properties (false) are to be copied.- Returns:
- The
targetis returned, which may be empty ifsourceisnullor empty andtargetwasnullor all properties are private and had not to be copied
-
copyToMap
protected static Map<String,Object> copyToMap(Dictionary<String,?> source, boolean allProps)
Copies the properties from thesourceDictionaryinto thetargetDictionaryexcept for private properties (whose name has a leading dot) which are only copied if theallPropsparameter istrue.- Parameters:
source- TheDictionaryproviding the properties to copy. Ifnullor empty, nothing is copied.allProps- Whether all properties (true) or only the public properties (false) are to be copied.- Returns:
- The
targetis returned, which may be empty ifsourceisnullor empty andtargetwasnullor all properties are private and had not to be copied
-
copyToDictionary
protected static Dictionary<String,Object> copyToDictionary(Dictionary<String,?> source, boolean allProps)
-
getComponentMetadata
public ComponentMetadata getComponentMetadata()
-
getSpecState
public int getSpecState()
- Specified by:
getSpecStatein interfaceComponentManager<S>
-
setServiceProperties
public void setServiceProperties(MethodResult methodResult, Integer trackingCount)
-
reconfigure
public abstract void reconfigure(Map<String,Object> configuration, boolean configurationDeleted, TargetedPID factoryPid)
-
getComponentManagers
public abstract void getComponentManagers(List<AbstractComponentManager<S>> cms)
-
-