Package de.caluga.morphium
Class 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSequenceGenerator.RecursionException
-
Constructor Summary
Constructors Constructor Description SequenceGenerator(Morphium m, String n)SequenceGenerator(Morphium mrph, String name, int inc, long startValue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCurrentValue()StringgetId()intgetInc()MorphiumgetMorphium()StringgetName()longgetNextValue()longgetStartValue()voidsetId(String id)voidsetInc(int inc)voidsetMorphium(Morphium morphium)voidsetName(String name)voidsetStartValue(long startValue)
-
-
-
Method Detail
-
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)
-
-