Coverage Report - org.mule.module.launcher.descriptor.PropertiesDescriptorParser
 
Classes in this File Line Coverage Branch Coverage Complexity
PropertiesDescriptorParser
0%
0/17
0%
0/2
1.5
 
 1  
 /*
 2  
  * $Id: PropertiesDescriptorParser.java 20792 2010-12-16 16:58:49Z aperepel $
 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.module.launcher.descriptor;
 12  
 
 13  
 import org.mule.util.StringUtils;
 14  
 
 15  
 import java.io.File;
 16  
 import java.io.FileInputStream;
 17  
 import java.io.IOException;
 18  
 import java.util.Properties;
 19  
 
 20  
 import org.apache.commons.lang.BooleanUtils;
 21  
 
 22  
 /**
 23  
  *
 24  
  */
 25  0
 public class PropertiesDescriptorParser implements DescriptorParser
 26  
 {
 27  
     protected static final String PROPERTY_ENCODING = "encoding";
 28  
     protected static final String PROPERTY_CONFIG_BUILDER = "config.builder";
 29  
     protected static final String PROPERTY_DOMAIN = "domain";
 30  
     // support not yet implemented for CL reversal
 31  
     protected static final String PROPERTY_CLASSLOADER_PARENT_FIRST = "classloader.parentFirst";
 32  
     protected static final String PROPERTY_CONFIG_RESOURCES = "config.resources";
 33  
     protected static final String PROPERTY_REDEPLOYMENT_ENABLED = "redeployment.enabled";
 34  
     protected static final String PROPERTY_PRIVILEDGED = "priviledged";
 35  
 
 36  
     public ApplicationDescriptor parse(File descriptor) throws IOException
 37  
     {
 38  0
         final Properties p = new Properties();
 39  0
         p.load(new FileInputStream(descriptor));
 40  
 
 41  0
         ApplicationDescriptor d = new ApplicationDescriptor();
 42  0
         d.setEncoding(p.getProperty(PROPERTY_ENCODING));
 43  0
         d.setConfigurationBuilder(p.getProperty(PROPERTY_CONFIG_BUILDER));
 44  0
         d.setDomain(p.getProperty(PROPERTY_DOMAIN));
 45  
 
 46  
         // supports 'true' (case insensitive), 'yes', 'on' as positive values
 47  0
         d.setParentFirstClassLoader(BooleanUtils.toBoolean(p.getProperty(PROPERTY_CLASSLOADER_PARENT_FIRST, Boolean.TRUE.toString())));
 48  
 
 49  0
         final String resProps = p.getProperty(PROPERTY_CONFIG_RESOURCES);
 50  
         String[] urls;
 51  0
         if (StringUtils.isBlank(resProps))
 52  
         {
 53  0
             urls = new String[] {ApplicationDescriptor.DEFAULT_CONFIGURATION_RESOURCE};
 54  
         }
 55  
         else
 56  
         {
 57  0
             urls = resProps.split(",");
 58  
         }
 59  0
         d.setConfigResources(urls);
 60  
 
 61  
         // supports true (case insensitive), yes, on as positive values
 62  0
         d.setRedeploymentEnabled(BooleanUtils.toBoolean(p.getProperty(PROPERTY_REDEPLOYMENT_ENABLED, Boolean.TRUE.toString())));
 63  
 
 64  0
         d.setPriviledged(BooleanUtils.toBoolean(p.getProperty(PROPERTY_PRIVILEDGED, Boolean.FALSE.toString())));
 65  
 
 66  0
         return d;
 67  
     }
 68  
 
 69  
     public String getSupportedFormat()
 70  
     {
 71  0
         return "properties";
 72  
     }
 73  
 }