Clover coverage report - Code Coverage for hivemind release 1.1-alpha-1
Coverage timestamp: Tue Jan 18 2005 07:55:08 EST
file stats: LOC: 79   Methods: 3
NCLOC: 29   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
ServiceSerializationHelper.java 100% 100% 100% 100%
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 org.apache.commons.logging.Log;
 18   
 import org.apache.commons.logging.LogFactory;
 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 Log LOG = LogFactory.getLog(ServiceSerializationHelper.class);
 32   
 
 33   
     private static ServiceSerializationSupport _serviceSerializationSupport;
 34   
 
 35   
     /**
 36   
      * Returns the previously stored SSS.
 37   
      * 
 38   
      * @throws ApplicationRuntimeException
 39   
      *             if no SSS has been stored.
 40   
      */
 41  7
     public static ServiceSerializationSupport getServiceSerializationSupport()
 42   
     {
 43  7
         if (_serviceSerializationSupport == null)
 44  2
             throw new ApplicationRuntimeException(SerMessages.noSupportSet());
 45   
 
 46  5
         return _serviceSerializationSupport;
 47   
     }
 48   
 
 49   
     /**
 50   
      * Stores the SSS instance for later access; if an existing SSS is already stored, then an error
 51   
      * is logged (should be just one SSS per class loader).
 52   
      */
 53   
 
 54  664
     public static void setServiceSerializationSupport(
 55   
             ServiceSerializationSupport serviceSerializationSupport)
 56   
     {
 57  664
         if (serviceSerializationSupport != null && _serviceSerializationSupport != null)
 58  2
             LOG.error(SerMessages.supportAlreadySet(
 59   
                     serviceSerializationSupport,
 60   
                     _serviceSerializationSupport));
 61   
 
 62  664
         _serviceSerializationSupport = serviceSerializationSupport;
 63   
     }
 64   
 
 65   
     /**
 66   
      * Invoked to clear the SSS, if it matches the provide parameter. This is necessary, rather than
 67   
      * blindly setting it to null, because of a tricky case related to
 68   
      * {@link org.apache.hivemind.servlet.HiveMindFilter}, which includes the ability to create a
 69   
      * new Registry on the fly and has to leave both Registry's running for a brief window.
 70   
      */
 71   
 
 72  20
     public static void resetServiceSerializationSupport(
 73   
             ServiceSerializationSupport serviceSerializationSupport)
 74   
     {
 75  20
         if (_serviceSerializationSupport == serviceSerializationSupport)
 76  9
             _serviceSerializationSupport = null;
 77   
     }
 78   
 
 79   
 }