Class AbstractComponentManager<S>
- java.lang.Object
-
- org.apache.felix.scr.impl.manager.AbstractComponentManager<S>
-
- All Implemented Interfaces:
ComponentManager<S>
- Direct Known Subclasses:
ComponentFactoryImpl
,SingleComponentManager
public abstract class AbstractComponentManager<S> extends Object implements 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_DISPOSED, STATE_SATISFIED, STATE_UNSATISFIED_CONFIGURATION, STATE_UNSATISFIED_REFERENCE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractComponentManager(ComponentContainer<S> container, ComponentMethods<S> componentMethods)
The constructor receives both the container and the methods.protected
AbstractComponentManager(ComponentContainer<S> container, ComponentMethods<S> componentMethods, boolean factoryInstance)
The constructor receives both the container and the methods.
-
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()
String
getFailureReason()
long
getId()
ComponentLogger
getLogger()
abstract Map<String,Object>
getProperties()
protected String[]
getProvidedServices()
List<? extends ReferenceManager<S,?>>
getReferenceManagers()
org.osgi.framework.ServiceReference<S>
getRegisteredServiceReference()
Dictionary<String,Object>
getServiceProperties()
Returns the subset of component properties to be used as service properties.protected org.osgi.framework.ServiceRegistration<S>
getServiceRegistration()
int
getSpecState()
boolean
isFactory()
protected boolean
isImmediate()
abstract void
reconfigure(Map<String,Object> configuration, boolean configurationDeleted, TargetedPID factoryPid)
protected boolean
registerService()
Registers the service on behalf of the component.void
setFailureReason(Throwable e)
Set the activation failure reasonabstract 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<S> componentMethods)
The constructor receives both the container and the methods.- Parameters:
container
- The component containercomponentMethods
- The component methods
-
AbstractComponentManager
protected AbstractComponentManager(ComponentContainer<S> container, ComponentMethods<S> componentMethods, boolean factoryInstance)
The constructor receives both the container and the methods.- Parameters:
container
- The component containercomponentMethods
- The component methodsfactoryInstance
- Flag whether this is a factory instance
-
-
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>
-
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()
-
getServiceRegistration
protected org.osgi.framework.ServiceRegistration<S> getServiceRegistration()
-
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()
-
getLogger
public ComponentLogger getLogger()
-
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>
-
getFailureReason
public String getFailureReason()
- Specified by:
getFailureReason
in interfaceComponentManager<S>
-
setFailureReason
public void setFailureReason(Throwable e)
Set the activation failure reason- Parameters:
e
- The exception which caused the activation to fail
-
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)
-
getRegisteredServiceReference
public final org.osgi.framework.ServiceReference<S> getRegisteredServiceReference()
- Specified by:
getRegisteredServiceReference
in interfaceComponentManager<S>
-
-