Clover coverage report - Code Coverage for hivemind release 1.0
Coverage timestamp: Wed Sep 22 2004 08:05:25 EDT
file stats: LOC: 129   Methods: 9
NCLOC: 83   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
InterceptorStackImpl.java 66.7% 92% 100% 90%
coverage 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.impl;
 16   
 
 17   
 import org.apache.commons.logging.Log;
 18   
 import org.apache.hivemind.ApplicationRuntimeException;
 19   
 import org.apache.hivemind.InterceptorStack;
 20   
 import org.apache.hivemind.internal.Module;
 21   
 import org.apache.hivemind.internal.ServiceInterceptorContribution;
 22   
 import org.apache.hivemind.internal.ServicePoint;
 23   
 import org.apache.hivemind.util.ToStringBuilder;
 24   
 
 25   
 /**
 26   
  * Implementation of the {@link org.apache.hivemind.InterceptorStack} interface; localizes
 27   
  * error checking in one place.
 28   
  *
 29   
  * @author Howard Lewis Ship
 30   
  */
 31   
 public final class InterceptorStackImpl implements InterceptorStack
 32   
 {
 33   
     private final Log _log;
 34   
 
 35   
     private ServiceInterceptorContribution _contribution;
 36   
     private ServicePoint _sep;
 37   
     private Class _interfaceClass;
 38   
     private Object _top;
 39   
 
 40  18
     public InterceptorStackImpl(Log log, ServicePoint sep, Object root)
 41   
     {
 42  18
         _log = log;
 43  18
         _sep = sep;
 44  18
         _top = root;
 45  18
         _interfaceClass = sep.getServiceInterface();
 46   
     }
 47   
 
 48  1
     public String toString()
 49   
     {
 50  1
         ToStringBuilder builder = new ToStringBuilder(this);
 51  1
         builder.append("contribution", _contribution);
 52  1
         builder.append("interfaceClass", _interfaceClass);
 53  1
         builder.append("top", _top);
 54   
 
 55  1
         return builder.toString();
 56   
     }
 57   
 
 58  11
     public String getServiceExtensionPointId()
 59   
     {
 60  11
         return _sep.getExtensionPointId();
 61   
     }
 62   
 
 63  12
     public Module getServiceModule()
 64   
     {
 65  12
         return _sep.getModule();
 66   
     }
 67   
 
 68  51
     public Class getServiceInterface()
 69   
     {
 70  51
         return _interfaceClass;
 71   
     }
 72   
 
 73  42
     public Object peek()
 74   
     {
 75  42
         return _top;
 76   
     }
 77   
 
 78  16
     public void push(Object interceptor)
 79   
     {
 80  16
         if (interceptor == null)
 81  0
             throw new ApplicationRuntimeException(
 82   
                 ImplMessages.nullInterceptor(_contribution, _sep),
 83   
                 _contribution.getLocation(),
 84   
                 null);
 85   
 
 86  16
         if (!_interfaceClass.isAssignableFrom(interceptor.getClass()))
 87  0
             throw new ApplicationRuntimeException(
 88   
                 ImplMessages.interceptorDoesNotImplementInterface(
 89   
                     interceptor,
 90   
                     _contribution,
 91   
                     _sep,
 92   
                     _interfaceClass),
 93   
                 _contribution.getLocation(),
 94   
                 null);
 95   
 
 96  16
         _top = interceptor;
 97   
     }
 98   
 
 99   
     /**
 100   
      * Invoked to process the next interceptor contribution; these should
 101   
      * be processed in ascending order.
 102   
      * 
 103   
      */
 104   
 
 105  18
     public void process(ServiceInterceptorContribution contribution)
 106   
     {
 107  18
         if (_log.isDebugEnabled())
 108  4
             _log.debug("Applying interceptor factory " + contribution.getFactoryServiceId());
 109   
 
 110   
         // And now we can finally do this!
 111   
 
 112  18
         try
 113   
         {
 114  18
             _contribution = contribution;
 115   
 
 116  18
             contribution.createInterceptor(this);
 117   
         }
 118   
         finally
 119   
         {
 120  18
             _contribution = null;
 121   
         }
 122   
     }
 123   
 
 124  12
     public Log getServiceLog()
 125   
     {
 126  12
         return _log;
 127   
     }
 128   
 }
 129