T - Type of the AutoCloseable@API.Internal
@API.NotThreadSafe
public class SharedResource<T extends java.lang.AutoCloseable>
extends java.lang.Object
| Constructor and Description |
|---|
SharedResource(T resource)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRef()
Increment the reference count.
|
T |
get()
Get the resource.
|
protected void |
preCloseAction(T resource)
Perform an action before closing the resource.
|
void |
release()
Decrement the reference count, and close() the resource if
the count has reached zero.
|
public SharedResource(T resource)
resource - the resource to be sharedpublic void addRef()
public void release()
OjaiException.protected void preCloseAction(T resource)
release() call.the - resource that will be closedpublic T get()