commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r372029 - in /jakarta/commons/sandbox/id/trunk/src: java/org/apache/commons/id/ java/org/apache/commons/id/task/ java/org/apache/commons/id/uuid/ test/org/apache/commons/id/
Date Tue, 24 Jan 2006 21:51:38 GMT
Author: joehni
Date: Tue Jan 24 13:51:23 2006
New Revision: 372029

URL: http://svn.apache.org/viewcvs?rev=372029&view=rev
Log:
Dropped IdentifierGeneratorFactory and derived.
Dropped IdentifierUtils.

Removed:
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/DefaultIdentifierGeneratorFactory.java
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/IdentifierGeneratorFactory.java
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/IdentifierUtils.java
    jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/CustomIdentifierGeneratorFactory.java
    jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/IdentifierGeneratorFactoryTest.java
    jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/IdentifierUtilsTest.java
Modified:
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/task/UUIDTask.java
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/UUID.java
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionFourGenerator.java
    jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionOneGenerator.java

Modified: jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/task/UUIDTask.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/task/UUIDTask.java?rev=372029&r1=372028&r2=372029&view=diff
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/task/UUIDTask.java (original)
+++ jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/task/UUIDTask.java Tue
Jan 24 13:51:23 2006
@@ -16,7 +16,6 @@
 
 package org.apache.commons.id.task;
 
-import org.apache.commons.id.IdentifierUtils;
 import org.apache.commons.id.uuid.UUID;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
