KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > container > config > ContainerComponentsXmlLoader


1 /*
2  * Copyright 2003-2006 the original author or authors.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  */

16 package com.jdon.container.config;
17
18 import java.util.Iterator JavaDoc;
19 import java.util.List JavaDoc;
20 import java.util.Map JavaDoc;
21
22 import org.jdom.Element;
23
24 import com.jdon.controller.config.XmlParser;
25 import com.jdon.util.Debug;
26
27 /**
28  * @author <a HREF="mailto:banqiao@jdon.com">banq</a>
29  *
30  */

31 public class ContainerComponentsXmlLoader extends XmlParser {
32     public final static String JavaDoc module = ContainerComponentsXmlLoader.class.getName();
33
34     public void parse(Element root, Map JavaDoc mps) throws Exception JavaDoc {
35         List JavaDoc components = root.getChildren("component");
36         Debug.logVerbose("[JdonFramework] found component size:" + components.size(), module);
37         Iterator JavaDoc iter = components.iterator();
38         
39         ComponentMetaDef componentMetaDef;
40         
41         while (iter.hasNext()) {
42           Element component = (Element) iter.next();
43           String JavaDoc name = component.getAttributeValue("name");
44           String JavaDoc className = component.getAttributeValue("class");
45           List JavaDoc mappings = component.getChildren("constructor");
46           String JavaDoc[] constructors = null;
47           if ((mappings != null) && (mappings.size() != 0)) {
48               constructors = new String JavaDoc[mappings.size()];
49               int j = 0;
50               Iterator JavaDoc i = mappings.iterator();
51               while (i.hasNext()) {
52                 Element constructor = (Element) i.next();
53                 String JavaDoc value = constructor.getAttributeValue("value");
54                 Debug.logVerbose("[JdonFramework] component constructor=" + value, module);
55                 constructors[j] = value;
56                 j++;
57               }
58             }
59
60           if (constructors != null)
61               componentMetaDef = new ComponentMetaDef(name, className, constructors);
62           else
63               componentMetaDef = new ComponentMetaDef(name, className);
64           
65           mps.put(name, componentMetaDef);
66         }
67       }
68     
69   
70     
71
72
73 }
74
Popular Tags