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