Package com.sas.iom.orb
Class ResourceTracker
java.lang.Object
com.sas.iom.orb.ResourceTracker
- All Implemented Interfaces:
- com.sas.iom.orb.TrackedResourceInterface
public class ResourceTracker
extends Object
implements TrackedResourceInterface
A repository of resources that need to be shutdown all at once (eg when a
container is destroyed). The ResourceTracker is itself a tracked resource
so that resource trackers can be nested. The ResourceTracker must be enabled
by calling enable() before it will track any resources. Some resources such
as ThreadPool automatically add themselves to the ResourceTracker.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidenable()Enable a resource tracker.static ResourceTrackerGet the default resource tracker.voidshutdown(boolean waitForCompletion) Shutdown all tracked resources.voidtrackResource(TrackedResourceInterface resource) Track a resource.voiduntrackResource(TrackedResourceInterface resource) Remove a resource from the tracker.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
ResourceTracker
public ResourceTracker()Construct a resource tracker.
-
-
Method Details
-
getInstance
Get the default resource tracker.- Returns:
- the default resource tracker
-
enable
public void enable()Enable a resource tracker. No resources will be tracked until the tracker is enabled. -
trackResource
public void trackResource(TrackedResourceInterface resource) Track a resource.- Parameters:
resource- the resource to track
-
untrackResource
public void untrackResource(TrackedResourceInterface resource) Remove a resource from the tracker.- Parameters:
resource- the resource to remove
-
shutdown
public void shutdown(boolean waitForCompletion) Shutdown all tracked resources.- Specified by:
shutdownin interfaceTrackedResourceInterface
-