1 15 16 package com.jdon.controller.config; 17 18 19 import java.util.Map ; 20 21 import java.util.List ; 22 23 import java.util.Iterator ; 24 import com.jdon.bussinessproxy.meta.POJOTargetMetaDef; 25 import com.jdon.util.Debug; 26 27 import org.jdom.Element; 28 29 30 public class XmlPojoServiceParser extends XmlParser{ 31 private final static String module = XmlPojoServiceParser.class.getName(); 32 33 34 public void parse(Element root, Map mps) throws Exception { 35 Debug.logVerbose("[JdonFramework] enter XmlPojoServiceParser .", module); 36 List services = root.getChildren("services"); 37 Iterator iter = services.iterator(); 38 while (iter.hasNext()) { 39 Element service = (Element) iter.next(); 40 if (service.getChildren("pojoService") != null) { 41 Iterator ii = service.getChildren("pojoService").iterator(); 42 while (ii.hasNext()) { 43 Element pojoService = (Element) ii.next(); 44 parsePOJOServiceConfig(pojoService, mps); 45 } 46 } 47 if (service.getChildren("component") != null) { 48 Iterator ii = service.getChildren("component").iterator(); 49 while (ii.hasNext()) { 50 Element pojoService = (Element) ii.next(); 51 parsePOJOServiceConfig(pojoService, mps); 52 } 53 } 54 } 55 } 56 57 63 private void parsePOJOServiceConfig(Element pojoService, Map mps) throws 64 Exception { 65 String name = pojoService.getAttributeValue("name"); 66 String className = pojoService.getAttributeValue("class"); 67 Debug.logVerbose("[JdonFramework] pojoService/component name=" + name + " class=" + className, 68 module); 69 70 if ( (className == null) || (className.equals(""))) 71 throw new Exception ("className is null "); 72 73 List mappings = pojoService.getChildren("constructor"); 74 String [] constructors = null; 75 if ((mappings != null) && (mappings.size() != 0)) { 76 Debug.logVerbose("[JdonFramework] constructor parameters number:" + mappings.size() + 77 " for pojoservice " + name, module); 78 constructors = new String [mappings.size()]; 79 int j = 0; 80 Iterator i = mappings.iterator(); 81 while (i.hasNext()) { 82 Element constructor = (Element) i.next(); 83 String value = constructor.getAttributeValue("value"); 84 Debug.logVerbose("[JdonFramework] pojoService constructor=" + value, module); 85 constructors[j] = value; 86 j++; 87 } 88 } 89 90 POJOTargetMetaDef pojoMetaDef = null; 91 if (constructors != null) 92 pojoMetaDef = new POJOTargetMetaDef(name, className, constructors); 93 else 94 pojoMetaDef = new POJOTargetMetaDef(name, className); 95 mps.put(name, pojoMetaDef); 96 97 } 98 } 99 | Popular Tags |