org.olat.core.util
Class CodeHelper

java.lang.Object
  extended by org.olat.core.util.CodeHelper

public class CodeHelper
extends java.lang.Object

enclosing_type Description:

Author:
Felix Jost, Guido Schnider

Constructor Summary
CodeHelper()
           
 
Method Summary
static long getForeverUniqueID()
          PLEASE use only if REALLY needed.
Best effort is taken to make it "globally unique" without any persisting media by instantiating it by System.currentTimeMilis * 64, so that after a restart of the vm, the counter advances 64000 units per second which should be enough that that value is never exceeded by the usage of that ID (100 concurrent users which can consume 640 unique id per each second, and: even if exceeded, after a restart of a vm (assumed time at least 10secs), a loss of 10*64000 = 640000 can be caught up

if you just need a counter which is unique within the virtual machine, but does not need to be unique if the sessions are persisted and the vm is restarted, then use @see getRAMUniqueID() returns a unique id; even if the system is restarted.
static java.lang.String getGlobalForeverUniqueID()
          Generates a virtually global unique ID based on the forever unique ID (see getForeverUniqueID()) and a user defined namespace (see OLATContext.instanceId).
static long getRAMUniqueID()
          a simple counter which is garanteed to be unique ONLY within one instance of a virtual machine.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeHelper

public CodeHelper()
Method Detail

getGlobalForeverUniqueID

public static java.lang.String getGlobalForeverUniqueID()
Generates a virtually global unique ID based on the forever unique ID (see getForeverUniqueID()) and a user defined namespace (see OLATContext.instanceId). This ID has a maximum length of 30 characters (10 chr instanceID + 20 chr timeuniqueID)

Returns:
a virtually global unique ID

getForeverUniqueID

public static long getForeverUniqueID()
PLEASE use only if REALLY needed.
Best effort is taken to make it "globally unique" without any persisting media by instantiating it by System.currentTimeMilis * 64, so that after a restart of the vm, the counter advances 64000 units per second which should be enough that that value is never exceeded by the usage of that ID (100 concurrent users which can consume 640 unique id per each second, and: even if exceeded, after a restart of a vm (assumed time at least 10secs), a loss of 10*64000 = 640000 can be caught up

if you just need a counter which is unique within the virtual machine, but does not need to be unique if the sessions are persisted and the vm is restarted, then use @see getRAMUniqueID() returns a unique id; even if the system is restarted.

Returns:
long

getRAMUniqueID

public static long getRAMUniqueID()
a simple counter which is garanteed to be unique ONLY within one instance of a virtual machine. Best effort is taken to make it "globally unique" by instantiating it by System.currentTimeMilis * 64, so that after a restart of the vm, the counter advances 64000 units per second which should be enough that that value is never exceeded by the usage of that ID

Returns:
RAM unique ID