All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.jigsaw.contrib.CheckpointResource

java.lang.Object
   |
   +----w3c.tools.store.AttributeHolder
           |
           +----w3c.tools.store.Resource
                   |
                   +----w3c.jigsaw.resources.HTTPResource
                           |
                           +----w3c.jigsaw.resources.FilteredResource
                                   |
                                   +----w3c.jigsaw.contrib.CheckpointResource

public class CheckpointResource
extends FilteredResource
implements Runnable
A resource that will checkpoint the configuration at regular intervals. This resource will make sure that current configuration is backed up to disk at regular (configurable) intervals.

The webmaster can customize what part of the configuration is to be backed up through boolean attributes.


Variable Index

 o alive
Is our attached thread still alive ?
 o ATTR_FLUSHCONFIG
Attribute index - Should we save the configuration ?
 o ATTR_FLUSHLOG
Attribute index - Should we flush the logs too ?
 o ATTR_FLUSHPROPS
Attrbute index - Should we save the properties too ?
 o ATTR_INTERVAL
Attribute index - Backup interval, in seconds.
 o ATTR_PRIORITY
Attribute index - The priority of the flusher thread.
 o checkpoint
Last date at which we checkpointed the configuration
 o thread
Our thread, if one is currently attached.

Constructor Index

 o CheckpointResource()

Method Index

 o acceptUnload()
This is the only resource that will refuse to be unloaded !
 o activate()
Start the thread for this object, only if needed.
 o get(Request)
Get the content of that resources.
 o getFlushConfiguration()
Get the flush configuration flag.
 o getFlushLog()
Get the flush log flag.
 o getFlushProperties()
Get the flush properties flag.
 o getInterval()
Get the sync interval.
 o getPriority()
Get the priority for our attached thread.
 o initialize(Object[])
Activate the checkpointer at initialization time.
 o notifyUnload()
This resource is being unloaded.
 o run()
We are attached a thread, now it's time to performt the job.
 o stop()
Force our attached thread to stop.

Variables

 o ATTR_INTERVAL
 protected static int ATTR_INTERVAL
Attribute index - Backup interval, in seconds.

 o ATTR_PRIORITY
 protected static int ATTR_PRIORITY
Attribute index - The priority of the flusher thread.

 o ATTR_FLUSHLOG
 protected static int ATTR_FLUSHLOG
Attribute index - Should we flush the logs too ?

 o ATTR_FLUSHPROPS
 protected static int ATTR_FLUSHPROPS
Attrbute index - Should we save the properties too ?

 o ATTR_FLUSHCONFIG
 protected static int ATTR_FLUSHCONFIG
Attribute index - Should we save the configuration ?

 o thread
 protected Thread thread
Our thread, if one is currently attached.

 o checkpoint
 protected Date checkpoint
Last date at which we checkpointed the configuration

 o alive
 protected boolean alive
Is our attached thread still alive ?

Constructors

 o CheckpointResource
 public CheckpointResource()

Methods

 o activate
 protected synchronized void activate()
Start the thread for this object, only if needed.

 o stop
 protected synchronized void stop()
Force our attached thread to stop.

 o getInterval
 public int getInterval()
Get the sync interval.

Returns:
An integer number of seconds, or -1 if undefined.
 o getPriority
 public int getPriority()
Get the priority for our attached thread.

Returns:
An integer priority for the thread, which defaults to 2 if undefined.
 o getFlushLog
 public boolean getFlushLog()
Get the flush log flag.

Returns:
A boolean, true if the log is to be flushed at each refresh interval, false otherwise.
 o getFlushProperties
 public boolean getFlushProperties()
Get the flush properties flag.

Returns:
A boolean, true if the properties are to be flushed, false otherwise.
 o getFlushConfiguration
 public boolean getFlushConfiguration()
Get the flush configuration flag.

Returns:
A boolean, true oif the configuration is to be flushed at each interval, false otherwise.
 o acceptUnload
 public boolean acceptUnload()
This is the only resource that will refuse to be unloaded !

Returns:
Always false.
Overrides:
acceptUnload in class Resource
 o notifyUnload
 public void notifyUnload()
This resource is being unloaded. Unloading that object will also stop the thread. However, there is a bug here, since if the resource gets unloaded for some reason, it will not be able to wakeup itself at next checkpoint time.

Overrides:
notifyUnload in class Resource
 o run
 public void run()
We are attached a thread, now it's time to performt the job.

 o get
 public Reply get(Request request) throws HTTPException
Get the content of that resources. Will display some usefull commands to start/stop the attached thread

Parameters:
request - The request to handle.
Throws: HTTPException
If request processing failed.
Overrides:
get in class HTTPResource
 o initialize
 public void initialize(Object values[])
Activate the checkpointer at initialization time.

Overrides:
initialize in class FilteredResource

All Packages  Class Hierarchy  This Package  Previous  Next  Index