Interface w3c.jigsaw.resources.ResourceStoreHolder
All Packages Class Hierarchy This Package Previous Next Index
Interface w3c.jigsaw.resources.ResourceStoreHolder
- public interface ResourceStoreHolder
- extends Object
Interface for resource store holders.
As ResourceStore objects may be potentially very large, and as the server
may have to load thousands of them, objects that want to keep some pointer
to a resource store should implement this interface.
If implemented, this interface will allow the resource store manager
to control what resource stores are loaded, when to unload them, when
they should be stabilized (with regard to their database), etc.
An object holding a resource store, will typically include the
following piece of code:
class XXX implements ResourceStoreHolder {
ResourceStore store = null ;
public boolean notifyStoreUnload(ResourceStore store) {
store.shutdown() ;
store = null ;
return true ;
}
synchronized Resource lookup(String identifier) {
if ( store == null )
store = ResourceStoreManager.loadResourceStore(...) ;
...
}
}
- See Also:
- ResourceStoreManager
-
notifyStoreShutdown(ResourceStore)
- The resource store manager is shutting down.
-
notifyStoreStabilize(ResourceStore)
- Stabilize your store.
-
notifyStoreUnload(ResourceStore)
- The resource store manager is willing to unload your store.
notifyStoreUnload
public abstract boolean notifyStoreUnload(ResourceStore store)
- The resource store manager is willing to unload your store.
The clever resource store manager is willing to free your store,
for some reasons (eg memory is getting low, it hasn't been access
for a long time, etc).
The resource store manager will take care of shutting down the
resource store appropriatelly, you should just get rid of your pointer
to it, if possible.
If you return true, the resource store manager
will no longer assume that you hold the store.
- Parameters:
- store - The store in question.
- Returns:
- A boolean true iff: you have get rid of your
pointer to the store. If you want to defer the store shutdown,
than return false, but you should have good
reasons for doing so.
notifyStoreShutdown
public abstract void notifyStoreShutdown(ResourceStore store)
- The resource store manager is shutting down.
When the resource manager is shutdown, it calls all its loaded store
holders to notify them that the store is going down. You will no
longer be considered a holder for the store after this notification.
The resource store manager will take care of saving the store,
after all holders have been notified of the shutdown.
- Parameters:
- store - The store to be shutdown.
notifyStoreStabilize
public abstract boolean notifyStoreStabilize(ResourceStore store)
- Stabilize your store.
The resource store manager is aware that your store has been
modified recently, but no saved. Moreover, this clever guy thinks
that it is a good time for you to stabilize it.
- Parameters:
- store - The store to stabilize.
- Returns:
- A boolean true if the resource store manager
can mark your store as unmodified (it has been saved succesfully),
false otherwise.
All Packages Class Hierarchy This Package Previous Next Index