Package com.rpl.rama.integration
Class ManagedResource<T>
java.lang.Object
com.rpl.rama.integration.ManagedResource<T>
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
TaskThreadManagedResource,WorkerManagedResource
-
Constructor Summary
ConstructorsConstructorDescriptionManagedResource(String resourceId, TaskGlobalContext taskGlobalContext, Callable<T> resourceConstructor) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the resource if it's an instance of java.io.Closeable.Constructs the resource using the provided constructor if it doesn't yet exist in the resource mapprotected abstract ListidTuple(TaskGlobalContext context)
-
Constructor Details
-
ManagedResource
public ManagedResource(String resourceId, TaskGlobalContext taskGlobalContext, Callable<T> resourceConstructor) - Parameters:
resourceId- - a unique ID for this resourcetaskGlobalContext- - the current TaskGlobalContextresourceConstructor- - a function returning a new instance of the resource
-
-
Method Details
-
idTuple
-
getResource
Constructs the resource using the provided constructor if it doesn't yet exist in the resource map- Returns:
- the resource constructed
-
close
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-