KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > factories > InodeGenerator


1 package com.dotmarketing.factories;
2
3 import java.io.Serializable JavaDoc;
4
5 import net.sf.hibernate.engine.SessionImplementor;
6 import net.sf.hibernate.id.IdentifierGenerator;
7
8
9 /**
10  * <b>vm.long</b><br>
11  * <br>
12  * An <tt>IdentifierGenerator</tt> that returns a <tt>Long</tt>, constructed from the
13  * system time and a counter value. Not safe for use in a cluster!
14  */

15 public class InodeGenerator implements IdentifierGenerator {
16
17     private static long counter = System.currentTimeMillis();
18
19     protected long getCount() {
20         synchronized(InodeGenerator.class) {
21             return counter++;
22         }
23     }
24
25     public synchronized Serializable JavaDoc generate(SessionImplementor cache, Object JavaDoc obj) {
26         return new Long JavaDoc( getCount() );
27     }
28
29
30
31 }
32
Popular Tags