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
    Constructor
    Description
    Construct a resource tracker.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Enable a resource tracker.
    Get the default resource tracker.
    void
    shutdown(boolean waitForCompletion)
    Shutdown all tracked resources.
    void
    trackResource(TrackedResourceInterface resource)
    Track a resource.
    void
    untrackResource(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

      public static ResourceTracker 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:
      shutdown in interface TrackedResourceInterface