Clover coverage report - Code Coverage for hivemind release 1.0-rc-1
Coverage timestamp: Wed Aug 25 2004 13:06:02 EDT
file stats: LOC: 79   Methods: 3
NCLOC: 48   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
MethodFabImpl.java - 100% 100% 100%
coverage
 1   
 //  Copyright 2004 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.hivemind.service.impl;
 16   
 
 17   
 import javassist.CtClass;
 18   
 import javassist.CtMethod;
 19   
 
 20   
 import org.apache.hivemind.ApplicationRuntimeException;
 21   
 import org.apache.hivemind.service.MethodFab;
 22   
 import org.apache.hivemind.service.MethodSignature;
 23   
 
 24   
 /**
 25   
  * Implementation of {@link org.apache.hivemind.service.MethodFab}, 
 26   
  * which is returned 
 27   
  * from {@link org.apache.hivemind.service.ClassFab#addMethod(int, String, Class, Class[], Class[], String)},
 28   
  * so that additional exception handlers may be attached to the added method.
 29   
  *
 30   
  * @author Howard Lewis Ship
 31   
  */
 32   
 class MethodFabImpl implements MethodFab
 33   
 {
 34   
     private CtClassSource _source;
 35   
     private MethodSignature _signature;
 36   
     private CtMethod _method;
 37   
 
 38  6282
     public MethodFabImpl(CtClassSource source, MethodSignature signature, CtMethod method)
 39   
     {
 40  6282
         _source = source;
 41  6282
         _signature = signature;
 42  6282
         _method = method;
 43   
     }
 44   
 
 45  19
     public void addCatch(Class exceptionClass, String catchBody)
 46   
     {
 47  19
         CtClass ctException = _source.getCtClass(exceptionClass);
 48   
 
 49  19
         try
 50   
         {
 51  19
             _method.addCatch(catchBody, ctException);
 52   
         }
 53   
         catch (Exception ex)
 54   
         {
 55  1
             throw new ApplicationRuntimeException(
 56   
                 ServiceMessages.unableToAddCatch(exceptionClass, _method, ex),
 57   
                 ex);
 58   
         }
 59   
     }
 60   
 
 61  3
     public void extend(String body, boolean asFinally)
 62   
     {
 63  3
         try
 64   
         {
 65  3
             _method.insertAfter(body, asFinally);
 66   
         }
 67   
         catch (Exception ex)
 68   
         {
 69  1
             throw new ApplicationRuntimeException(
 70   
                 ServiceMessages.unableToExtendMethod(
 71   
                     _signature,
 72   
                     _method.getDeclaringClass().getName(),
 73   
                     ex),
 74   
                 ex);
 75   
         }
 76   
     }
 77   
 
 78   
 }
 79