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