All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.tools.store.Resource

java.lang.Object
   |
   +----w3c.tools.store.AttributeHolder
           |
           +----w3c.tools.store.Resource

public class Resource
extends AttributeHolder
The resource class describes an object, accessible through the server. Resource objects are required to have the following properties:

These resource objects do not define how they are accessed. See the sub-classes for specific accesses. It might be the case that HTTP-NG allows any sub-class of resource to be accessible, although, right now HTTP-1.x only allows you to access HTTPResource instances.


Variable Index

 o ATTR_IDENTIFIER
Attribute index - The index for the identifier attribute.
 o ATTR_RESOURCE_FRAMES
Attribute index - Associated resource frames
 o ATTR_RESOURCE_STORE
Attribute index - The resource store associated with this resource.
 o ATTR_STORE_ENTRY
Attribute index - The index of the resource store entry attribute.

Constructor Index

 o Resource()
Create an empty resource instance.

Method Index

 o acceptUnload()
Is that resource willing to be unloaded.
 o collectFrames(Class)
Collect any frame that's an instance of the given class.
 o delete()
Delete this Resource instance, and remove it from its store.
 o getClone(Object[])
Clone this attribute holder, and init it with the given attributes.
 o getFrame(Class)
Get the first occurence of a frame of the given class.
 o getHelpURL()
Get this resource's help url.
 o getHelpURL(String)
Get the help URL for that resource's topic.
 o getIdentifier()
Get this resource identifier.
 o getResourceStore()
Get the store associated with this resource.
 o getStoreEntry()
Get the store entry for that resource.
 o getValue(Class, int, Object)
Get an attached frame attribute value.
 o lock(ResourceLocker)
Lock this resource in its store.
 o markModified()
Mark this resource as having been modified.
 o notifyUnload()
This resource is being unloaded.
 o registerFrame(ResourceFrame, Hashtable)
Initialize and attach a new ResourceFrame to that resource.
 o setValue(Class, int, Object)
Set an attached frame attribute value.
 o setValue(int, Object)
We overide setValue, to mark the resource as modified.
 o unlock(ResourceLocker)
Unlock the given resource.
 o unregisterFrame(ResourceFrame)
Unregister a resource frame from the given resource.
 o updateAttributes()
The web admin wants us to update any out of date attribute.

Variables

 o ATTR_STORE_ENTRY
 protected static int ATTR_STORE_ENTRY
Attribute index - The index of the resource store entry attribute.

 o ATTR_IDENTIFIER
 protected static int ATTR_IDENTIFIER
Attribute index - The index for the identifier attribute.

 o ATTR_RESOURCE_STORE
 protected static int ATTR_RESOURCE_STORE
Attribute index - The resource store associated with this resource.

 o ATTR_RESOURCE_FRAMES
 protected static int ATTR_RESOURCE_FRAMES
Attribute index - Associated resource frames

Constructors

 o Resource
 public Resource()
Create an empty resource instance. Initialize the instance attributes description, and its values.

Methods

 o getClone
 public Object getClone(Object values[])
Clone this attribute holder, and init it with the given attributes.

Overrides:
getClone in class AttributeHolder
 o getStoreEntry
 public Object getStoreEntry()
Get the store entry for that resource. Only the resource store in charge of this resource knows about the type of the resulting object. Buy declaring the class of that object private, the resource store can assume some private access to it.

Returns:
A java Object instance, or null if no store entry is attached to that resource.
 o getHelpURL
 public String getHelpURL()
Get this resource's help url.

Returns:
An URL, encoded as a String, or null if not available.
 o getHelpURL
 public String getHelpURL(String topics)
Get the help URL for that resource's topic.

Parameters:
topic - The topic you want help for.
Returns:
A String encoded URL, or null if none was found.
 o getIdentifier
 public String getIdentifier()
Get this resource identifier.

Returns:
The String value for the identifier.
 o getResourceStore
 public ResourceStore getResourceStore()
Get the store associated with this resource.

Returns:
The associated store or null. Not all resources have a store associated with them (eg the one that whose creation is cheap, etc).
 o registerFrame
 public void registerFrame(ResourceFrame frame,
                           Hashtable defs)
Initialize and attach a new ResourceFrame to that resource.

Parameters:
frame - An uninitialized ResourceFrame instance.
defs - A default set of attribute values.
Returns:
The initialized instance of the ResourceFrame itself.
Throws: HolderInitException
If the frame couldn't be initialized.
 o unregisterFrame
 public synchronized void unregisterFrame(ResourceFrame frame)
Unregister a resource frame from the given resource.

Parameters:
frame - The frame to unregister from the resource.
 o collectFrames
 public synchronized ResourceFrame[] collectFrames(Class c)
Collect any frame that's an instance of the given class.

Parameters:
cls - The class of frames we are looking for.
Returns:
An array of ResourceFrame, containing a set of frames instances of the given class, or null if no resource frame is available.
 o getFrame
 public synchronized ResourceFrame getFrame(Class c)
Get the first occurence of a frame of the given class.

Parameters:
cls - The class of te frame to look for.
Returns:
A ResourceFrame instance, or null.
 o getValue
 public synchronized Object getValue(Class c,
                                     int idx,
                                     Object def)
Get an attached frame attribute value. This method really is a short-hand that combines a getFrame and getValue method call.

Parameters:
cls - The class of the frame we want the value of.
idx - The attribute index.
def - The default value (if the attribute value isn't defined).
Returns:
The attribute value as an Object instance, or the provided default value if the attribute value isn't defined.
 o setValue
 public synchronized void setValue(Class c,
                                   int idx,
                                   Object val)
Set an attached frame attribute value. This method really is a short-hand that combines a getFrame and a setValue method call.

Parameters:
cls - The class of the frame we want to modify.
idx - The attribute to modify.
val - The new attribute value.
 o markModified
 public void markModified()
Mark this resource as having been modified.

 o setValue
 public void setValue(int idx,
                      Object value)
We overide setValue, to mark the resource as modified.

Parameters:
idx - The index of the attribute to modify.
value - The new attribute value.
Overrides:
setValue in class AttributeHolder
 o acceptUnload
 public boolean acceptUnload()
Is that resource willing to be unloaded. This method is a bit tricky to implement. The guideline is that you should not dynamically change the returned value (since you can't control what happens between a call to that method and a call to the notifyUnload method).

Returning false should never be needed, except for very strange resources.

Returns:
A boolean true if the resource can be unloaded false otherwise.
 o notifyUnload
 public void notifyUnload()
This resource is being unloaded. The resource is being unloaded from memory, perform any additional cleanup required.

 o lock
 public boolean lock(ResourceLocker locker)
Lock this resource in its store. Acquire a lock on this resource: if you do acquire the lock, than you are guaranteed that either the resource will be kept in memory, or you will be notified through a call to notifyResourceLockBreak that the resource is going down.

Parameters:
locker - The object willing to acquire the lock.
Returns:
A boolean true if locking succeeded, false otherwise.
 o unlock
 public void unlock(ResourceLocker locker)
Unlock the given resource.

Parameters:
locker - The object that wishes to relinquish the lock.
 o updateAttributes
 public void updateAttributes()
The web admin wants us to update any out of date attribute.

 o delete
 public synchronized void delete()
Delete this Resource instance, and remove it from its store. This method will erase definitely this resource, for ever, by removing it from its resource store (when doable).


All Packages  Class Hierarchy  This Package  Previous  Next  Index