FileDocCategorySizeDatePackage
SequenceGenerator.javaAPI DocExample1528Thu Aug 24 20:57:44 BST 2000com.imaginary.lwp

SequenceGenerator

public abstract class SequenceGenerator extends Object

Fields Summary
private static long
currentNode
private static SequenceGenerator
generator
private static long
nextID
Constructors Summary
public SequenceGenerator()

        super();
    
Methods Summary
public abstract longgenerate(java.lang.String seq)

public static synchronized longgenerateSequence(java.lang.String seq)

    
         
          
        if( generator == null ) {
            String cname = System.getProperty(LWPProperties.SEQ_GEN);

            if( cname == null ) {
                generator = new JDBCGenerator();
            }
            else {
                try {
                    generator =
                        (SequenceGenerator)Class.forName(cname).newInstance();
                }
                catch( Exception e ) {
                    throw new SequenceException(e.getMessage());
                }
            }
        }
        return generator.generate(seq);
    
public static synchronized longnextObjectID()

        if( currentNode == -1L || nextID >= 99999L ) {
            currentNode = generateSequence("node");
            if( currentNode < 1 ) {
                nextID = 1;
            }
            else {
                nextID = 0;
            }
        }
        else {
            nextID++;
        }
        return ((currentNode*100000L) + nextID);