Class ComponentFactoryImpl<S>
- All Implemented Interfaces:
ComponentContainer<S>, ComponentManager<S>, org.osgi.service.component.ComponentFactory<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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classNested classes/interfaces inherited from class AbstractComponentManager
AbstractComponentManager.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longConfiguration change count (R5) or imitation (R4)private final Map<SingleComponentManager<S>, SingleComponentManager<S>> Contains the component instances created by calling thenewInstance(Dictionary)method.The configuration for the component factory.private booleanFlag telling if our component factory is currently configured from config admin.protected TargetedPIDFields inherited from class AbstractComponentManager
m_activationLock, m_container, m_factoryInstance, REASONS, registrationManagerFields inherited from interface ComponentManager
STATE_ACTIVE, STATE_DISPOSED, STATE_SATISFIED, STATE_UNSATISFIED_CONFIGURATION, STATE_UNSATISFIED_REFERENCE -
Constructor Summary
ConstructorsConstructorDescriptionComponentFactoryImpl(ComponentContainer<S> container, ComponentMethods componentMethods) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancollectDependencies(ComponentContextImpl<S> componentContext) Collect and store in m_dependencies_map all the services for dependencies, outside of any locks.private SingleComponentManager<S> Creates anSingleComponentManagerinstance with theBundleComponentActivatorandComponentMetadataof this instance.protected voiddeleteComponent(int reason) The component factory does not have a component to delete.voiddispose(int reason) Disposes off all components ever created by this component holder.voiddisposed(SingleComponentManager<S> component) Informs the holder that the component has been disposed as a result of calling the dispose method.booleanCompares thisComponentFactoryImplobject to another object.voidprotected voidgetComponentManagers(Map<?, SingleComponentManager<S>> componentMap, List<AbstractComponentManager<S>> componentManagers) getConfigurationTargetedPID(TargetedPID pid, TargetedPID factoryPid) For ComponentFactoryImpl, this is used only for updating targets on the dependency managers, so we don't need any other properties.protected String[]Returns the subset of component properties to be used as service properties.booleaninthashCode()Returns a hash code value for the object.(package private) <T> voidinvokeBindMethod(DependencyManager<S, T> dependencyManager, RefPair<S, T> reference, int trackingCount) (package private) <T> voidinvokeUnbindMethod(DependencyManager<S, T> dependencyManager, RefPair<S, T> oldRef, int trackingCount) (package private) <T> booleaninvokeUpdatedMethod(DependencyManager<S, T> dependencyManager, RefPair<S, T> ref, int trackingCount) Invoke updated methodbooleanorg.osgi.service.component.ComponentInstance<S> newInstance(Dictionary<String, ?> dictionary) (package private) void(package private) voidvoidreconfigure(Map<String, Object> configuration, boolean configurationDeleted, TargetedPID factoryPid) voidsetServiceProperties(Dictionary<String, ?> serviceProperties) protected booleanMethods inherited from class AbstractComponentManager
activateInternal, clear, copyTo, copyToDictionary, copyToMap, deactivateInternal, disable, disableInternal, dispose, dumpThreads, enable, enableInternal, enableLatchWait, getActivator, getBundle, getBundleContext, getComponentMetadata, getComponentMethods, getDependencyManager, getDependencyManagers, getFailureReason, getId, getLockTimeout, getLogger, getReferenceManagers, getRegisteredServiceReference, getReversedDependencyManagers, getServiceInternal, getServiceRegistration, getSpecState, getState, getTrackingCount, isImmediate, isStateLocked, notifyWaiters, obtainActivationReadLock, obtainActivationWriteLock, obtainStateLock, registerComponentId, registerMissingDependency, registerService, releaseActivationReadLock, releaseActivationWriteeLock, releaseStateLock, setFailureReason, setServiceProperties, setState, toString, tracked, unregisterComponentId, unregisterService, updateTargets, waitForTrackedMethods inherited from interface ComponentContainer
getActivator, getComponentMetadata, getLogger
-
Field Details
-
m_componentInstances
Contains the component instances created by calling thenewInstance(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.
-
m_configuration
The configuration for the component factory. This configuration is supplied as the base configuration for each component instance created by thenewInstance(Dictionary)method. -
m_hasConfiguration
private volatile boolean m_hasConfigurationFlag telling if our component factory is currently configured from config admin. We are configured when configuration policy is required and we have received the config admin properties, or when configuration policy is optional or ignored. -
m_changeCount
protected volatile long m_changeCountConfiguration change count (R5) or imitation (R4) -
m_targetedPID
-
-
Constructor Details
-
ComponentFactoryImpl
-
-
Method Details
-
verifyDependencyManagers
protected boolean verifyDependencyManagers()- Overrides:
verifyDependencyManagersin classAbstractComponentManager<S>
-
isFactory
public boolean isFactory()- Overrides:
isFactoryin classAbstractComponentManager<S>
-
newInstance
- Specified by:
newInstancein interfaceorg.osgi.service.component.ComponentFactory<S>
-
equals
Compares thisComponentFactoryImplobject 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). -
hashCode
-
deleteComponent
protected void deleteComponent(int reason) The component factory does not have a component to delete.But in the backwards compatible case any instances created for factory configuration instances are to disabled as a consequence of deactivating the component factory.
- Specified by:
deleteComponentin classAbstractComponentManager<S>
-
getProvidedServices
- Overrides:
getProvidedServicesin classAbstractComponentManager<S>
-
hasConfiguration
public boolean hasConfiguration() -
getProperties
For ComponentFactoryImpl, this is used only for updating targets on the dependency managers, so we don't need any other properties.- Specified by:
getPropertiesin interfaceComponentManager<S>- Specified by:
getPropertiesin classAbstractComponentManager<S>
-
setServiceProperties
- Specified by:
setServicePropertiesin classAbstractComponentManager<S>
-
postRegister
void postRegister()- Specified by:
postRegisterin classAbstractComponentManager<S>
-
preDeregister
void preDeregister()- Specified by:
preDeregisterin classAbstractComponentManager<S>
-
getServiceProperties
Description copied from class:AbstractComponentManagerReturns 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:
getServicePropertiesin classAbstractComponentManager<S>
-
collectDependencies
Description copied from class:AbstractComponentManagerCollect and store in m_dependencies_map all the services for dependencies, outside of any locks.- Overrides:
collectDependenciesin classAbstractComponentManager<S>- 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.
-
invokeUpdatedMethod
<T> boolean invokeUpdatedMethod(DependencyManager<S, T> dependencyManager, RefPair<S, T> ref, int trackingCount) Description copied from class:AbstractComponentManagerInvoke updated method- Specified by:
invokeUpdatedMethodin classAbstractComponentManager<S>- Returns:
trueif the component needs reactivation,falseotherwise.
-
invokeBindMethod
<T> void invokeBindMethod(DependencyManager<S, T> dependencyManager, RefPair<S, T> reference, int trackingCount) - Specified by:
invokeBindMethodin classAbstractComponentManager<S>
-
invokeUnbindMethod
<T> void invokeUnbindMethod(DependencyManager<S, T> dependencyManager, RefPair<S, T> oldRef, int trackingCount) - Specified by:
invokeUnbindMethodin classAbstractComponentManager<S>
-
dispose
public void dispose(int reason) Disposes off all components ever created by this component holder. This method is called if either the Declarative Services runtime is stopping or if the owning bundle is stopped. In both cases all components created by this holder must be disposed off.- Overrides:
disposein classAbstractComponentManager<S>
-
disposed
Description copied from interface:ComponentContainerInforms the holder that the component has been disposed as a result of calling the dispose method.- Specified by:
disposedin interfaceComponentContainer<S>
-
createComponentManager
Creates anSingleComponentManagerinstance with theBundleComponentActivatorandComponentMetadataof this instance. The component manager is kept in the internal set of created components. The component is neither configured nor enabled. -
getComponentManagers
protected void getComponentManagers(Map<?, SingleComponentManager<S>> componentMap, List<AbstractComponentManager<S>> componentManagers) -
getConfigurationTargetedPID
-
reconfigure
public void reconfigure(Map<String, Object> configuration, boolean configurationDeleted, TargetedPID factoryPid) - Specified by:
reconfigurein classAbstractComponentManager<S>
-
getComponentManagers
- Specified by:
getComponentManagersin classAbstractComponentManager<S>
-