KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > container > configuration > Configuration


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.container.configuration;
6
7 import java.util.* ;
8
9 /**
10  * Jul 19, 2004
11  * @author: Tuan Nguyen
12  * @email: tuan08@users.sourceforge.net
13  * @version: $Id: Configuration.java,v 1.3 2004/10/29 01:55:23 tuan08 Exp $
14  */

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 JavaDoc 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 JavaDoc name) {
31     return (ValuesParam) globalParam_.remove(name) ;
32   }
33   
34   public ServiceConfiguration getServiceConfiguration(String JavaDoc 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 JavaDoc type = sconf.getServiceType() ;
51     if(type.endsWith(".groovy")) {
52       groovyServiceConfiguration_.put(sconf.getServiceType(), sconf) ;
53     } else {
54       String JavaDoc key = sconf.getServiceKey() ;
55       if(key == null) key = sconf.getServiceType() ;
56       serviceConfiguration_.put(key, sconf) ;
57     }
58   }
59   
60   public ServiceConfiguration removeServiceConfiguration(String JavaDoc service) {
61     return (ServiceConfiguration) serviceConfiguration_.remove(service) ;
62   }
63   
64   public void addImportConfiguration(String JavaDoc url) {
65     importConfiguration_.add(url) ;
66   }
67   
68   public List getImportConfiguration() { return importConfiguration_ ; }
69   
70   public void addRemoveConfiguration(String JavaDoc 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