Clover coverage report - Apache Addressing - 1.0
Coverage timestamp: Tue Mar 22 2005 07:59:24 EST
file stats: LOC: 71   Methods: 2
NCLOC: 40   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
JugUUIdGenerator.java - 0% 0% 0%
coverage
 1   
 /*
 2   
  * Copyright  2004 The Apache Software Foundation.
 3   
  *
 4   
  *  Licensed under the Apache License, Version 2.0 (the "License");
 5   
  *  you may not use this file except in compliance with the License.
 6   
  *  You may obtain a copy of the License at
 7   
  *
 8   
  *      http://www.apache.org/licenses/LICENSE-2.0
 9   
  *
 10   
  *  Unless required by applicable law or agreed to in writing, software
 11   
  *  distributed under the License is distributed on an "AS IS" BASIS,
 12   
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13   
  *  See the License for the specific language governing permissions and
 14   
  *  limitations under the License.
 15   
  *
 16   
  */
 17   
 package org.apache.ws.addressing.uuid;
 18   
 
 19   
 import javax.xml.rpc.JAXRPCException;
 20   
 import java.lang.reflect.Method;
 21   
 
 22   
 /**
 23   
  * A {@link UUIdGenerator} implementation that uses JUG, an opensource Java UUID generation
 24   
  * library. Reflection is utilized to avoid a compile-time dependency on jug.jar.
 25   
  *
 26   
  * @author Ian P. Springer <ian_springer@hp.com>
 27   
  */
 28   
 public class JugUUIdGenerator implements UUIdGenerator {
 29   
 
 30   
     private static final String JUG_UUIDGENERATOR_CLASSNAME = "org.doomdark.uuid.UUIDGenerator";
 31   
     private static final String JUG_WEBSITE_URL = "http://www.doomdark.org/doomdark/proj/jug/";
 32   
 
 33   
     private static Method generateUUIdMethod;
 34   
     private static Method newInstanceMethod;
 35   
 
 36   
     static {
 37  0
         Class jugUuidGenClass = null;
 38  0
         try {
 39  0
             jugUuidGenClass = Class.forName(JUG_UUIDGENERATOR_CLASSNAME);
 40   
         } catch (ClassNotFoundException cnfe) {
 41  0
             throw new RuntimeException("Java UUID Generator (JUG) " + JUG_UUIDGENERATOR_CLASSNAME + " not found. Please add jug.jar, from " + JUG_WEBSITE_URL + ", to your classpath and restart.");
 42   
         }
 43  0
         try {
 44  0
             newInstanceMethod = jugUuidGenClass.getMethod("getInstance", new Class[0]);
 45  0
             generateUUIdMethod = jugUuidGenClass.getMethod("generateTimeBasedUUID", new Class[0]);
 46   
         } catch (Exception e) {
 47  0
             throw new RuntimeException("Fatal error initializing Java UUID Generator (JUG) " + JUG_UUIDGENERATOR_CLASSNAME + ".");
 48   
         }
 49   
     }
 50   
 
 51   
     private ThreadLocal JUG_UUIDGENERATOR =
 52   
             new ThreadLocal() {
 53  0
                 protected synchronized Object initialValue() {
 54  0
                     try {
 55  0
                         return newInstanceMethod.invoke(null, new Object[0]);
 56   
                     } catch (Exception e) {
 57  0
                         throw new RuntimeException(e);
 58   
                     }
 59   
                 }
 60   
             };
 61   
 
 62  0
     public String generateUUId() {
 63  0
         try {
 64  0
             return generateUUIdMethod.invoke(JUG_UUIDGENERATOR.get(), new Object[0]).toString();
 65   
         } catch (Exception e) {
 66  0
             throw new JAXRPCException(e);
 67   
         }
 68   
     }
 69   
 
 70   
 }
 71