org.apache.felix.dm.runtime
Class FactorySet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<Dictionary>
          extended by 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.


Constructor Summary
FactorySet(Bundle b, MetaData srvMeta, List<MetaData> depsMeta)
          Sole constructor.
 
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()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArray
 

Constructor Detail

FactorySet

public FactorySet(Bundle b,
                  MetaData srvMeta,
                  List<MetaData> depsMeta)
Sole constructor.

Parameters:
b - the bundle containing the Service annotated with the factory attribute
impl - The Service implementation class
serviceProperties - The Service properties
provides - The Services provided by this Service
factoryConfigure - The configure callback invoked in order to pass configurations added in this Set.
Method Detail

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.