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