org.ops4j.peaberry.util
Class AbstractWatcher<S>

java.lang.Object
  extended by org.ops4j.peaberry.util.AbstractWatcher<S>
All Implemented Interfaces:
ServiceWatcher<S>

public abstract class AbstractWatcher<S>
extends Object
implements ServiceWatcher<S>

Skeletal implementation to simplify development of ServiceWatchers.

Developers only have to extend this class and provide implementations of the adding(Import), modified(Object, Map), and removed(S) service tracking methods. The design of this helper class is loosely based on the OSGi ServiceTrackerCustomizer.

Since:
1.1
Author:
mcculls@gmail.com (Stuart McCulloch)

Constructor Summary
AbstractWatcher()
           
 
Method Summary
<T extends S>
Export<T>
add(Import<T> service)
          Add the given service to this watcher.
protected  S adding(Import<S> service)
          Notification that a service has been added to this watcher.
protected  void modified(S instance, Map<String,?> attributes)
          Notification that some service attributes have been modified.
protected  void removed(S instance)
          Notification that a service has been removed from this watcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractWatcher

public AbstractWatcher()
Method Detail

add

public final <T extends S> Export<T> add(Import<T> service)
Description copied from interface: ServiceWatcher
Add the given service to this watcher.

Specified by:
add in interface ServiceWatcher<S>
Parameters:
service - imported service handle
Returns:
exported service handle, null if the watcher is not interested

adding

protected S adding(Import<S> service)
Notification that a service has been added to this watcher.

Parameters:
service - new service handle
Returns:
tracking instance, null if the service shouldn't be tracked

modified

protected void modified(S instance,
                        Map<String,?> attributes)
Notification that some service attributes have been modified.

Parameters:
instance - tracking instance
attributes - service attributes

removed

protected void removed(S instance)
Notification that a service has been removed from this watcher.

Parameters:
instance - tracking instance


Copyright © 2006-2012 OPS4J - Open Participation Software for Java. All Rights Reserved.