juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svi...@apache.org
Subject cvs commit: ws-juddi/src/java/org/apache/juddi/uuidgen UUIDGen.java NativeUUIDGen.java
Date Mon, 22 Mar 2004 14:23:33 GMT
sviens      2004/03/22 06:23:33

  Modified:    src/java/org/apache/juddi/uuidgen UUIDGen.java
                        NativeUUIDGen.java
  Log:
  Reformatted source (the entire class was on one line - wierd).
  
  Revision  Changes    Path
  1.3       +28 -1     ws-juddi/src/java/org/apache/juddi/uuidgen/UUIDGen.java
  
  Index: UUIDGen.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/uuidgen/UUIDGen.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UUIDGen.java	11 Mar 2004 18:06:22 -0000	1.2
  +++ UUIDGen.java	22 Mar 2004 14:23:33 -0000	1.3
  @@ -12,4 +12,31 @@
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
  - */package org.apache.juddi.uuidgen;/** * A Universally Unique Identifier (UUID) is a 128
bit number generated * according to an algorithm that is garanteed to be unique in time and
space * from all other UUIDs. It consists of an IEEE 802 Internet Address and * various time
stamps to ensure uniqueness. For a complete specification, * see ftp://ietf.org/internet-drafts/draft-leach-uuids-guids-01.txt
[leach]. * * @author Steve Viens (sviens@apache.org) */public interface UUIDGen{  /**   *
  */  String uuidgen();  /**   *   */  String[] uuidgen(int nmbr);}
  \ No newline at end of file
  + */
  +package org.apache.juddi.uuidgen;
  +
  +/**
  + * A Universally Unique Identifier (UUID) is a 128 bit number generated
  + * according to an algorithm that is garanteed to be unique in time and space 
  + * from all other UUIDs. It consists of an IEEE 802 Internet Address and 
  + * various time stamps to ensure uniqueness. For a complete specification, 
  + * see ftp://ietf.org/internet-drafts/draft-leach-uuids-guids-01.txt [leach].
  + *  
  + * @author Steve Viens (sviens@apache.org) 
  + */
  +public interface UUIDGen
  +{  
  +  /**
  +   * Generates a UUID and returns it's value as a String
  +   * @return The new UUID value as a String
  +   */
  +  String uuidgen(); 
  +  
  +  /**
  +   * Generates a collection of UUID's and returns thier 
  +   * values as an array of Strings 
  +   * @param nmbr The number of UUID's to generate
  +   * @return An array of UUID's as String objects
  +   */
  +  String[] uuidgen(int nmbr);
  +}
  \ No newline at end of file
  
  
  
  1.3       +84 -1     ws-juddi/src/java/org/apache/juddi/uuidgen/NativeUUIDGen.java
  
  Index: NativeUUIDGen.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/uuidgen/NativeUUIDGen.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NativeUUIDGen.java	11 Mar 2004 18:06:22 -0000	1.2
  +++ NativeUUIDGen.java	22 Mar 2004 14:23:33 -0000	1.3
  @@ -12,4 +12,87 @@
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
  - */package org.apache.juddi.uuidgen;import java.io.BufferedReader;import java.io.IOException;import
java.io.InputStreamReader;import org.apache.juddi.util.Config;/** * Used to create new universally
unique identifiers or UUID's * (sometimes called GUID's).  UDDI UUID's are allways formmated
* according to DCE UUID conventions. * * @author Steve Viens (sviens@apache.org) */public
final class NativeUUIDGen implements UUIDGen{  private static final String COMMAND_KEY = "juddi.uuidgenCommand";
 private static final String DEFAULT_COMMAND = "uuidgen";  private String command = null;
 /**   *   */  public NativeUUIDGen()  {    this.command =        Config.getStringProperty(COMMAND_KEY,DEFAULT_COMMAND);
 }  /**   *   */  public String uuidgen()  {    try    {      Runtime r = Runtime.getRuntime();
     Process p = r.exec(command);      BufferedReader x = new BufferedReader(            
             new InputStreamReader(                            p.getInputStream()));     
return x.readLine();    }    catch (IOException e)    {      e.printStackTrace();    }   
return null;  }  /**   *   */  public String[] uuidgen(int nmbr)  {    String[] uuids = new
String[nmbr];    for (int i=0; i<uuids.length; i++)      uuids[i] = uuidgen();    return
uuids;  }  /***************************************************************************/ 
/***************************** TEST DRIVER *********************************/  /***************************************************************************/
 public static void main(String argc[])  {    UUIDGen generator = new NativeUUIDGen();   
long start = System.currentTimeMillis();    for (int i = 1; i <= 100; ++i)      generator.uuidgen();
   long end = System.currentTimeMillis();    System.out.println("\nNativeUUIDGen: Generation
of 100 UUID's took " +      (end-start)+" milliseconds.");  }}
  \ No newline at end of file
  + */
  +package org.apache.juddi.uuidgen;
  +
  +import java.io.BufferedReader;
  +import java.io.IOException;
  +import java.io.InputStreamReader;
  +
  +import org.apache.juddi.util.Config;
  +
  +/**
  + * Used to create new universally unique identifiers or UUID's
  + * (sometimes called GUID's).  UDDI UUID's are allways formmated
  + * according to DCE UUID conventions.
  + * 
  + * @author Steve Viens (sviens@apache.org)
  + */
  +public final class NativeUUIDGen implements UUIDGen
  +{
  +  private static final String COMMAND_KEY = "juddi.uuidgenCommand";
  +  private static final String DEFAULT_COMMAND = "uuidgen";
  +  private String command = null;
  +  
  +  /**
  +   *
  +   */
  +  public NativeUUIDGen()
  +  {     
  +        this.command = Config.getStringProperty(COMMAND_KEY,DEFAULT_COMMAND);
  +  }
  +  
  +  /**
  +   *
  +   */
  +  public String uuidgen()
  +  {
  +    try
  +    {
  +      Runtime r = Runtime.getRuntime();
  +      Process p = r.exec(command);
  +      BufferedReader x = new BufferedReader(
  +                new InputStreamReader(p.getInputStream()));
  +      
  +      return x.readLine();
  +    }    
  +    catch (IOException e)
  +    {      
  +        e.printStackTrace();
  +    }    
  +    
  +    return null;
  +  }  
  +  
  +  /**
  +   *
  +   */
  +  public String[] uuidgen(int nmbr) 
  +  {    
  +        String[] uuids = new String[nmbr];
  +    for (int i=0; i<uuids.length; i++)
  +      uuids[i] = uuidgen();    
  +  
  +    return uuids; 
  +  }  
  +        
  +                
  +  /***************************************************************************/
  +  /***************************** TEST DRIVER *********************************/
  +  /***************************************************************************/
  +  
  +        
  +  public static void main(String args[])
  +  {
  +    UUIDGen generator = new NativeUUIDGen();
  +    long start = System.currentTimeMillis();
  +
  +    for (int i = 1; i <= 100; ++i)
  +        generator.uuidgen();
  +
  +    long end = System.currentTimeMillis();
  +
  +    System.out.println("\nNativeUUIDGen: Generation of 100 UUID's took " +
  +                (end-start)+" milliseconds.");  
  +  }
  +}
  \ No newline at end of file
  
  
  

Mime
View raw message