net.sf.jzeno.util
Class UUIDGenerator

java.lang.Object
  extended by net.sf.jzeno.util.UUIDGenerator

public class UUIDGenerator
extends java.lang.Object

This Class is an implementation of the UUID pattern described on the server side (http://www.theserverside.com) It creates 32 digits(encoded in hexadecimal) globally unique identifiers that can be used as primary keys in EJB The format of the generated UUID's is as follows: System.currentTimeMillis() | | System.identityHashCode(this) | | xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx | | IP-Address | | Random Number The GUID is composed as folows: 1. Unique down to the millisecond. Digits 1-8 are the hex encoded lower 32 bits of the System.currentTimeMillis() call. 2. Unique Across a Cluster. Digits 9-16 are the hex encoded representation of the 32-bit integer of the underlying IP Address (an IP is divided into 4 separate bytes, appended together they form 32 bits). 3. Unique down to the objects within a Server. Digits 17-24 are the hex representation of the call to System.identityHashCode(this), which is guaranteed to return distinct integers for distinct objects within a machine (the algorithm returns the memory address of an object). This assures that multiple instances of a GUID generator on the same machine will not create duplicate keys, even if in different JVMs. 4. Unique within an object within a millisecond. Finally, digits 25-32 represent a random 32 bit integer generated on every method call using the Cryptographically strong java.security.SecureRandom class. Thus multiple calls to the same method within the same millisecond are guaranteed to be unique. Altogether, a UUID created using this algorithm is guaranteed to be unique across all machines in a cluster, across all instances of UUID generators within one machine, down to the millisecond and even down to the individual method call within each millisecond. This class is implemented as a singleton, but can also be implemented as a stateless session bean


Method Summary
static UUIDGenerator getInstance()
           
 java.lang.String getUUID()
          Get a new GUID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static UUIDGenerator getInstance()

getUUID

public java.lang.String getUUID()
Get a new GUID