Clover coverage report - Code Coverage for hivemind release 1.1.1
Coverage timestamp: Sat Jan 28 2006 10:19:31 PST
file stats: LOC: 65   Methods: 2
NCLOC: 22   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ServiceSerializationHelper.java 75% 100% 100% 93.3%
coverage coverage
 1    // Copyright 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.internal.ser;
 16   
 17    import java.lang.ref.WeakReference;
 18   
 19    import org.apache.hivemind.ApplicationRuntimeException;
 20   
 21    /**
 22    * Class used to hold a <em>global</em> instance of
 23    * {@link org.apache.hivemind.internal.ser.ServiceSerializationSupport}, so that
 24    * {@link org.apache.hivemind.internal.ser.ServiceToken}s may locate them.
 25    *
 26    * @author Howard M. Lewis Ship
 27    * @since 1.1
 28    */
 29    public class ServiceSerializationHelper
 30    {
 31    private static final ThreadLocal _threadLocal = new ThreadLocal();
 32   
 33    /**
 34    * Returns the previously stored SSS.
 35    *
 36    * @throws ApplicationRuntimeException
 37    * if no SSS has been stored.
 38    */
 39  4 public static ServiceSerializationSupport getServiceSerializationSupport()
 40    {
 41  4 ServiceSerializationSupport result = null;
 42   
 43  4 WeakReference reference = (WeakReference) _threadLocal.get();
 44  4 if (reference != null)
 45  4 result = (ServiceSerializationSupport) reference.get();
 46   
 47  4 if (result == null)
 48  1 throw new ApplicationRuntimeException(SerMessages.noSupportSet());
 49   
 50  3 return result;
 51    }
 52   
 53    /**
 54    * Stores the SSS instance for later access; if an existing SSS is already stored, then an error
 55    * is logged (should be just one SSS per class loader).
 56    */
 57   
 58  770 public static void setServiceSerializationSupport(
 59    ServiceSerializationSupport serviceSerializationSupport)
 60    {
 61  770 WeakReference reference = new WeakReference(serviceSerializationSupport);
 62   
 63  770 _threadLocal.set(reference);
 64    }
 65    }