sessionstruct.java

来自「一个java 代码生成器」· Java 代码 · 共 134 行

JAVA
134
字号
/**
 * Copyright (c) 2002, Siddhartha P. Chandurkar siddhartha@visioncodified.com
 * All rights reserved.
 * Licensed under the Academic Free License version 1.1
 * See the file LICENSE.TXT for details.
 * LICENSE.txt is located in the directory  <install-directory>\Jenerator
 * of your Jenertaor Installation.
 *
 */
package com.jenerator.struct.ejb;

//<Imports>

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

//</Imports>

/**
 * SessionStruct
 * A structure which contains all the configuration related to Session Beans.
 * @author Siddhartha P. Chandurkar
 * @version 0.9.0
 */
public class SessionStruct extends EjbStruct {

    //ATTRIBUTES
    private String sessionType;
    private String transactionType;

    //CONSTRUCTORS
    public SessionStruct() {

    }

    //Get and set methods
    public String getSessionType() {
        return sessionType;
    }

    public String getTransactionType() {
        return transactionType;
    }

    public void setSessionType(String _sessionType) {
        sessionType = _sessionType;
    }

    public void setTransactionType(String _transactionType) {
        transactionType = _transactionType;
    }

    /**
     * toXml
     */
    public String toXml() {
        StringBuffer xmlBuffer = new StringBuffer();
        xmlBuffer.append("<?xml version='1.0'?>");
        xmlBuffer.append("<session>");
        xmlBuffer.append("<version>");
        xmlBuffer.append(super.getEjbSpecVersion());
        xmlBuffer.append("</version>");
        xmlBuffer.append("<package>");
        xmlBuffer.append(super.getPackageName());
        xmlBuffer.append("</package>");
        Vector imports = super.getImports();
        if (imports.size() > 0) {
            xmlBuffer.append("<imports>");
            for (int i = 0; i < imports.size(); i++) {
                xmlBuffer.append("<import>");
                xmlBuffer.append(imports.elementAt(i));
                xmlBuffer.append("</import>");
            }
            xmlBuffer.append("</imports>");
        }
        xmlBuffer.append("<ejb-name>");
        xmlBuffer.append(super.getBeanName());
        xmlBuffer.append("</ejb-name>");
        xmlBuffer.append("<remote>");
        xmlBuffer.append(super.getRemoteName());
        xmlBuffer.append("</remote>");
        xmlBuffer.append("<home>");
        xmlBuffer.append(super.getHomeName());
        xmlBuffer.append("</home>");
        xmlBuffer.append("<ejb-class>");
        xmlBuffer.append(super.getEjbClass());
        xmlBuffer.append("</ejb-class>");


        Vector attributes = super.getAttributes();
        xmlBuffer.append("<attributes>");
        for (int m = 0; m < attributes.size(); m++) {
            AttributeStruct attrStruct = (AttributeStruct) attributes.elementAt(m);
            //xmlBuffer.append("<attribute name=\"" + attrStruct.getOriginalName() + "\" type=\"" + attrStruct.getType() + "\">");
            xmlBuffer.append("<attribute type=\"" + attrStruct.getType() + "\">");
            xmlBuffer.append(attrStruct.getName());
            xmlBuffer.append("</attribute>");
        }
        xmlBuffer.append("</attributes>");


        Hashtable methodSigs = super.getMethodSignatures();
        if (!methodSigs.isEmpty()) {
            Enumeration keys = methodSigs.keys();

            xmlBuffer.append("<methods>");
            while (keys.hasMoreElements()) {
                String signature = keys.nextElement().toString();
                String exceptions = methodSigs.get(signature).toString();
                xmlBuffer.append("<method>");
                xmlBuffer.append("<signature>");
                xmlBuffer.append(signature.toString());
                xmlBuffer.append("</signature>");
                xmlBuffer.append("<exceptions>");
                xmlBuffer.append(exceptions.toString());
                xmlBuffer.append("</exceptions>");
                xmlBuffer.append("</method>");
            }
            xmlBuffer.append("</methods>");
        }

        xmlBuffer.append("<session-type>");
        xmlBuffer.append(sessionType);
        xmlBuffer.append("</session-type>");
        xmlBuffer.append("<transaction-type>");
        xmlBuffer.append(transactionType);
        xmlBuffer.append("</transaction-type>");
        xmlBuffer.append("<jndi-name>" + super.getJndiName() + "</jndi-name>");
        xmlBuffer.append("<unit-test-framework>" + super.getUnitTestingFramework() + "</unit-test-framework>");
        xmlBuffer.append("</session>");
        return xmlBuffer.toString();
    }//toXml
}//SessionStruct

⌨️ 快捷键说明

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