Coverage Report - org.mule.util.compression.CompressionHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
CompressionHelper
0%
0/7
0%
0/2
2.333
CompressionHelper$1
0%
0/8
0%
0/2
2.333
 
 1  
 /*
 2  
  * $Id: CompressionHelper.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.util.compression;
 12  
 
 13  
 import org.mule.util.ClassUtils;
 14  
 
 15  
 import java.security.AccessController;
 16  
 import java.security.PrivilegedAction;
 17  
 
 18  
 import org.apache.commons.logging.Log;
 19  
 import org.apache.commons.logging.LogFactory;
 20  
 
 21  
 /**
 22  
  * <code>CompressionHelper</code> a static class that provides facilities for
 23  
  * compressing and uncompressing byte arrays
 24  
  */
 25  
 
 26  0
 public final class CompressionHelper
 27  
 {
 28  
     /**
 29  
      * logger used by this class
 30  
      */
 31  0
     private static Log logger = LogFactory.getLog(CompressionHelper.class);
 32  
 
 33  
     private static CompressionStrategy defaultStrategy;
 34  
 
 35  
     /** Do not instanciate. */
 36  
     private CompressionHelper ()
 37  0
     {
 38  
         // no-op
 39  0
     }
 40  
 
 41  
     public static synchronized CompressionStrategy getDefaultCompressionStrategy()
 42  
     {
 43  0
         if (defaultStrategy == null)
 44  
         {
 45  0
             defaultStrategy = (CompressionStrategy) AccessController.doPrivileged(new PrivilegedAction()
 46  0
             {
 47  
                 public Object run()
 48  
                 {
 49  
                     try
 50  
                     {
 51  0
                         Object o = ClassUtils.loadClass(CompressionStrategy.COMPRESSION_DEFAULT,
 52  
                             CompressionHelper.class).newInstance();
 53  0
                         if (logger.isDebugEnabled())
 54  
                         {
 55  0
                             logger.debug("Found CompressionStrategy: " + o.getClass().getName());
 56  
                         }
 57  0
                         return o;
 58  
                     }
 59  0
                     catch (Exception e)
 60  
                     {
 61  
                         // TODO MULE-863: What should we really do?  Document this?
 62  0
                         logger.warn("Failed to build compression strategy: " + e.getMessage());
 63  
                     }
 64  0
                     return null;
 65  
                 }
 66  
             });
 67  
         }
 68  0
         return defaultStrategy;
 69  
     }
 70  
 
 71  
 }