1 5 package org.exoplatform.container.configuration; 6 7 import java.util.* ; 8 9 15 public class Configuration { 16 private Map globalParam_ = new HashMap(); 17 private Map serviceConfiguration_ = new HashMap() ; 18 private Map groovyServiceConfiguration_ = new HashMap() ; 19 private List importConfiguration_ = new ArrayList() ; 20 private List removeConfiguration_ = new ArrayList() ; 21 22 public ValuesParam getInitParam(String name) { 23 return (ValuesParam) globalParam_.get(name) ; 24 } 25 26 public void addInitParam(ValuesParam param) { 27 globalParam_.put(param.getName(), param) ; 28 } 29 30 public ValuesParam removeInitParam(String name) { 31 return (ValuesParam) globalParam_.remove(name) ; 32 } 33 34 public ServiceConfiguration getServiceConfiguration(String service) { 35 if(service.endsWith(".groovy")) { 36 return (ServiceConfiguration) groovyServiceConfiguration_.get(service) ; 37 } 38 return (ServiceConfiguration) serviceConfiguration_.get(service) ; 39 } 40 41 public Collection getServiceConfigurations() { 42 return serviceConfiguration_.values(); 43 } 44 45 public Collection getGroovyServiceConfigurations() { 46 return groovyServiceConfiguration_.values(); 47 } 48 49 public void addServiceConfiguration(ServiceConfiguration sconf) { 50 String type = sconf.getServiceType() ; 51 if(type.endsWith(".groovy")) { 52 groovyServiceConfiguration_.put(sconf.getServiceType(), sconf) ; 53 } else { 54 String key = sconf.getServiceKey() ; 55 if(key == null) key = sconf.getServiceType() ; 56 serviceConfiguration_.put(key, sconf) ; 57 } 58 } 59 60 public ServiceConfiguration removeServiceConfiguration(String service) { 61 return (ServiceConfiguration) serviceConfiguration_.remove(service) ; 62 } 63 64 public void addImportConfiguration(String url) { 65 importConfiguration_.add(url) ; 66 } 67 68 public List getImportConfiguration() { return importConfiguration_ ; } 69 70 public void addRemoveConfiguration(String type) { 71 removeConfiguration_.add(type) ; 72 } 73 74 public List getRemoveConfiguration() { return removeConfiguration_ ; } 75 76 Map getGlobalParam() { return globalParam_ ; } 77 78 Map getServiceConfigurationMap() { return serviceConfiguration_ ; } 79 80 Map getGroovyServiceConfigurationMap() { return groovyServiceConfiguration_ ; } 81 82 void mergeConfiguration(Configuration other) { 83 globalParam_.putAll(other.getGlobalParam()) ; 84 serviceConfiguration_.putAll(other.getServiceConfigurationMap()) ; 85 groovyServiceConfiguration_.putAll(other.getGroovyServiceConfigurationMap()) ; 86 removeConfiguration_.addAll(other.getRemoveConfiguration()) ; 87 } 88 } 89 | Popular Tags |