org.portletbridge.portlet
Class GUIDGenerator

java.lang.Object
  extended by org.portletbridge.portlet.GUIDGenerator

public class GUIDGenerator
extends java.lang.Object

This GUID generator can be safely pooled on a single machine and deployed in a cluster to provide completely scalable performance.

The problem of generating unique IDs can essentially be broken down as uniqueness over space and uniqueness over time which, when combined, produces a globally unique sequence.

Taking the UUID and GUID Internet standards draft for the Network Working Group by Paul J. Leach, Microsoft, and Rich Salz, Certco, as a starting point we assume that the GUID be represented as a 36-digit alphanumeric (including hyphens) of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

The first 20 characters represent the uniqueness over time (the low 32-bits of the time stamp as the first 8, the next 4 as the mid 16 bits of the time stamp, the next 4 as the high value of the time stamp multiplexed with the version, and the next 4 a combination of the lock sequence high -multiplexed with the variant field - and the low bits)

Note: The internet guidelines suggest the timestamp as a 60-bit value to a precision of 100ns since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar)

The last 12 characters are a 48-bit node identifier usually implemented as the IEEE 802 address, which gives uniqueness over space.

These are combined to produce a unique sequence.
Some of the main problems in an EJB implementation of this technique are: -

The GUID is constucted by.

This gives us a value that is a combination of

Note: the potential theoretical conflicts are:

Version:
1.1
Author:
Steve Woodcock

Constructor Summary
GUIDGenerator()
          Creates new GUIDGenerator
 
Method Summary
 java.lang.String getUnformatedUUID()
           Used to provide a UUID that does not conform to the GUID RFC.
 java.lang.String getUUID()
           Returns a UUID formated according to the draft internet standard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GUIDGenerator

public GUIDGenerator()
              throws GUIDException
Creates new GUIDGenerator

Throws:
GUIDException
Method Detail

getUnformatedUUID

public java.lang.String getUnformatedUUID()

Used to provide a UUID that does not conform to the GUID RFC. The String returned does not have the xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format instead it is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. This is to provide a shorter version of the UUID for easier database manipulation.

However, it is recommended that th full format be used.

Returns:
A String representing a UUID in the format xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Each character in the string is a hexadecimal.
Throws:
java.rmi.RemoteException - Required to be thrown by the EJB specification.

getUUID

public java.lang.String getUUID()

Returns a UUID formated according to the draft internet standard. See the class level documentation for more details.

Returns:
A String representing a UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.


Copyright © 2002-2006 Grape Design Limited. All Rights Reserved.