@@ -59,7 +58,7 @@
 			uuid = UUID.nameUUIDFromString(name, new UUID(namespace), UUID.SHA1_ENCODING);
 		}
 		else if (uuidVersion.equals("VERSION_FOUR")) {
-			uuid = (UUID) IdentifierUtils.UUID_VERSION_FOUR_GENERATOR.nextIdentifier();
+			uuid = UUID.randomUUID();
 		}
 		else if (uuidVersion.equals("VERSION_ONE")) {
 			uuid = UUID.timeUUID();

Modified: jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/UUID.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/UUID.java?rev=372029&r1=372028&r2=372029&view=diff
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/UUID.java (original)
+++ jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/UUID.java Tue Jan
24 13:51:23 2006
@@ -15,16 +15,15 @@
  */
 package org.apache.commons.id.uuid;
 
+import org.apache.commons.id.DecoderException;
+import org.apache.commons.id.DigestUtils;
+import org.apache.commons.id.Hex;
+
 import java.io.DataInput;
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.StringTokenizer;
 
-import org.apache.commons.id.DecoderException;
-import org.apache.commons.id.DigestUtils;
-import org.apache.commons.id.Hex;
-import org.apache.commons.id.IdentifierUtils;
-
 
 /**
  * <p><code>UUID</code> represents a Universally Unique Identifier per
RFC 4122.
@@ -60,7 +59,6 @@
 	/** Holds the internal string value of the UUID */
 	private String stringValue = null;
 	
-	
 	/** Constructs a nil UUID */
 	public UUID() {
 		super();
@@ -406,7 +404,7 @@
 	 * @return a new version 4 UUID, based upon Random bits.
 	 */
 	public static UUID randomUUID() {
-		return (UUID) IdentifierUtils.UUID_VERSION_FOUR_GENERATOR.nextIdentifier();
+                return VersionFourGenerator.getInstance().nextUUID();
 	}
 	
 	/**
@@ -415,7 +413,7 @@
 	 * @return a new version 1 UUID, based upon node identifier and time stamp.
 	 */
 	public static UUID timeUUID() {
-		return (UUID) IdentifierUtils.UUID_VERSION_ONE_GENERATOR.nextIdentifier();
+		return VersionOneGenerator.getInstance().nextUUID();
 	}
 	
 	/**

Modified: jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionFourGenerator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionFourGenerator.java?rev=372029&r1=372028&r2=372029&view=diff
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionFourGenerator.java
(original)
+++ jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionFourGenerator.java
Tue Jan 24 13:51:23 2006
@@ -15,13 +15,13 @@
  */
 package org.apache.commons.id.uuid;
 
+import org.apache.commons.id.IdentifierGenerator;
+
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
 import java.security.SecureRandom;
 import java.util.Random;
 
-import org.apache.commons.id.IdentifierGenerator;
-
 /**
  * <p>Class is responsible for generating version 4 UUID's per RFC 4122.
  * This class attempts to use a java.security.SecureRandom with
@@ -51,6 +51,8 @@
 
         /** The pseudo-random number generator package name to use */
         private static String usePRNGPackage = "SUN";
+        
+        private static VersionFourGenerator generator;
 
         /**
          * <p>Constructs a new VersionFourGenerator.</p>
@@ -60,6 +62,18 @@
         }
 
         /**
+         * <p>Returns a singleton instance of the version four UUID generator.</p>
+         *
+         * @return the singleton instance of the version four UUID generator.
+         */
+        public static VersionFourGenerator getInstance() {
+                if (generator == null) {
+                    generator = new VersionFourGenerator();
+                }
+                return generator;
+        }
+
+        /**
          * <p>Returns a new version four UUID.</p>
          *
          * @return Object a new version 4 UUID.
@@ -89,7 +103,7 @@
         *
         * @return Object a new version 4 UUID.
         */
-        private UUID nextUUID() {
+        public UUID nextUUID() {
             //Call nextUUID with secure = false
             return nextUUID(false);
         }

Modified: jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionOneGenerator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionOneGenerator.java?rev=372029&r1=372028&r2=372029&view=diff
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionOneGenerator.java
(original)
+++ jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/VersionOneGenerator.java
Tue Jan 24 13:51:23 2006
@@ -15,8 +15,6 @@
  */
 package org.apache.commons.id.uuid;
 
-import java.lang.reflect.InvocationTargetException;
-
 import org.apache.commons.discovery.tools.DiscoverSingleton;
 import org.apache.commons.id.IdentifierGenerator;
 import org.apache.commons.id.uuid.clock.OverClockedException;
@@ -40,7 +38,7 @@
 public final class VersionOneGenerator implements IdentifierGenerator, Constants {
 
     /** Positions 10-16: Length of node bytes */
-    protected static final int NODE_ID_BYTE_LENGTH = 6;
+    private static final int NODE_ID_BYTE_LENGTH = 6;
 
     /** Position 8: CLOCK_SEQ_LOW byte */
     private static final int CLOCK_HI_VARIANT_BYTE8 = 8;
@@ -62,14 +60,8 @@
 
     /**
      *  <p>Private singleton constructor.</p>
-     *
-     * @throws NoSuchMethodException exception instantiating from DiscoverClass.
-     * @throws InvocationTargetException exception instantiating from DiscoverClass.
-     * @throws IllegalAccessException exception instantiating from DiscoverClass.
-     * @throws InstantiationException exception instantiating from DiscoverClass.
      */
-    private VersionOneGenerator() throws NoSuchMethodException, InvocationTargetException,
IllegalAccessException,
-        InstantiationException {
+    private VersionOneGenerator() {
         super();
         manager = (NodeManager) DiscoverSingleton.find( NodeManager.class, DEFAULT_NODEMANAGER_IMPL);
     }
@@ -78,18 +70,14 @@
      * <p>Returns the singleton instance of the version one UUID generator.</p>
      *
      * @return the singleton instance of the version one UUID generator.
-     * @throws NoSuchMethodException exception instantiating from DiscoverClass.
-     * @throws InvocationTargetException exception instantiating from DiscoverClass.
-     * @throws IllegalAccessException exception instantiating from DiscoverClass.
-     * @throws InstantiationException exception instantiating from DiscoverClass.
      */
-    public static VersionOneGenerator getInstance() throws NoSuchMethodException, InvocationTargetException,
IllegalAccessException,
-        InstantiationException {
+    public static VersionOneGenerator getInstance()  {
             if (generator == null) {
                 generator = new VersionOneGenerator();
             }
             return generator;
     }
+    
     /**
      * @see org.apache.commons.id.IdentifierGenerator#nextIdentifier()
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message