org.apache.felix.ipojo.handler.temporal
Class ServiceCollection

java.lang.Object
  extended by org.apache.felix.ipojo.handler.temporal.ServiceCollection
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection

public class ServiceCollection
extends java.lang.Object
implements java.util.Collection

Maintains a service object collection. This collection wrap the temporal dependency to be accessible from a Collection, that can be passed to helper objects (Collaborators). The onTimeout policies are executed when the Collection.iterator(), Collection.toArray(Object[]) and Collection.toArray() methods are called. The Collection.iterator() method returns an ServiceCollection.ServiceIterator iterating on a cached copy of available service objects. In the case that there are no available services when the timeout is reached, the policies act as follows:

Author:
Felix Project Team

Nested Class Summary
private  class ServiceCollection.ServiceIterator
          Iterator on a set of service objects.
 
Field Summary
private  TemporalDependency m_dependency
          The wrapped temporal dependencies.
 
Constructor Summary
ServiceCollection(TemporalDependency dep)
          Creates a Service Collection.
 
Method Summary
 boolean add(java.lang.Object o)
          Unsupported method.
 boolean addAll(java.util.Collection c)
          Unsupported method.
 void clear()
          Unsupported method.
 boolean contains(java.lang.Object o)
          Checks if the wrapped temporal dependencies has always access to the given service object.The method allows knowing if the provider returning the service object has leaved.
 boolean containsAll(java.util.Collection c)
          Checks if the wrapped temporal dependencies has always access to the given service objects.The method allows knowing if providers returning the service objects have leaved.
private  java.util.List getAvailableObjects()
          Helper method creating a list of available service objects.
 boolean isEmpty()
          Checks if at least one provider matching with the dependency is available.
 java.util.Iterator iterator()
          Gets an iterator on the actual list of available service objects.
 boolean remove(java.lang.Object o)
          Unsupported method.
 boolean removeAll(java.util.Collection c)
          Unsupported method.
 boolean retainAll(java.util.Collection c)
          Unsupported method.
 int size()
          Gets the number of available providers.
 java.lang.Object[] toArray()
          Returns an array containing available service objects.
 java.lang.Object[] toArray(java.lang.Object[] a)
          Returns an array containing available service objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

m_dependency

private TemporalDependency m_dependency
The wrapped temporal dependencies.

Constructor Detail

ServiceCollection

public ServiceCollection(TemporalDependency dep)
Creates a Service Collection.

Parameters:
dep - the wrapped temporal dependencies
Method Detail

add

public boolean add(java.lang.Object o)
Unsupported method.

Specified by:
add in interface java.util.Collection
Parameters:
o - an object
Returns:
N/A
See Also:
Collection.add(java.lang.Object)

addAll

public boolean addAll(java.util.Collection c)
Unsupported method.

Specified by:
addAll in interface java.util.Collection
Parameters:
c - an object
Returns:
N/A
See Also:
Collection.addAll(java.util.Collection)

clear

public void clear()
Unsupported method.

Specified by:
clear in interface java.util.Collection
See Also:
Collection.clear()

contains

public boolean contains(java.lang.Object o)
Checks if the wrapped temporal dependencies has always access to the given service object.The method allows knowing if the provider returning the service object has leaved.

Specified by:
contains in interface java.util.Collection
Parameters:
o - the service object
Returns:
true if the object is still available, false otherwise.
See Also:
Collection.contains(java.lang.Object)

containsAll

public boolean containsAll(java.util.Collection c)
Checks if the wrapped temporal dependencies has always access to the given service objects.The method allows knowing if providers returning the service objects have leaved.

Specified by:
containsAll in interface java.util.Collection
Parameters:
c - the set of service object
Returns:
true if the objects are still available, false otherwise.
See Also:
Collection.contains(java.lang.Object)

isEmpty

public boolean isEmpty()
Checks if at least one provider matching with the dependency is available.

Specified by:
isEmpty in interface java.util.Collection
Returns:
true if one provider or more satisfying the dependency are available. Otherwise, returns false
See Also:
Collection.isEmpty()

getAvailableObjects

private java.util.List getAvailableObjects()
Helper method creating a list of available service objects.

Returns:
the list of available service objects.

iterator

public java.util.Iterator iterator()
Gets an iterator on the actual list of available service objects. This method applies on timeout policies is no services are available after the timeout. The returned iterator iterates on a cached copy of the service objects.

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Returns:
a iterator giving access to service objects.
See Also:
Collection.iterator()

remove

public boolean remove(java.lang.Object o)
Unsupported method.

Specified by:
remove in interface java.util.Collection
Parameters:
o - a object
Returns:
N/A
See Also:
Collection.remove(java.lang.Object)

removeAll

public boolean removeAll(java.util.Collection c)
Unsupported method.

Specified by:
removeAll in interface java.util.Collection
Parameters:
c - a set of objects
Returns:
N/A
See Also:
Collection.removeAll(java.util.Collection)

retainAll

public boolean retainAll(java.util.Collection c)
Unsupported method.

Specified by:
retainAll in interface java.util.Collection
Parameters:
c - a set of objects
Returns:
N/A
See Also:
Collection.retainAll(java.util.Collection)

size

public int size()
Gets the number of available providers.

Specified by:
size in interface java.util.Collection
Returns:
the number of matching service providers.
See Also:
Collection.size()

toArray

public java.lang.Object[] toArray()
Returns an array containing available service objects. This method executed on timeout policies if no matching providers when the timeout is reached.

Specified by:
toArray in interface java.util.Collection
Returns:
a array containing available service objects. depending on the timeout policy, this array can also be null, be empty, or can contain only one element (a default-implementation object, or a nullable object).
See Also:
Collection.toArray()

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Returns an array containing available service objects. This method executed on timeout policies if no matching providers when the timeout is reached.

Specified by:
toArray in interface java.util.Collection
Parameters:
a - the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
a array containing available service objects. depending on the timeout policy, this array can also be null, be empty, or can contain only one element (a default-implementation object, or a nullable object).
See Also:
Collection.toArray(java.lang.Object[])


Copyright © 2006-2010 The Apache Software Foundation. All Rights Reserved.