com.springsource.util.osgi
Class ServiceRegistrationTracker

java.lang.Object
  extended by com.springsource.util.osgi.ServiceRegistrationTracker

public final class ServiceRegistrationTracker
extends java.lang.Object

Utility class that tracks a set of ServiceRegistrations and always for them to be safely unregistered.

ServiceRegistrations are tracked in a threadsafe manner, and importantly are unregistered without holding any locks.

See Also:
ServiceRegistration

Field Summary
private  java.lang.Object monitor
           
private  java.util.Set<org.osgi.framework.ServiceRegistration> registrations
           
 
Constructor Summary
ServiceRegistrationTracker()
           
 
Method Summary
 void track(org.osgi.framework.ServiceRegistration registration)
          Tracks the supplied ServiceRegistration.
 void unregisterAll()
          Safely unregisters all the tracked ServiceRegistrations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

monitor

private final java.lang.Object monitor

registrations

private java.util.Set<org.osgi.framework.ServiceRegistration> registrations
Constructor Detail

ServiceRegistrationTracker

public ServiceRegistrationTracker()
Method Detail

track

public void track(org.osgi.framework.ServiceRegistration registration)
Tracks the supplied ServiceRegistration. This ServiceRegistration will be unregistered during unregisterAll().

Parameters:
registration - the ServiceRegistration to track.

unregisterAll

public void unregisterAll()
Safely unregisters all the tracked ServiceRegistrations.