public class ComponentFactoryImpl<S> extends AbstractComponentManager<S> implements org.osgi.service.component.ComponentFactory, ComponentContainer<S>
ComponentFactoryImpl extends the AbstractComponentManager
class to implement the component factory functionality. As such the
OSGi Declarative Services ComponentFactory interface is
implemented.
In addition the ComponentHolder interface is implemented to use this
class directly as the holder for component instances created by the
newInstance(Dictionary) method.
This class implements spec-compliant component factories and the felix "persistent" component factory, where the factory is always registered whether or not all dependencies are present and the created components also persist whether or not the dependencies are present to allow the component instance to exist.
| Modifier and Type | Class and Description |
|---|---|
private static class |
ComponentFactoryImpl.ModifyComponentInstance<S> |
AbstractComponentManager.State| Modifier and Type | Field and Description |
|---|---|
protected long |
m_changeCount
Configuration change count (R5) or imitation (R4)
|
private java.util.Map<SingleComponentManager<S>,SingleComponentManager<S>> |
m_componentInstances
Contains the component instances created by calling the
newInstance(Dictionary) method. |
private java.util.Map<java.lang.String,java.lang.Object> |
m_configuration
The configuration for the component factory.
|
private boolean |
m_hasConfiguration
Flag telling if our component factory is currently configured from config admin.
|
protected TargetedPID |
m_targetedPID |
m_activationLock, m_container, m_factoryInstance, REASONSSTATE_ACTIVE, STATE_DISABLED, STATE_DISPOSED, STATE_SATISFIED, STATE_UNSATISFIED_CONFIGURATION, STATE_UNSATISFIED_REFERENCE| Constructor and Description |
|---|
ComponentFactoryImpl(ComponentContainer<S> container,
ComponentMethods componentMethods) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
collectDependencies(ComponentContextImpl<S> componentContext)
Collect and store in m_dependencies_map all the services for dependencies, outside of any locks.
|
private SingleComponentManager<S> |
createComponentManager()
Creates an
SingleComponentManager instance with the
BundleComponentActivator and ComponentMetadata of this
instance. |
protected void |
deleteComponent(int reason)
The component factory does not have a component to delete.
|
void |
dispose(int reason)
Disposes off all components ever created by this component holder.
|
void |
disposed(SingleComponentManager<S> component)
Informs the holder that the component has been disposed as a result of
calling the dispose method.
|
boolean |
equals(java.lang.Object object)
Compares this
ComponentFactoryImpl object to another object. |
org.osgi.service.component.ComponentInstance |
getComponentInstance() |
void |
getComponentManagers(java.util.List<AbstractComponentManager<S>> cms) |
protected void |
getComponentManagers(java.util.Map<?,SingleComponentManager<S>> componentMap,
java.util.List<AbstractComponentManager<S>> componentManagers) |
TargetedPID |
getConfigurationTargetedPID(TargetedPID pid,
TargetedPID factoryPid) |
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
For ComponentFactoryImpl, this is used only for updating targets on the dependency managers, so we don't need any other
properties.
|
protected java.lang.String[] |
getProvidedServices() |
java.util.Dictionary<java.lang.String,java.lang.Object> |
getServiceProperties()
Returns the subset of component properties to be used as service
properties.
|
boolean |
hasConfiguration() |
int |
hashCode()
Returns a hash code value for the object.
|
(package private) boolean |
hasInstance() |
(package private) <T> void |
invokeBindMethod(DependencyManager<S,T> dependencyManager,
RefPair<S,T> reference,
int trackingCount) |
(package private) <T> void |
invokeUnbindMethod(DependencyManager<S,T> dependencyManager,
RefPair<S,T> oldRef,
int trackingCount) |
(package private) <T> boolean |
invokeUpdatedMethod(DependencyManager<S,T> dependencyManager,
RefPair<S,T> ref,
int trackingCount)
Invoke updated method
|
boolean |
isFactory() |
org.osgi.service.component.ComponentInstance |
newInstance(java.util.Dictionary<java.lang.String,?> dictionary) |
(package private) void |
postRegister() |
(package private) void |
preDeregister() |
void |
reconfigure(java.util.Map<java.lang.String,java.lang.Object> configuration,
boolean configurationDeleted,
TargetedPID factoryPid) |
void |
setServiceProperties(java.util.Dictionary<java.lang.String,?> serviceProperties) |
protected boolean |
verifyDependencyManagers() |
activateInternal, clear, copyTo, copyToDictionary, copyToMap, deactivateInternal, disable, disableInternal, dispose, dumpThreads, enable, enableInternal, enableLatchWait, getActivator, getBundle, getBundleContext, getComponentMetadata, getComponentMethods, getDependencyManager, getDependencyManagers, getId, getLockTimeout, getName, getReferenceManagers, getReversedDependencyManagers, getServiceInternal, getSpecState, getState, getTrackingCount, isActivatorActive, isImmediate, isLogEnabled, isStateLocked, log, log, obtainActivationReadLock, obtainActivationWriteLock, obtainStateLock, registerComponentId, registerMissingDependency, registerService, releaseActivationReadLock, releaseActivationWriteeLock, releaseStateLock, setServiceProperties, setState, toString, tracked, unregisterComponentId, unregisterService, updateTargets, waitForTrackedclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetActivator, getComponentMetadataprivate final java.util.Map<SingleComponentManager<S>,SingleComponentManager<S>> m_componentInstances
newInstance(Dictionary) method. These component instances are
provided with updated configuration (or deleted configuration) if
such modifications for the component factory takes place.
The map is keyed by the component manager instances. The value of each entry is the same as the entry's key. This is an IdentityHashMap for speed, thus not a Set.
private volatile java.util.Map<java.lang.String,java.lang.Object> m_configuration
newInstance(Dictionary) method.private volatile boolean m_hasConfiguration
protected volatile long m_changeCount
protected TargetedPID m_targetedPID
public ComponentFactoryImpl(ComponentContainer<S> container, ComponentMethods componentMethods)
protected boolean verifyDependencyManagers()
verifyDependencyManagers in class AbstractComponentManager<S>public boolean isFactory()
isFactory in class AbstractComponentManager<S>public org.osgi.service.component.ComponentInstance newInstance(java.util.Dictionary<java.lang.String,?> dictionary)
newInstance in interface org.osgi.service.component.ComponentFactorypublic boolean equals(java.lang.Object object)
ComponentFactoryImpl object to another object.
A component factory impl is considered to be equal to another component
factory impl if the component names are equal(using String.equals).
equals in class java.lang.Objectobject - The ComponentFactoryImpl object to be compared.true if object is a
ComponentFactoryImpl and is equal to this object;
false otherwise.public int hashCode()
hashCode in class java.lang.Objectprotected void deleteComponent(int reason)
But in the backwards compatible case any instances created for factory configuration instances are to disabled as a consequence of deactivating the component factory.
deleteComponent in class AbstractComponentManager<S>protected java.lang.String[] getProvidedServices()
getProvidedServices in class AbstractComponentManager<S>public boolean hasConfiguration()
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
getProperties in interface ComponentManager<S>getProperties in class AbstractComponentManager<S>public void setServiceProperties(java.util.Dictionary<java.lang.String,?> serviceProperties)
setServiceProperties in class AbstractComponentManager<S>void postRegister()
postRegister in class AbstractComponentManager<S>void preDeregister()
preDeregister in class AbstractComponentManager<S>public java.util.Dictionary<java.lang.String,java.lang.Object> getServiceProperties()
AbstractComponentManagergetServiceProperties in class AbstractComponentManager<S>boolean hasInstance()
hasInstance in class AbstractComponentManager<S>protected boolean collectDependencies(ComponentContextImpl<S> componentContext)
AbstractComponentManagercollectDependencies in class AbstractComponentManager<S>componentContext - possible instance key for prototype scope references<T> boolean invokeUpdatedMethod(DependencyManager<S,T> dependencyManager, RefPair<S,T> ref, int trackingCount)
AbstractComponentManagerinvokeUpdatedMethod in class AbstractComponentManager<S>true if the component needs reactivation, false otherwise.<T> void invokeBindMethod(DependencyManager<S,T> dependencyManager, RefPair<S,T> reference, int trackingCount)
invokeBindMethod in class AbstractComponentManager<S><T> void invokeUnbindMethod(DependencyManager<S,T> dependencyManager, RefPair<S,T> oldRef, int trackingCount)
invokeUnbindMethod in class AbstractComponentManager<S>public org.osgi.service.component.ComponentInstance getComponentInstance()
public void dispose(int reason)
dispose in class AbstractComponentManager<S>public void disposed(SingleComponentManager<S> component)
ComponentContainerdisposed in interface ComponentContainer<S>private SingleComponentManager<S> createComponentManager()
SingleComponentManager instance with the
BundleComponentActivator and ComponentMetadata of this
instance. The component manager is kept in the internal set of created
components. The component is neither configured nor enabled.protected void getComponentManagers(java.util.Map<?,SingleComponentManager<S>> componentMap, java.util.List<AbstractComponentManager<S>> componentManagers)
public TargetedPID getConfigurationTargetedPID(TargetedPID pid, TargetedPID factoryPid)
public void reconfigure(java.util.Map<java.lang.String,java.lang.Object> configuration,
boolean configurationDeleted,
TargetedPID factoryPid)
reconfigure in class AbstractComponentManager<S>public void getComponentManagers(java.util.List<AbstractComponentManager<S>> cms)
getComponentManagers in class AbstractComponentManager<S>