Klasse SequenceGenerator

java.lang.Object
de.caluga.morphium.SequenceGenerator

public class SequenceGenerator extends Object
User: Stephan Bösebeck Date: 24.07.12 Time: 21:36

Generate a new unique sequence number. Uses Sequence to store the current value. Process is as follows:

  • lock the entry in sequence collection with my own UUID (rather unique) using atomar $set operation
  • read my locked entries (should only be one). If one is found, I have a valid lock. If not found, somebody locked over. Wait a while and try again
  • increase the number by one (or the given increment) on the locked element, get this value
  • remove the lock (atomar using $set)
  • return current value
  • Konstruktordetails

    • SequenceGenerator

      public SequenceGenerator(Morphium m, String n)
    • SequenceGenerator

      public SequenceGenerator(Morphium mrph, String name, int inc, long startValue)
  • Methodendetails

    • getCurrentValue

      public long getCurrentValue()
    • getNextValue

      public long getNextValue()
    • getInc

      public int getInc()
    • setInc

      public void setInc(int inc)
    • getStartValue

      public long getStartValue()
    • setStartValue

      public void setStartValue(long startValue)
    • getId

      public String getId()
    • setId

      public void setId(String id)
    • getName

      public String getName()
    • setName

      public void setName(String name)
    • getMorphium

      public Morphium getMorphium()
    • setMorphium

      public void setMorphium(Morphium morphium)