⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlpojoserviceparser.java

📁 一个非常好的FRAMWRK!是一个外国组织做的!不!
💻 JAVA
字号:
/**
 * Copyright 2003-2005 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.jdon.controller.config;


import java.util.Map;

import java.util.List;

import java.util.Iterator;
import com.jdon.bussinessproxy.meta.POJOTargetMetaDef;
import com.jdon.util.Debug;

import org.jdom.Element;


public class XmlPojoServiceParser  extends XmlParser{
  private final static String module = XmlPojoServiceParser.class.getName();


  public void parse(Element root, Map mps) throws Exception {
    Debug.logVerbose(" enter XmlPojoServiceParser .", module);
    List services = root.getChildren("services");
    Iterator iter = services.iterator();
    while (iter.hasNext()) {
      Element service = (Element) iter.next();
      if (service.getChildren("pojoService") != null) {
        Iterator ii = service.getChildren("pojoService").iterator();
        while (ii.hasNext()) {
          Element pojoService = (Element) ii.next();
          parsePOJOServiceConfig(pojoService, mps);
        }
      }else if (service.getChildren("component") != null) {
          Iterator ii = service.getChildren("component").iterator();
          while (ii.hasNext()) {
            Element pojoService = (Element) ii.next();
            parsePOJOServiceConfig(pojoService, mps);
          }
       }
    }
  }

  /**
   * parse POJOService Config
   * @param pojoService Element
   * @param mps Map
   * @throws Exception
   */
  private void parsePOJOServiceConfig(Element pojoService, Map mps) throws
      Exception {
    String name = pojoService.getAttributeValue("name");
    String className = pojoService.getAttributeValue("class");
    Debug.logVerbose(" pojoService/component name=" + name + " class=" + className,
                     module);

    if ( (className == null) || (className.equals("")))
      throw new Exception("className is null ");

    List mappings = pojoService.getChildren("constructor");
    String[] constructors = null;
    if ((mappings != null) && (mappings.size() != 0)) {
      Debug.logVerbose(" constructor parameters number:" + mappings.size() +
                       " for pojoservice " + name,  module);
      constructors = new String[mappings.size()];
      int j = 0;
      Iterator i = mappings.iterator();
      while (i.hasNext()) {
        Element constructor = (Element) i.next();
        String value = constructor.getAttributeValue("value");
        Debug.logVerbose(" pojoService constructor=" + value, module);
        constructors[j] = value;
        j++;
      }
    }

    POJOTargetMetaDef pojoMetaDef = null;
    if (constructors != null)
      pojoMetaDef = new POJOTargetMetaDef(name, className, constructors);
    else
      pojoMetaDef = new POJOTargetMetaDef(name, className);
    mps.put(name, pojoMetaDef);

  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -