Subversion Repositories SmartDukaan

Rev

Rev 49 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 49 Rev 51
Line 19... Line 19...
19
	 * 
19
	 * 
20
	 */
20
	 */
21
	private static final long serialVersionUID = 1L;
21
	private static final long serialVersionUID = 1L;
22
	
22
	
23
	/**
23
	/**
24
	 * 
24
	 * Entity object's starting sequence number
25
	 */
25
	 */
26
	public static final int ENTITY = 0;
26
	public static final int ENTITY = 0;
27
 
27
 
28
	/**
28
	/**
-
 
29
	 * Singleton instance that is de-serialized from file on the disk
29
	 * 
30
	 * 
30
	 * @return 	SequenceGenerator 	instance of SequenceGenerator
31
	 * @return 	SequenceGenerator 	instance of SequenceGenerator
31
	 * @throws Exception 
32
	 * @throws Exception 
32
	 */
33
	 */
33
	public static final SequenceGenerator getInstance() throws Exception {
34
	public static final SequenceGenerator getInstance() throws Exception {
Line 43... Line 44...
43
		
44
		
44
		return sequenceGenerator;
45
		return sequenceGenerator;
45
	}
46
	}
46
	
47
	
47
	/**
48
	/**
48
	 * 
-
 
-
 
49
	 * Instance memeber that records all current counts
49
	 */
50
	 */
50
	private long[] currentCounts = null;
51
	private long[] currentCounts = null;
51
 
52
 
52
	/**
53
	/**
53
	 * A private Constructor prevents any other class from instantiating
54
	 * A private Constructor prevents any other class from instantiating. All 
-
 
55
	 * objects that need dynamic sequence generation need to provide starting 
-
 
56
	 * number here.
54
	 */
57
	 */
55
	private SequenceGenerator() {
58
	private SequenceGenerator() {
56
		this.currentCounts = new long[1];
59
		this.currentCounts = new long[1];
57
		
60
		
58
		// Set initial values
61
		// Set initial values
59
		this.currentCounts[ENTITY] = 1000000;
62
		this.currentCounts[ENTITY] = 1000000;
60
	}
63
	}
61
	
64
	
62
	/**
65
	/**
-
 
66
	 * Client of the class call this method to get new sequence number. 
-
 
67
	 * Once a sequence number if fetched it cannot be undone.
63
	 * 
68
	 * 
64
	 * @param index
69
	 * @param index
65
	 * @return currentCount
70
	 * @return currentCount
66
	 * @throws Exception 
71
	 * @throws Exception 
67
	 */
72
	 */