Clover coverage report - Code Coverage for hivemind release 1.0-rc-2
Coverage timestamp: Sat Sep 11 2004 09:09:48 EDT
file stats: LOC: 93   Methods: 6
NCLOC: 55   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.ShutdownCoordinator;
 22   
 import org.apache.hivemind.events.RegistryShutdownListener;
 23   
 import org.apache.hivemind.util.EventListenerList;
 24   
 
 25   
 /**
 26   
  * Manages a list of objects that implement the
 27   
  * {@link org.apache.hivemind.events.RegistryShutdownListener} interface.
 28   
  *
 29   
  * @author Howard Lewis Ship
 30   
  */
 31   
 public final class ShutdownCoordinatorImpl implements ShutdownCoordinator
 32   
 {
 33   
     private final Log _log;
 34   
 
 35  98
     public ShutdownCoordinatorImpl()
 36   
     {
 37  98
         this(LogFactory.getLog(ShutdownCoordinatorImpl.class));
 38   
     }
 39   
 
 40  117
     public ShutdownCoordinatorImpl(Log log)
 41   
     {
 42  117
         _log = log;
 43   
     }
 44   
 
 45   
     private EventListenerList _listenerList;
 46   
 
 47  1205
     public synchronized void addRegistryShutdownListener(RegistryShutdownListener s)
 48   
     {
 49  1205
         if (_listenerList == null)
 50  102
             _listenerList = new EventListenerList();
 51   
 
 52  1205
         _listenerList.addListener(s);
 53   
     }
 54   
 
 55  0
     public synchronized void removeRegistryShutdownListener(RegistryShutdownListener s)
 56   
     {
 57  0
         if (_listenerList != null)
 58  0
             _listenerList.removeListener(s);
 59   
     }
 60   
 
 61  40
     public void shutdown()
 62   
     {
 63  40
         if (_listenerList == null)
 64  16
             return;
 65   
 
 66  24
         Iterator i = _listenerList.getListeners();
 67   
 
 68  24
         _listenerList = null;
 69   
 
 70  24
         while (i.hasNext())
 71   
         {
 72  232
             RegistryShutdownListener s = (RegistryShutdownListener) i.next();
 73   
 
 74  232
             shutdown(s);
 75   
         }
 76   
 
 77  24
         _listenerList = null;
 78   
     }
 79   
 
 80  232
     private void shutdown(RegistryShutdownListener s)
 81   
     {
 82  232
         try
 83   
         {
 84  232
             s.registryDidShutdown();
 85   
         }
 86   
         catch (RuntimeException ex)
 87   
         {
 88  1
             _log.error(ImplMessages.shutdownCoordinatorFailure(s, ex), ex);
 89   
         }
 90   
     }
 91   
 
 92   
 }
 93