public class References extends Object
SharedResource
s and ResourceReference
s.Modifier and Type | Field and Description |
---|---|
static ResourceReference |
NOOP_REFERENCE
A
ResourceReference that does nothing. |
Modifier | Constructor and Description |
---|---|
private |
References() |
Modifier and Type | Method and Description |
---|---|
static ResourceReference |
fromResource(SharedResource resource)
|
public static final ResourceReference NOOP_REFERENCE
ResourceReference
that does nothing.
Useful for e.g. testing of resource types when reference counting is not the focus.public static ResourceReference fromResource(SharedResource resource)
Returns a ResourceReference
that invokes SharedResource.release()
on
close
. Useful for treating the "main" reference of a SharedResource
just as any other reference obtained by calling SharedResource.refer()
. Example:
final Request request = new Request(...); try (final ResourceReference ref = References.fromResource(request)) { .... } // The request will be released on exit from the try block.
resource
- The resource to create a ResourceReference for.Copyright © 2018. All rights reserved.