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: 94   Methods: 6
NCLOC: 56   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
ShutdownCoordinatorImpl.java 75% 88.9% 83.3% 84.4%
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 java.util.Iterator;
 18   
 
 19   
 import org.apache.commons.logging.Log;
 20   
 import org.apache.commons.logging.LogFactory;
 21   
 import org.apache.hivemind.*;
 22   
 import org.apache.hivemind.HiveMind;
 23   
 import org.apache.hivemind.events.RegistryShutdownListener;
 24   
 import org.apache.hivemind.util.EventListenerList;
 25   
 
 26   
 /**
 27   
  * Manages a list of objects that implement the
 28   
  * {@link org.apache.hivemind.events.RegistryShutdownListener} interface.
 29   
  *
 30   
  * @author Howard Lewis Ship
 31   
  */
 32   
 public final class ShutdownCoordinatorImpl implements ShutdownCoordinator
 33   
 {
 34   
     private final Log _log;
 35   
 
 36  80
     public ShutdownCoordinatorImpl()
 37   
     {
 38  80
         this(LogFactory.getLog(ShutdownCoordinatorImpl.class));
 39   
     }
 40   
 
 41  90
     public ShutdownCoordinatorImpl(Log log)
 42   
     {
 43  90
         _log = log;
 44   
     }
 45   
 
 46   
     private EventListenerList _listenerList;
 47   
 
 48  510
     public synchronized void addRegistryShutdownListener(RegistryShutdownListener s)
 49   
     {
 50  510
         if (_listenerList == null)
 51  83
             _listenerList = new EventListenerList();
 52   
 
 53  510
         _listenerList.addListener(s);
 54   
     }
 55   
 
 56  0
     public synchronized void removeRegistryShutdownListener(RegistryShutdownListener s)
 57   
     {
 58  0
         if (_listenerList != null)
 59  0
             _listenerList.removeListener(s);
 60   
     }
 61   
 
 62  22
     public void shutdown()
 63   
     {
 64  22
         if (_listenerList == null)
 65  8
             return;
 66   
 
 67  14
         Iterator i = _listenerList.getListeners();
 68   
 
 69  14
         _listenerList = null;
 70   
 
 71  14
         while (i.hasNext())
 72   
         {
 73  68
             RegistryShutdownListener s = (RegistryShutdownListener) i.next();
 74   
 
 75  68
             shutdown(s);
 76   
         }
 77   
 
 78  14
         _listenerList = null;
 79   
     }
 80   
 
 81  68
     private void shutdown(RegistryShutdownListener s)
 82   
     {
 83  68
         try
 84   
         {
 85  68
             s.registryDidShutdown();
 86   
         }
 87   
         catch (RuntimeException ex)
 88   
         {
 89  1
             _log.error(ImplMessages.shutdownCoordinatorFailure(s, ex), ex);
 90   
         }
 91   
     }
 92   
 
 93   
 }
 94