站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss RULES 4.0.0.11754MR2 API 英文版文档

UUIDGenerator (Drools 4.0.0.11754MR2 API) - JBoss RULES 4.0.0.11754MR2 API 英文版文档


org.drools.util
Class UUIDGenerator

java.lang.Object
  extended by org.drools.util.UUIDGenerator

public final class UUIDGenerator
extends Object

Ripped from JUG

See Also:
org.safehaus.jug

Method Summary
 UUID generateRandomBasedUUID()
          Method for generating (pseudo-)random based UUIDs, using the default (shared) SecureRandom object.
 UUID generateRandomBasedUUID(Random randomGenerator)
          Method for generating (pseudo-)random based UUIDs, using the specified SecureRandom object.
 MessageDigest getHashAlgorithm()
           
static UUIDGenerator getInstance()
          Method used for accessing the singleton generator instance.
 Random getRandomNumberGenerator()
          Method for getting the shared random number generator used for generating the UUIDs.
 void setRandomNumberGenerator(Random r)
          Method that can be called to specify alternative random number generator to use.
 
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()
Method used for accessing the singleton generator instance.


getRandomNumberGenerator

public Random getRandomNumberGenerator()
Method for getting the shared random number generator used for generating the UUIDs. This way the initialization cost is only taken once; access need not be synchronized (or in cases where it has to, SecureRandom takes care of it); it might even be good for getting really 'random' stuff to get shared access...


setRandomNumberGenerator

public void setRandomNumberGenerator(Random r)
Method that can be called to specify alternative random number generator to use. This is usually done to use implementation that is faster than SecureRandom that is used by default.

Note that to avoid first-time initialization penalty of using SecureRandom, this method has to be called before generating the first random-number based UUID.


getHashAlgorithm

public MessageDigest getHashAlgorithm()

generateRandomBasedUUID

public UUID generateRandomBasedUUID()
Method for generating (pseudo-)random based UUIDs, using the default (shared) SecureRandom object. Note that the first time SecureRandom object is used, there is noticeable delay between calling the method and getting the reply. This is because SecureRandom has to initialize itself to reasonably random state. Thus, if you want to lessen delay, it may be be a good idea to either get the first random UUID asynchronously from a separate thread, or to use the other generateRandomBasedUUID passing a previously initialized SecureRandom instance.

Returns:
UUID generated using (pseudo-)random based method

generateRandomBasedUUID

public UUID generateRandomBasedUUID(Random randomGenerator)
Method for generating (pseudo-)random based UUIDs, using the specified SecureRandom object. To prevent/avoid delay JDK's default SecureRandom object causes when first random number is generated, it may be a good idea to initialize the SecureRandom instance (on a separate thread for example) when app starts.

Parameters:
randomGenerator - Random number generator to use for getting the random number from which UUID will be composed.
Returns:
UUID generated using (pseudo-)random based method


Copyright © 2001-2007 JBoss Inc.. All Rights Reserved.