    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.

##

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

##

CheckpointResource()

##

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

##

ATTR_INTERVAL

     protected static int ATTR_INTERVAL

  Attribute index - Backup interval, in seconds.

ATTR_PRIORITY

     protected static int ATTR_PRIORITY

  Attribute index - The priority of the flusher thread.

ATTR_FLUSHLOG

     protected static int ATTR_FLUSHLOG

  Attribute index - Should we flush the logs too ?

ATTR_FLUSHPROPS

     protected static int ATTR_FLUSHPROPS

  Attrbute index - Should we save the properties too ?

ATTR_FLUSHCONFIG

     protected static int ATTR_FLUSHCONFIG

  Attribute index - Should we save the configuration ?

thread

     protected Thread thread

  Our thread, if one is currently attached.

checkpoint

     protected Date checkpoint

  Last date at which we checkpointed the configuration

alive

     protected boolean alive

  Is our attached thread still alive ?

##

CheckpointResource

     public CheckpointResource()

##

activate

     protected synchronized void activate()

  Start the thread for this object, only if needed.

stop

     protected synchronized void stop()

  Force our attached thread to stop.

getInterval

     public int getInterval()

  Get the sync interval.

  Returns:
    An integer number of seconds, or -1 if undefined.

getPriority

     public int getPriority()

  Get the priority for our attached thread.

  Returns:
    An integer priority for the thread, which defaults to 2 if undefined.

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.

getFlushProperties

     public boolean getFlushProperties()

  Get the flush properties flag.

  Returns:
    A boolean, true if the properties are to be flushed, false otherwise.

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.

acceptUnload

     public boolean acceptUnload()

  This is the only resource that will refuse to be unloaded !

  Returns:
    Always false.
  Overrides:
    acceptUnload in class Resource

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

run

     public void run()

  We are attached a thread, now it's time to performt the job.

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

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