All Packages Class Hierarchy This Package Previous Next Index
Interface w3c.tools.store.ResourceStoreHolder
- public interface ResourceStoreHolder
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
-
acceptStoreUnload(ResourceStore)
- The resource store manager is willing to unload your store.
-
notifyStoreShutdown(ResourceStore)
- The resource store manager is shutting down.
-
notifyStoreStabilize(ResourceStore)
- The resource store manager did manager to save your store.
acceptStoreUnload
public abstract boolean acceptStoreUnload(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).
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.
Implementers of that interface should make sure they no longer
hold a ref to the store after this method terminates.
- Parameters:
- store - The store to be shutdown.
notifyStoreStabilize
public abstract void notifyStoreStabilize(ResourceStore store)
- The resource store manager did manager to save your store.
This method gets called once the resource store has been stabilized
to persistent storage.
- Parameters:
- store - The store to stabilize.
All Packages Class Hierarchy This Package Previous Next Index