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 class
AbstractComponentManager.State
-
Field Summary
Fields Modifier and Type Field Description protected ReentrantReadWriteLock
m_activationLock
protected ComponentContainer<S>
m_container
protected boolean
m_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 protected
AbstractComponentManager(ComponentContainer<S> container, ComponentMethods componentMethods)
The constructor receives both the activator and the metadataprotected
AbstractComponentManager(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 boolean
collectDependencies(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 thesource
Dictionary
into thetarget
Dictionary
except for private properties (whose name has a leading dot) which are only copied if theallProps
parameter 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 thesource
Dictionary
into thetarget
Dictionary
except for private properties (whose name has a leading dot) which are only copied if theallProps
parameter istrue
.protected abstract void
deleteComponent(int reason)
org.osgi.util.promise.Promise<Void>
disable(boolean async)
void
dispose(int reason)
Disposes off this component deactivating and disabling it first as required.org.osgi.util.promise.Promise<Void>
enable(boolean async)
ComponentActivator
getActivator()
org.osgi.framework.Bundle
getBundle()
Returns theBundle
providing this component.abstract void
getComponentManagers(List<AbstractComponentManager<S>> cms)
ComponentMetadata
getComponentMetadata()
long
getId()
protected String
getName()
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.int
getSpecState()
boolean
isFactory()
protected boolean
isImmediate()
boolean
isLogEnabled(int level)
Returnstrue
if logging for the given level is enabled.void
log(int level, String message, Object[] arguments, Throwable ex)
void
log(int level, String message, Throwable ex)
abstract void
reconfigure(Map<String,Object> configuration, boolean configurationDeleted, TargetedPID factoryPid)
protected boolean
registerService()
Registers the service on behalf of the component.abstract void
setServiceProperties(Dictionary<String,?> serviceProperties)
void
setServiceProperties(MethodResult methodResult, Integer trackingCount)
String
toString()
protected boolean
unregisterService()
protected boolean
verifyDependencyManagers()
-
-
-
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:
getId
in interfaceComponentManager<S>
-
getName
protected String getName()
-
getBundle
public org.osgi.framework.Bundle getBundle()
Returns theBundle
providing 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)
Returnstrue
if logging for the given level is enabled.- Specified by:
isLogEnabled
in interfaceSimpleLogger
-
log
public void log(int level, String message, Throwable ex)
- Specified by:
log
in interfaceSimpleLogger
-
log
public void log(int level, String message, Object[] arguments, Throwable ex)
- Specified by:
log
in interfaceSimpleLogger
-
verifyDependencyManagers
protected boolean verifyDependencyManagers()
-
getReferenceManagers
public List<? extends ReferenceManager<S,?>> getReferenceManagers()
- Specified by:
getReferenceManagers
in interfaceComponentManager<S>
-
getProperties
public abstract Map<String,Object> getProperties()
- Specified by:
getProperties
in 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 thesource
Dictionary
into thetarget
Dictionary
except for private properties (whose name has a leading dot) which are only copied if theallProps
parameter istrue
.- Parameters:
target
- TheDictionary
into which to copy the properties. Ifnull
a newHashtable
is created.source
- TheDictionary
providing the properties to copy. Ifnull
or empty, nothing is copied.allProps
- Whether all properties (true
) or only the public properties (false
) are to be copied.- Returns:
- The
target
is returned, which may be empty ifsource
isnull
or empty andtarget
wasnull
or 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 thesource
Dictionary
into thetarget
Dictionary
except for private properties (whose name has a leading dot) which are only copied if theallProps
parameter istrue
.- Parameters:
source
- TheDictionary
providing the properties to copy. Ifnull
or empty, nothing is copied.allProps
- Whether all properties (true
) or only the public properties (false
) are to be copied.- Returns:
- The
target
is returned, which may be empty ifsource
isnull
or empty andtarget
wasnull
or 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:
getSpecState
in 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)
-
-