Class AbstractComponentManager<S>
java.lang.Object
org.apache.felix.scr.impl.manager.AbstractComponentManager<S>
- All Implemented Interfaces:
ComponentManager<S>
- Direct Known Subclasses:
ComponentFactoryImpl
,SingleComponentManager
The default ComponentManager. Objects of this class are responsible for managing
implementation object's lifecycle.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ReentrantReadWriteLock
protected final ComponentContainer
<S> protected final boolean
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
ConstructorsModifierConstructorDescriptionprotected
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
Modifier and TypeMethodDescriptionprotected 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> 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) 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) final org.osgi.util.promise.Promise
<Void> disable
(boolean async) void
dispose
(int reason) Disposes off this component deactivating and disabling it first as required.final org.osgi.util.promise.Promise
<Void> enable
(boolean async) org.osgi.framework.Bundle
Returns theBundle
providing this component.abstract void
long
getId()
protected String[]
List
<? extends ReferenceManager<S, ?>> final org.osgi.framework.ServiceReference
<S> Returns the subset of component properties to be used as service properties.protected org.osgi.framework.ServiceRegistration
<S> int
boolean
protected boolean
abstract void
reconfigure
(Map<String, Object> configuration, boolean configurationDeleted, TargetedPID factoryPid) protected boolean
Registers the service on behalf of the component.void
Set the activation failure reasonabstract void
setServiceProperties
(Dictionary<String, ?> serviceProperties) void
setServiceProperties
(MethodResult methodResult, Integer trackingCount) toString()
protected boolean
protected boolean
-
Field Details
-
m_container
-
m_factoryInstance
protected final boolean m_factoryInstance -
m_activationLock
-
-
Constructor Details
-
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 Details
-
enable
-
disable
-
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
-
registerService
protected boolean registerService()Registers the service on behalf of the component. -
unregisterService
protected boolean unregisterService() -
getServiceRegistration
-
collectDependencies
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
-
getLogger
-
toString
-
verifyDependencyManagers
protected boolean verifyDependencyManagers() -
getReferenceManagers
- Specified by:
getReferenceManagers
in interfaceComponentManager<S>
-
getProperties
- Specified by:
getProperties
in interfaceComponentManager<S>
-
setServiceProperties
-
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
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
-
getSpecState
public int getSpecState()- Specified by:
getSpecState
in interfaceComponentManager<S>
-
getFailureReason
- Specified by:
getFailureReason
in interfaceComponentManager<S>
-
setFailureReason
Set the activation failure reason- Parameters:
e
- The exception which caused the activation to fail
-
setServiceProperties
-
reconfigure
public abstract void reconfigure(Map<String, Object> configuration, boolean configurationDeleted, TargetedPID factoryPid) -
getComponentManagers
-
getRegisteredServiceReference
- Specified by:
getRegisteredServiceReference
in interfaceComponentManager<S>
-