Interface SharedResource
- All Known Subinterfaces:
ClientProvider
,Container
,DelegatedRequestHandler
,RequestHandler
,ServerProvider
- All Known Implementing Classes:
AbstractClientProvider
,AbstractRequestHandler
,AbstractResource
,AbstractServerProvider
,ActiveContainer
,NonWorkingClientProvider
,NonWorkingRequestHandler
,NonWorkingServerProvider
,NoopSharedResource
,Request
,ResourcePool
,ThreadedRequestHandler
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.
- Author:
- Simon Thoresen Hult
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault ResourceReference
refer()
Creates a reference to this resource.default ResourceReference
Creates a reference to this resource.void
release()
Releases the "main" reference to this resource (the implicit reference due to creation of the object).
-
Field Details
-
SYSTEM_PROPERTY_NAME_DEBUG
- See Also:
-
DEBUG
-
-
Method Details
-
refer
Creates a reference to 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 callingResourceReference.close()
on it. A reference created by this method can NOT be released by callingrelease()
.- See Also:
-
refer
Creates a reference to this resource. You call this method to prevent an object from being destroyed until you have finished using it. You can attach a context that will live as long as the reference.
- Parameters:
context
- A context to be associated with the reference. It should give some clue as to who referenced it.You MUST keep the returned
ResourceReference
object and release the reference by callingResourceReference.close()
on it. A reference created by this method can NOT be released by callingrelease()
.- See Also:
-
release
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 callingResourceReference.close()
on theResourceReference
returned fromrefer()
, NOT by calling this method. You call this method once you are done using an object that you have previously caused instantiation of.- See Also:
-