net.sf.taverna.t2.spi
Class SPIRegistry<SPI>

java.lang.Object
  extended by net.sf.taverna.t2.spi.SPIRegistry<SPI>
Type Parameters:
SPI - The interface type that the SPI classes implement
All Implemented Interfaces:
Observable<SPIRegistry.SPIRegistryEvent>
Direct Known Subclasses:
BeanableFactoryRegistry

public class SPIRegistry<SPI>
extends java.lang.Object
implements Observable<SPIRegistry.SPIRegistryEvent>

Simple SPI lookup (using META-INF/services/interfaceName) to discover run-time class implementations. Subclass or instantiate with given interface to use the SPI lookup. This is based upon the InstanceRegistry and SpiRegistry in Raven.

Author:
Stuart Owen, Stian Soiland

Nested Class Summary
 class SPIRegistry.RegistryListenerAdapter
           
static class SPIRegistry.SPIRegistryEvent
           
 
Field Summary
static SPIRegistry.SPIRegistryEvent UPDATED
          Sent to Observer<SPIRegistry.SPIRegistryEvent>s when this SPI registry has been updated.
 
Constructor Summary
SPIRegistry(java.lang.Class<SPI> spi)
          Construct the SPI for the given interface.
 
Method Summary
 void addObserver(Observer<SPIRegistry.SPIRegistryEvent> observer)
          Register an Observer
 java.util.List<SPI> getInstances()
          Get all discovered instances.
 java.util.List<Observer<SPIRegistry.SPIRegistryEvent>> getObservers()
          A list of all the currently registered Observers
 java.lang.Class<SPI> getSpi()
          Get the SPI instances found by this registry will be implementing.
 void refresh()
          Reset the instanceRegistry causing it to be re-populated on the next call to getInstances.
 void removeObserver(Observer<SPIRegistry.SPIRegistryEvent> observer)
          Remove a class who is currently observing
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPDATED

public static final SPIRegistry.SPIRegistryEvent UPDATED
Sent to Observer<SPIRegistry.SPIRegistryEvent>s when this SPI registry has been updated.

Constructor Detail

SPIRegistry

public SPIRegistry(java.lang.Class<SPI> spi)
Construct the SPI for the given interface.

Parameters:
spi - Interface to discover
Method Detail

addObserver

public void addObserver(Observer<SPIRegistry.SPIRegistryEvent> observer)
Description copied from interface: Observable
Register an Observer

Specified by:
addObserver in interface Observable<SPIRegistry.SPIRegistryEvent>
Parameters:
observer - the class who wants notified of changes

getInstances

public java.util.List<SPI> getInstances()
Get all discovered instances.

Returns:
a List of instances of the classes discovered by the registry

getObservers

public java.util.List<Observer<SPIRegistry.SPIRegistryEvent>> getObservers()
Description copied from interface: Observable
A list of all the currently registered Observers

Specified by:
getObservers in interface Observable<SPIRegistry.SPIRegistryEvent>
Returns:

getSpi

public java.lang.Class<SPI> getSpi()
Get the SPI instances found by this registry will be implementing.

Returns:
The Class of the SPI interface

refresh

public void refresh()
Reset the instanceRegistry causing it to be re-populated on the next call to getInstances.


removeObserver

public void removeObserver(Observer<SPIRegistry.SPIRegistryEvent> observer)
Description copied from interface: Observable
Remove a class who is currently observing

Specified by:
removeObserver in interface Observable<SPIRegistry.SPIRegistryEvent>
Parameters:
observer - the class who no longer wants notified