Class SingleComponentManager<S>
- java.lang.Object
-
- org.apache.felix.scr.impl.manager.AbstractComponentManager<S>
-
- org.apache.felix.scr.impl.manager.SingleComponentManager<S>
-
- All Implemented Interfaces:
ComponentManager<S>
,org.osgi.framework.ServiceFactory<S>
- Direct Known Subclasses:
ServiceFactoryComponentManager
public class SingleComponentManager<S> extends AbstractComponentManager<S> implements org.osgi.framework.ServiceFactory<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 interface
SingleComponentManager.SetImplementationObject<S>
TheSetImplementationObject
interface provides an API for component managers to setup the implementation object and potentially other parts as part of thecreateImplementationObject(org.osgi.framework.Bundle, org.apache.felix.scr.impl.manager.SingleComponentManager.SetImplementationObject<S>, org.apache.felix.scr.impl.manager.ComponentContextImpl<S>)
method processing.-
Nested classes/interfaces inherited from class org.apache.felix.scr.impl.manager.AbstractComponentManager
AbstractComponentManager.State
-
-
Field Summary
Fields Modifier and Type Field Description private ComponentContextImpl<S>
m_componentContext
private java.util.Map<java.lang.String,java.lang.Object>
m_configurationProperties
private java.util.Map<java.lang.String,java.lang.Object>
m_factoryProperties
private java.util.Map<java.lang.String,java.lang.Object>
m_properties
private java.util.Dictionary<java.lang.String,java.lang.Object>
m_serviceProperties
private java.util.concurrent.atomic.AtomicInteger
m_useCount
-
Fields inherited from class org.apache.felix.scr.impl.manager.AbstractComponentManager
m_activationLock, m_container, m_factoryInstance, REASONS, registrationManager
-
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 SingleComponentManager(ComponentContainer<S> container, ComponentMethods<S> componentMethods)
The constructor receives both the activator and the metadataSingleComponentManager(ComponentContainer<S> container, ComponentMethods<S> componentMethods, boolean factoryInstance)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
clear()
(package private) void
clearServiceProperties()
private boolean
createComponent(ComponentContextImpl<S> componentContext)
protected S
createImplementationObject(org.osgi.framework.Bundle usingBundle, SingleComponentManager.SetImplementationObject<S> setter, ComponentContextImpl<S> componentContext)
protected void
deleteComponent(int reason)
protected void
disposeImplementationObject(ComponentContextImpl<S> componentContext, int reason)
org.osgi.service.component.ComponentInstance<S>
getComponentInstance()
void
getComponentManagers(java.util.List<AbstractComponentManager<S>> cms)
private S
getInstance()
Get the object that is implementing this descriptorjava.util.Map<java.lang.String,java.lang.Object>
getProperties()
Returns the (private copy) of the Component properties to be used for the ComponentContext as well as eventual service registration.private S
getService(ComponentContextImpl<S> componentContext)
S
getService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration<S> serviceRegistration)
(package private) boolean
getServiceInternal(org.osgi.framework.ServiceRegistration<S> serviceRegistration)
java.util.Dictionary<java.lang.String,java.lang.Object>
getServiceProperties()
Returns the subset of component properties to be used as service properties.(package private) org.osgi.framework.ServiceReference<S>
getServiceReference()
protected org.osgi.framework.ServiceRegistration<S>
getServiceRegistration()
(package private) <T> void
invokeBindMethod(DependencyManager<S,T> dependencyManager, RefPair<S,T> refPair, int trackingCount)
protected MethodResult
invokeModifiedMethod()
(package private) <T> void
invokeUnbindMethod(DependencyManager<S,T> dependencyManager, RefPair<S,T> oldRefPair, int trackingCount)
(package private) <T> boolean
invokeUpdatedMethod(DependencyManager<S,T> dependencyManager, RefPair<S,T> refPair, int trackingCount)
Invoke updated methodprivate boolean
keepInstances()
private boolean
modify(boolean configurationDeleted)
(package private) void
postRegister()
(package private) void
preDeregister()
(package private) void
reconfigure(boolean configurationDeleted)
void
reconfigure(java.util.Map<java.lang.String,java.lang.Object> configuration, boolean configurationDeleted, TargetedPID factoryPid)
Called by the Configuration Admin Service to update the component with Configuration properties.(package private) void
registerComponentId()
private boolean
servicePropertiesMatches(org.osgi.framework.ServiceRegistration<S> reg, java.util.Dictionary<java.lang.String,java.lang.Object> props)
Checks if the given service registration properties matches another set of properties.protected void
setFactoryProperties(java.util.Dictionary<java.lang.String,?> dictionary)
void
setServiceProperties(java.util.Dictionary<java.lang.String,?> serviceProperties)
void
ungetService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration<S> serviceRegistration, S o)
(package private) void
unregisterComponentId()
private void
updateServiceRegistration()
-
Methods inherited from class org.apache.felix.scr.impl.manager.AbstractComponentManager
activateInternal, collectDependencies, copyTo, copyToDictionary, copyToMap, deactivateInternal, disable, disableInternal, dispose, dispose, dumpThreads, enable, enableInternal, enableLatchWait, getActivator, getBundle, getBundleContext, getComponentMetadata, getComponentMethods, getDependencyManager, getDependencyManagers, getFailureReason, getId, getLockTimeout, getLogger, getProvidedServices, getReferenceManagers, getRegisteredServiceReference, getReversedDependencyManagers, getSpecState, getState, getTrackingCount, isFactory, isImmediate, isStateLocked, notifyWaiters, obtainActivationReadLock, obtainActivationWriteLock, obtainStateLock, registerMissingDependency, registerService, releaseActivationReadLock, releaseActivationWriteeLock, releaseStateLock, setFailureReason, setServiceProperties, setState, toString, tracked, unregisterService, updateTargets, verifyDependencyManagers, waitForTracked
-
-
-
-
Field Detail
-
m_useCount
private final java.util.concurrent.atomic.AtomicInteger m_useCount
-
m_componentContext
private volatile ComponentContextImpl<S> m_componentContext
-
m_configurationProperties
private java.util.Map<java.lang.String,java.lang.Object> m_configurationProperties
-
m_factoryProperties
private java.util.Map<java.lang.String,java.lang.Object> m_factoryProperties
-
m_properties
private java.util.Map<java.lang.String,java.lang.Object> m_properties
-
m_serviceProperties
private java.util.Dictionary<java.lang.String,java.lang.Object> m_serviceProperties
-
-
Constructor Detail
-
SingleComponentManager
public SingleComponentManager(ComponentContainer<S> container, ComponentMethods<S> componentMethods)
The constructor receives both the activator and the metadata- Parameters:
componentMethods
-
-
SingleComponentManager
public SingleComponentManager(ComponentContainer<S> container, ComponentMethods<S> componentMethods, boolean factoryInstance)
-
-
Method Detail
-
clear
void clear()
- Overrides:
clear
in classAbstractComponentManager<S>
-
createComponent
private boolean createComponent(ComponentContextImpl<S> componentContext)
-
deleteComponent
protected void deleteComponent(int reason)
- Specified by:
deleteComponent
in classAbstractComponentManager<S>
-
clearServiceProperties
void clearServiceProperties()
-
getComponentInstance
public org.osgi.service.component.ComponentInstance<S> getComponentInstance()
-
getInstance
private S getInstance()
Get the object that is implementing this descriptor- Returns:
- the object that implements the services
-
createImplementationObject
protected S createImplementationObject(org.osgi.framework.Bundle usingBundle, SingleComponentManager.SetImplementationObject<S> setter, ComponentContextImpl<S> componentContext)
-
disposeImplementationObject
protected void disposeImplementationObject(ComponentContextImpl<S> componentContext, int reason)
-
invokeBindMethod
<T> void invokeBindMethod(DependencyManager<S,T> dependencyManager, RefPair<S,T> refPair, int trackingCount)
- Specified by:
invokeBindMethod
in classAbstractComponentManager<S>
-
invokeUpdatedMethod
<T> boolean invokeUpdatedMethod(DependencyManager<S,T> dependencyManager, RefPair<S,T> refPair, int trackingCount)
Description copied from class:AbstractComponentManager
Invoke updated method- Specified by:
invokeUpdatedMethod
in classAbstractComponentManager<S>
- Returns:
true
if the component needs reactivation,false
otherwise.
-
invokeUnbindMethod
<T> void invokeUnbindMethod(DependencyManager<S,T> dependencyManager, RefPair<S,T> oldRefPair, int trackingCount)
- Specified by:
invokeUnbindMethod
in classAbstractComponentManager<S>
-
setFactoryProperties
protected void setFactoryProperties(java.util.Dictionary<java.lang.String,?> dictionary)
-
registerComponentId
void registerComponentId()
- Overrides:
registerComponentId
in classAbstractComponentManager<S>
-
unregisterComponentId
void unregisterComponentId()
- Overrides:
unregisterComponentId
in classAbstractComponentManager<S>
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Returns the (private copy) of the Component properties to be used for the ComponentContext as well as eventual service registration. Method implements the Component Properties provisioning as described in 112.6, Component Properties.- Specified by:
getProperties
in interfaceComponentManager<S>
- Specified by:
getProperties
in classAbstractComponentManager<S>
- Returns:
- a private map of component properties
-
setServiceProperties
public void setServiceProperties(java.util.Dictionary<java.lang.String,?> serviceProperties)
- Specified by:
setServiceProperties
in classAbstractComponentManager<S>
-
postRegister
void postRegister()
- Specified by:
postRegister
in classAbstractComponentManager<S>
-
preDeregister
void preDeregister()
- Specified by:
preDeregister
in classAbstractComponentManager<S>
-
getServiceProperties
public java.util.Dictionary<java.lang.String,java.lang.Object> getServiceProperties()
Description copied from class:AbstractComponentManager
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.- Overrides:
getServiceProperties
in classAbstractComponentManager<S>
-
getServiceReference
final org.osgi.framework.ServiceReference<S> getServiceReference()
-
getServiceRegistration
protected org.osgi.framework.ServiceRegistration<S> getServiceRegistration()
- Overrides:
getServiceRegistration
in classAbstractComponentManager<S>
-
updateServiceRegistration
private void updateServiceRegistration()
-
reconfigure
public void reconfigure(java.util.Map<java.lang.String,java.lang.Object> configuration, boolean configurationDeleted, TargetedPID factoryPid)
Called by the Configuration Admin Service to update the component with Configuration properties. This causes the component to be reactivated with the new configuration unless no configuration has ever been set on this component and theconfiguration
parameter isnull
. In this case nothing is to be done. If a configuration has previously been set and now the configuration is deleted, theconfiguration
parameter isnull
and the component has to be reactivated with the default configuration.- Specified by:
reconfigure
in classAbstractComponentManager<S>
- Parameters:
configuration
- The configuration properties for the component from the Configuration Admin Service ornull
if there is no configuration or if the configuration has just been deleted.configurationDeleted
- TODOfactoryPid
- TODO
-
reconfigure
void reconfigure(boolean configurationDeleted)
-
modify
private boolean modify(boolean configurationDeleted)
-
invokeModifiedMethod
protected MethodResult invokeModifiedMethod()
-
servicePropertiesMatches
private boolean servicePropertiesMatches(org.osgi.framework.ServiceRegistration<S> reg, java.util.Dictionary<java.lang.String,java.lang.Object> props)
Checks if the given service registration properties matches another set of properties.- Parameters:
reg
- the service registration whose service properties will be compared to the props parameterprops
- the properties to be compared with the registration service properties.- Returns:
true
if the registration service properties equals the prop properties, false if not.
-
getService
public S getService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration<S> serviceRegistration)
- Specified by:
getService
in interfaceorg.osgi.framework.ServiceFactory<S>
-
getServiceInternal
boolean getServiceInternal(org.osgi.framework.ServiceRegistration<S> serviceRegistration)
- Overrides:
getServiceInternal
in classAbstractComponentManager<S>
-
getService
private S getService(ComponentContextImpl<S> componentContext)
-
ungetService
public void ungetService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration<S> serviceRegistration, S o)
- Specified by:
ungetService
in interfaceorg.osgi.framework.ServiceFactory<S>
-
keepInstances
private boolean keepInstances()
-
getComponentManagers
public void getComponentManagers(java.util.List<AbstractComponentManager<S>> cms)
- Specified by:
getComponentManagers
in classAbstractComponentManager<S>
-
-