Class ManagedResource<T>

java.lang.Object
com.rpl.rama.integration.ManagedResource<T>
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
TaskThreadManagedResource, WorkerManagedResource

public abstract class ManagedResource<T> extends Object implements Closeable
  • Constructor Details

    • ManagedResource

      public ManagedResource(String resourceId, TaskGlobalContext taskGlobalContext, Callable<T> resourceConstructor)
      Parameters:
      resourceId - - a unique ID for this resource
      taskGlobalContext - - the current TaskGlobalContext
      resourceConstructor - - a function returning a new instance of the resource
  • Method Details

    • idTuple

      protected abstract List idTuple(TaskGlobalContext context)
    • getResource

      public T getResource()
      Constructs the resource using the provided constructor if it doesn't yet exist in the resource map
      Returns:
      the resource constructed
    • close

      public void close() throws IOException
      Closes the resource if it's an instance of java.io.Closeable. The resource will be closed only one time if shared across multiple task global instances. Will remove the resource from the map of resources
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException