org.apache.felix.dm.runtime
Class FactorySet
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<Dictionary>
org.apache.felix.dm.runtime.FactorySet
- All Implemented Interfaces:
- Iterable<Dictionary>, Collection<Dictionary>, Set<Dictionary>
public class FactorySet
- extends AbstractSet<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.
Method Summary |
boolean |
add(Dictionary configuration)
Create or Update a Service. |
void |
clear()
Another Service wants to remove all existing Services. |
Iterator<Dictionary> |
iterator()
returns the list of active Service instances configurations. |
boolean |
remove(Object configuration)
Another Service wants to remove an existing Service. |
int |
size()
Returns the number of active Service instances. |
void |
start()
Our Service is starting. |
void |
stop()
Our Service is stopping: we have to remove all Service instances that we have created. |
String |
toString()
|
FactorySet
public FactorySet(Bundle b,
MetaData srvMeta,
List<MetaData> depsMeta)
- 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.
start
public void start()
- Our Service is starting.
stop
public void stop()
- Our Service is stopping: we have to remove all Service instances that we have created.
add
public boolean add(Dictionary configuration)
- Create or Update a Service.
- Specified by:
add
in interface Collection<Dictionary>
- Specified by:
add
in interface Set<Dictionary>
- Overrides:
add
in class AbstractCollection<Dictionary>
remove
public boolean remove(Object configuration)
- 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:
remove
in interface Collection<Dictionary>
- Specified by:
remove
in interface Set<Dictionary>
- Overrides:
remove
in class AbstractCollection<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:
clear
in interface Collection<Dictionary>
- Specified by:
clear
in interface Set<Dictionary>
- Overrides:
clear
in class AbstractCollection<Dictionary>
iterator
public Iterator<Dictionary> iterator()
- returns the list of active Service instances configurations.
- Specified by:
iterator
in interface Iterable<Dictionary>
- Specified by:
iterator
in interface Collection<Dictionary>
- Specified by:
iterator
in interface Set<Dictionary>
- Specified by:
iterator
in class AbstractCollection<Dictionary>
toString
public String toString()
- Overrides:
toString
in class AbstractCollection<Dictionary>
size
public int size()
- Returns the number of active Service instances.
- Specified by:
size
in interface Collection<Dictionary>
- Specified by:
size
in interface Set<Dictionary>
- Specified by:
size
in class AbstractCollection<Dictionary>
Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.