org.outerj.xreporter.idgenerator
Class FileBasedIdGenerator

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.outerj.xreporter.idgenerator.FileBasedIdGenerator
All Implemented Interfaces:
org.apache.avalon.framework.configuration.Configurable, IdGenerator, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.thread.ThreadSafe

public class FileBasedIdGenerator
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements IdGenerator, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.thread.ThreadSafe

An ID-generator which reads (and stores) its starting ID from a file, so that always-increasing ID's are obtained, even between XReporter restarts. The ID generator obtains its ID's in blocks: each time it has reached the maximum ID in the current block, it reqeusts a new block by writing (current ID value + block size) to the ID file.


Field Summary
protected  int blockSize
           
protected  int counter
           
protected  int maxValue
           
protected  java.lang.String separator
           
protected  java.io.File sequenceFile
           
protected  java.lang.String serverIdentifier
           
 
Fields inherited from interface org.outerj.xreporter.idgenerator.IdGenerator
ROLE
 
Constructor Summary
FileBasedIdGenerator()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 java.lang.String getId()
           
 void getNewNumberBlock()
           
 void initialize()
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

counter

protected int counter

maxValue

protected int maxValue

blockSize

protected int blockSize

sequenceFile

protected java.io.File sequenceFile

serverIdentifier

protected java.lang.String serverIdentifier

separator

protected java.lang.String separator
Constructor Detail

FileBasedIdGenerator

public FileBasedIdGenerator()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception

getNewNumberBlock

public void getNewNumberBlock()

getId

public java.lang.String getId()
Specified by:
getId in interface IdGenerator