org.eclipse.gemini.blueprint.service.importer.support.internal.collection
Class OsgiServiceCollection

java.lang.Object
  extended by org.eclipse.gemini.blueprint.service.importer.support.internal.collection.OsgiServiceCollection
All Implemented Interfaces:
Iterable, Collection, CollectionProxy, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
OsgiServiceList, OsgiServiceSet

public class OsgiServiceCollection
extends Object
implements Collection, org.springframework.beans.factory.InitializingBean, CollectionProxy, org.springframework.beans.factory.DisposableBean

OSGi service dynamic collection - allows iterating while the underlying storage is being shrunk/expanded. This collection is read-only - its content is being retrieved dynamically from the OSGi platform.

This collection and its iterators are thread-safe. That is, multiple threads can access the collection. However, since the collection is read-only, it cannot be modified by the client.

Author:
Costin Leau
See Also:
Collection

Nested Class Summary
protected  class OsgiServiceCollection.OsgiServiceIterator
          Read-only iterator wrapper around the dynamic collection iterator.
 
Field Summary
protected  DynamicCollection<Object> services
          The dynamic collection.
protected  Map<Long,ProxyPlusCallback> servicesIdMap
           
 
Constructor Summary
OsgiServiceCollection(org.osgi.framework.Filter filter, org.osgi.framework.BundleContext context, ClassLoader classLoader, ServiceProxyCreator proxyCreator, boolean useServiceReference)
           
 
Method Summary
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 void afterPropertiesSet()
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection c)
           
protected  DynamicCollection<Object> createInternalDynamicStorage()
          Create the dynamic storage used internally.
 void destroy()
           
 boolean isEmpty()
           
 boolean isSatisfied()
          Is the underlying proxy satisfied? For dynamic, mandatory imports, this checks the service reference.
 Iterator<Object> iterator()
           
protected  void mandatoryServiceCheck()
          Check to see whether at least one service is available.
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 boolean retainAll(Collection c)
           
 void setListeners(OsgiServiceLifecycleListener[] listeners)
           
 void setRequiredAtStartup(boolean serviceRequiredAtStartup)
           
 void setServiceImporter(Object importer)
           
 void setServiceImporterName(String name)
           
 void setStateListeners(List<ImporterStateListener> stateListeners)
           
 void setUseBlueprintExceptions(boolean useBlueprintExceptions)
           
 int size()
           
 Object[] toArray()
           
 Object[] toArray(Object[] array)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

servicesIdMap

protected final Map<Long,ProxyPlusCallback> servicesIdMap

services

protected DynamicCollection<Object> services
The dynamic collection.

Constructor Detail

OsgiServiceCollection

public OsgiServiceCollection(org.osgi.framework.Filter filter,
                             org.osgi.framework.BundleContext context,
                             ClassLoader classLoader,
                             ServiceProxyCreator proxyCreator,
                             boolean useServiceReference)
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

destroy

public void destroy()
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean

mandatoryServiceCheck

protected void mandatoryServiceCheck()
Check to see whether at least one service is available.


isSatisfied

public boolean isSatisfied()
Description copied from interface: CollectionProxy
Is the underlying proxy satisfied? For dynamic, mandatory imports, this checks the service reference. For optional imports, it always returns true.

Specified by:
isSatisfied in interface CollectionProxy
Returns:

createInternalDynamicStorage

protected DynamicCollection<Object> createInternalDynamicStorage()
Create the dynamic storage used internally. The storage has to be thread-safe.


setServiceImporter

public void setServiceImporter(Object importer)

setServiceImporterName

public void setServiceImporterName(String name)

iterator

public Iterator<Object> iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection

size

public int size()
Specified by:
size in interface Collection

toString

public String toString()
Overrides:
toString in class Object

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection

add

public boolean add(Object o)
Specified by:
add in interface Collection

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection

clear

public void clear()
Specified by:
clear in interface Collection

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Collection

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection

toArray

public Object[] toArray(Object[] array)
Specified by:
toArray in interface Collection

setListeners

public void setListeners(OsgiServiceLifecycleListener[] listeners)
Parameters:
listeners - The listeners to set.

setRequiredAtStartup

public void setRequiredAtStartup(boolean serviceRequiredAtStartup)

setStateListeners

public void setStateListeners(List<ImporterStateListener> stateListeners)

setUseBlueprintExceptions

public void setUseBlueprintExceptions(boolean useBlueprintExceptions)


Copyright © 2006-2013. All Rights Reserved.