2009/04/15 - Apache HiveMind has been retired.

For more information, please explore the Attic.

Clover coverage report - Code Coverage for hivemind-lib release 1.2.1
Coverage timestamp: Fri Feb 10 2006 16:34:07 PST
file stats: LOC: 92   Methods: 4
NCLOC: 52   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RemoteExceptionCoordinatorImpl.java 20% 19% 50% 22.9%
coverage coverage
 1    // Copyright 2004, 2005 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.lib.impl;
 16   
 17    import java.util.ArrayList;
 18    import java.util.List;
 19   
 20    import org.apache.hivemind.ApplicationRuntimeException;
 21    import org.apache.hivemind.lib.RemoteExceptionCoordinator;
 22    import org.apache.hivemind.lib.RemoteExceptionEvent;
 23    import org.apache.hivemind.lib.RemoteExceptionListener;
 24   
 25    /**
 26    * Core implementation of {@link org.apache.hivemind.lib.RemoteExceptionCoordinator}.
 27    *
 28    * @author Howard Lewis Ship
 29    */
 30   
 31    public class RemoteExceptionCoordinatorImpl implements RemoteExceptionCoordinator
 32    {
 33    private boolean _locked;
 34    private List _listeners;
 35   
 36  2 private void checkLocked(String methodName)
 37    {
 38  2 if (_locked)
 39  0 throw new ApplicationRuntimeException(ImplMessages.coordinatorLocked(methodName));
 40    }
 41   
 42  0 public synchronized void addRemoteExceptionListener(RemoteExceptionListener listener)
 43    {
 44  0 checkLocked("addRemoteExceptionListener");
 45   
 46  0 if (_listeners == null)
 47  0 _listeners = new ArrayList();
 48   
 49  0 _listeners.add(listener);
 50    }
 51   
 52  0 public synchronized void removeRemoteExceptionListener(RemoteExceptionListener listener)
 53    {
 54  0 checkLocked("removeRemoteExceptionListener");
 55   
 56  0 if (_listeners == null)
 57  0 return;
 58   
 59  0 _listeners.remove(listener);
 60    }
 61   
 62  2 public synchronized void fireRemoteExceptionDidOccur(Object source, Throwable exception)
 63    {
 64  2 checkLocked("sendNotification");
 65   
 66  2 if (_listeners == null || _listeners.size() == 0)
 67  2 return;
 68   
 69  0 RemoteExceptionEvent event = new RemoteExceptionEvent(source, exception);
 70   
 71  0 int count = _listeners.size();
 72   
 73  0 _locked = true;
 74   
 75  0 try
 76    {
 77   
 78  0 for (int i = 0; i < count; i++)
 79    {
 80  0 RemoteExceptionListener listener = (RemoteExceptionListener) _listeners.get(i);
 81   
 82  0 listener.remoteExceptionDidOccur(event);
 83    }
 84    }
 85    finally
 86    {
 87  0 _locked = false;
 88    }
 89   
 90    }
 91   
 92    }