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

📄 xmlserviceparser.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.util.Debug;
import com.jdon.bussinessproxy.meta.EJBTargetMetaDef;

import org.jdom.Element;

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

  public void parse(Element root, Map mps) throws Exception {
    List services = root.getChildren("services");
    Iterator iter = services.iterator();
    while (iter.hasNext()) {
      Element service = (Element) iter.next();
      if (service.getChildren("ejbService") != null) {
        Iterator i = service.getChildren("ejbService").iterator();
        while (i.hasNext()) {
          Element ejbService = (Element) i.next();
          parseEJBServiceConfig(ejbService, mps);
        }
      }
    }
  }

  private void parseEJBServiceConfig(Element ejbService, Map mps) throws
      Exception {
    String name = ejbService.getAttributeValue("name");
    Debug.logVerbose(" ejbService name=" + name, module);

    Element jndiE = ejbService.getChild("jndi");
    String jndiName = jndiE.getAttributeValue("name");

    Element ejbLobjectE = ejbService.getChild("ejbLocalObject");

    Element ejbHobjectE = ejbService.getChild("ejbHomeObject");
    Element ejbRobjectE = ejbService.getChild("ejbRemoteObject");

    EJBTargetMetaDef eJBMetaDef = null;
    if (ejbLobjectE != null) {
      eJBMetaDef = new EJBTargetMetaDef(name, jndiName,
                                        ejbLobjectE.getAttributeValue("class"));
      Debug.logVerbose(" jndiName=" + jndiName, module);
      Debug.logVerbose(" local=" + eJBMetaDef.getLocalName(), module);
      mps.put(name, eJBMetaDef);
    } else if ( (ejbRobjectE != null) && (ejbHobjectE != null)) {
      String homeClassName = ejbHobjectE.getAttributeValue("class");
      String remoteClassName = ejbRobjectE.getAttributeValue("class");
      eJBMetaDef = new EJBTargetMetaDef(jndiName, homeClassName,
                                        remoteClassName);
      mps.put(name, eJBMetaDef);
    } else {
      throw new Exception(
          "please config ejbLocalObject or ejbHomeObject/ejbRemoteObject ");
    }
    
    Element interfaceE = ejbService.getChild("interface");
    if (interfaceE != null){
        eJBMetaDef.setInterfaceClass(interfaceE.getAttributeValue("class"));
    }
  }

}

⌨️ 快捷键说明

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