Coverage Report - org.kuali.rice.kew.plugin.PluginConfig
 
Classes in this File Line Coverage Branch Coverage Complexity
PluginConfig
0%
0/28
0%
0/10
1.455
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kew.plugin;
 17  
 
 18  
 import org.kuali.rice.core.api.config.property.Config;
 19  
 import org.kuali.rice.core.impl.config.property.ConfigParserImplConfig;
 20  
 
 21  
 import java.io.File;
 22  
 import java.net.MalformedURLException;
 23  
 import java.net.URL;
 24  
 import java.util.ArrayList;
 25  
 import java.util.HashMap;
 26  
 import java.util.List;
 27  
 import java.util.Map;
 28  
 import java.util.Properties;
 29  
 
 30  
 /**
 31  
  * Class representing a plugin's config, containing configuration
 32  
  * settings parsed from the config.
 33  
  *
 34  
  * @see Config
 35  
  *
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  */
 38  
 public class PluginConfig extends ConfigParserImplConfig {
 39  
 
 40  
         private String resourceLoaderClassname;
 41  0
         private List listeners = new ArrayList();
 42  
         private Properties parentProperties;
 43  
         private Map parentObjects;
 44  
         private Config parentConfig;
 45  
 
 46  
         public PluginConfig(URL url, Config parentConfig) {
 47  0
                 super(url.toString());
 48  0
                 this.parentProperties = parentConfig.getProperties();
 49  0
                 this.parentObjects = parentConfig.getObjects();
 50  0
                 this.parentConfig = parentConfig;
 51  0
         }
 52  
 
 53  
         public PluginConfig(File configFile, Config parentConfig) throws MalformedURLException {
 54  0
                 this(configFile.toURI().toURL(), parentConfig);
 55  0
         }
 56  
 
 57  
         public Properties getBaseProperties() {
 58  0
                 return this.parentProperties;
 59  
         }
 60  
 
 61  
         public Map getBaseObjects() {
 62  0
                 return this.parentObjects;
 63  
         }
 64  
 
 65  
         public void addListener(String listenerClass) {
 66  0
                 listeners.add(listenerClass);
 67  0
         }
 68  
 
 69  
         public List getListeners() {
 70  0
                 return listeners;
 71  
         }
 72  
 
 73  
         public void setResourceLoaderClassname(String resourceLoaderClassname) {
 74  0
                 this.resourceLoaderClassname = resourceLoaderClassname;
 75  0
         }
 76  
 
 77  
         public String getResourceLoaderClassname() {
 78  0
                 return resourceLoaderClassname;
 79  
         }
 80  
 
 81  
     public String toString() {
 82  0
         return "[PluginConfig: resourceLoaderClassname: " + getResourceLoaderClassname() + "]";
 83  
     }
 84  
     
 85  
          
 86  
         @Override
 87  
         public Object getObject(String key) {
 88  0
                 Object object = super.getObject(key);
 89  0
                 if (object == null && parentConfig != null) {
 90  0
                         object = parentConfig.getObject(key);
 91  
                 }
 92  0
                 return object;
 93  
         }
 94  
 
 95  
         @Override
 96  
         public Map<String, Object> getObjects() {
 97  0
                 Map<String, Object> finalObjects = new HashMap<String, Object>(super.getObjects());
 98  0
                 if (parentConfig != null) {
 99  0
                         Map<String, Object> parentObjects = parentConfig.getObjects();
 100  0
                         for (String key : parentObjects.keySet()) {
 101  0
                                 if (!finalObjects.containsKey(key)) {
 102  0
                                         finalObjects.put(key, parentObjects.get(key));
 103  
                                 }
 104  
                         }
 105  
                 }
 106  
                 
 107  0
                 return finalObjects;
 108  
         }
 109  
 }