Package org.apache.felix.dm.runtime
Class FactorySet
- All Implemented Interfaces:
Iterable<Dictionary>,Collection<Dictionary>,Set<Dictionary>
This class implements a
java.util.Set which acts as a service factory.
When a Service contains a factory attribute, this class is provided
into the OSGi registry with a dm.factory.name service property. So, another factory component
may be injected with this Set. And each time a Dictionary configuration is registered in the Set,
then a new Service instance will be instantiated, and will be provided with the Dictionary passed to the
Service instance.- Author:
- Felix Project Team
-
Constructor Summary
ConstructorsConstructorDescriptionFactorySet(org.osgi.framework.Bundle b, MetaData srvMeta, List<MetaData> depsMeta) Sole constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(Dictionary configuration) Create or Update a Service.voidclear()Another Service wants to remove all existing Services.iterator()returns the list of active Service instances configurations.booleanAnother Service wants to remove an existing Service.intsize()Returns the number of active Service instances.voidstart(org.apache.felix.dm.Component c) Our Service is starting.voidstop()Our Service is stopping: we have to remove all Service instances that we have created.toString()Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
addAll, contains, containsAll, isEmpty, retainAll, spliterator, toArray, toArray
-
Constructor Details
-
FactorySet
Sole constructor.- Parameters:
b- the bundle containing the Service annotated with the factory attributeimpl- The Service implementation classserviceProperties- The Service propertiesprovides- The Services provided by this ServicefactoryConfigure- The configure callback invoked in order to pass configurations added in this Set.
-
-
Method Details
-
start
public void start(org.apache.felix.dm.Component c) Our Service is starting. -
stop
public void stop()Our Service is stopping: we have to remove all Service instances that we have created. -
add
Create or Update a Service.- Specified by:
addin interfaceCollection<Dictionary>- Specified by:
addin interfaceSet<Dictionary>- Overrides:
addin classAbstractCollection<Dictionary>
-
remove
Another Service wants to remove an existing Service. This method is not synchronized but uses a SerialExecutor for serializing concurrent method call. (This avoid potential dead locks, especially when Service callback methods are invoked).- Specified by:
removein interfaceCollection<Dictionary>- Specified by:
removein interfaceSet<Dictionary>- Overrides:
removein classAbstractCollection<Dictionary>
-
clear
public void clear()Another Service wants to remove all existing Services. This method is not synchronized but uses a SerialExecutor for serializing concurrent method call. (This avoid potential dead locks, especially when Service callback methods are invoked).- Specified by:
clearin interfaceCollection<Dictionary>- Specified by:
clearin interfaceSet<Dictionary>- Overrides:
clearin classAbstractCollection<Dictionary>
-
iterator
returns the list of active Service instances configurations.- Specified by:
iteratorin interfaceCollection<Dictionary>- Specified by:
iteratorin interfaceIterable<Dictionary>- Specified by:
iteratorin interfaceSet<Dictionary>- Specified by:
iteratorin classAbstractCollection<Dictionary>
-
toString
- Overrides:
toStringin classAbstractCollection<Dictionary>
-
size
public int size()Returns the number of active Service instances.- Specified by:
sizein interfaceCollection<Dictionary>- Specified by:
sizein interfaceSet<Dictionary>- Specified by:
sizein classAbstractCollection<Dictionary>
-