public interface SharedResource
This interface defines a reference counted resource. This is the parent interface of RequestHandler
,
ClientProvider
and ServerProvider
, and is used by jDISC to appropriately signal resources as they
become candidates for deallocation. As a ContainerBuilder
is activated
, all its components are retained
by that Container
. Once a DeactivatedContainer
terminates, all of that Container's components are
released
. This resource tracking allows an Application to implement a significantly
simpler scheme for managing its resources than would otherwise be possible.
Objects are created with an initial reference count of 1, representing the reference held by the object creator.
You should not really think about the management of resources in terms of reference counting, instead think of it in terms of resource ownership. You retain a resource to prevent it from being destroyed while you are using it, and you release a resource once you are done using it.
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
static String |
SYSTEM_PROPERTY_NAME_DEBUG |
Modifier and Type | Method and Description |
---|---|
ResourceReference |
refer()
Increments the reference count of this resource.
|
void |
release()
Releases the "main" reference to this resource (the implicit reference due to creation of the object).
|
static final String SYSTEM_PROPERTY_NAME_DEBUG
static final boolean DEBUG
ResourceReference refer()
Increments the reference count of this resource. You call this method to prevent an object from being destroyed until you have finished using it.
You MUST keep the returned ResourceReference
object and release the reference by calling
ResourceReference.close()
on it. A reference created by this method can NOT be released by calling
release()
.
ResourceReference.close()
void release()
Releases the "main" reference to this resource (the implicit reference due to creation of the object).
References obtained by calling refer()
must be released by calling ResourceReference.close()
on the ResourceReference
returned from refer()
, NOT by calling this method. You call this
method once you are done using an object that you have previously caused instantiation of.
ResourceReference
Copyright © 2018. All rights reserved.