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

📄 jonasdeploymenttool.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  Licensed to the Apache Software Foundation (ASF) under one or more *  contributor license agreements.  See the NOTICE file distributed with *  this work for additional information regarding copyright ownership. *  The ASF licenses this file to You 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 org.apache.tools.ant.taskdefs.optional.ejb;import java.io.File;import java.io.IOException;import java.util.Enumeration;import java.util.Hashtable;import javax.xml.parsers.SAXParser;import org.apache.tools.ant.AntClassLoader;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.Project;import org.apache.tools.ant.taskdefs.Java;import org.apache.tools.ant.types.Path;/** * The deployment tool to add the jonas specific deployment descriptors to the * ejb JAR file. JONAS only requires one additional file jonas-ejb-jar.xml. * * @version 1.0 * @see EjbJar#createJonas */public class JonasDeploymentTool extends GenericDeploymentTool {    /** Public Id of the standard deployment descriptor DTD. */    protected static final String EJB_JAR_1_1_PUBLIC_ID        = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";    protected static final String EJB_JAR_2_0_PUBLIC_ID        = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN";    /** Public Id of the JOnAS-specific deployment descriptor DTD. */    protected static final String JONAS_EJB_JAR_2_4_PUBLIC_ID        = "-//ObjectWeb//DTD JOnAS 2.4//EN";    protected static final String JONAS_EJB_JAR_2_5_PUBLIC_ID        = "-//ObjectWeb//DTD JOnAS 2.5//EN";    /** RMI ORB. */    protected static final String RMI_ORB = "RMI";    /** JEREMIE ORB. */    protected static final String JEREMIE_ORB = "JEREMIE";    /** DAVID ORB. */    protected static final String DAVID_ORB = "DAVID";    /**     * Name of the standard deployment descriptor DTD (these files are stored in     * the ${JONAS_ROOT}/xml directory).     */    protected static final String EJB_JAR_1_1_DTD = "ejb-jar_1_1.dtd";    protected static final String EJB_JAR_2_0_DTD = "ejb-jar_2_0.dtd";    /**     * Name of the JOnAS-specific deployment descriptor DTD (these files are     * stored in the ${JONAS_ROOT}/xml directory).     */    protected static final String JONAS_EJB_JAR_2_4_DTD        = "jonas-ejb-jar_2_4.dtd";    protected static final String JONAS_EJB_JAR_2_5_DTD        = "jonas-ejb-jar_2_5.dtd";    /** Default JOnAS deployment descriptor name. */    protected static final String JONAS_DD = "jonas-ejb-jar.xml";    /** GenIC class name (JOnAS 2.5) */    protected static final String GENIC_CLASS =    "org.objectweb.jonas_ejb.genic.GenIC";    /** Old GenIC class name (JOnAS 2.4.x). */    protected static final String OLD_GENIC_CLASS_1 =        "org.objectweb.jonas_ejb.tools.GenWholeIC";    /** Old GenIC class name. */    protected static final String OLD_GENIC_CLASS_2 =        "org.objectweb.jonas_ejb.tools.GenIC";    /**     * Filename of the standard EJB descriptor (which is passed to this class     * from the parent "ejbjar" task). This file is relative to the directory     * specified by the "srcdir" attribute in the ejbjar task.     */    private String descriptorName;    /**     * Filename of the JOnAS-specific EJB descriptor (which is passed to this     * class from the parent "ejbjar" task). This file is relative to the     * directory specified by the "srcdir" attribute in the ejbjar task.     */    private String jonasDescriptorName;    /* ------------- */    /* GenIC options */    /* ------------- */    /**     * Temporary output directory used by GenIC.     */    private File outputdir;    /**     * <code>true</code> if the intermediate Java source files generated by     * GenIC must be deleted or not. The default is <code>false</code>     */    private boolean keepgenerated = false;    /**     * <code>true</code> if the generated source files must not be compiled via     * the java and rmi compilers. The default is <code>false</code>.     */    private boolean nocompil = false;    /**     * <code>true</code> if the XML deployment descriptors must be parsed     * without validation. The default is <code>false</code>.     */    private boolean novalidation = false;    /**     * Java compiler to use. The default is the value of     * <code>build.compiler</code> property.     */    private String javac;    /** Options to pass to the java compiler. */    private String javacopts;    /** Options to pass to the rmi compiler. */    private String rmicopts;    /**     * Whether or not the RMI skeleton and stub must be modified to     * implement the implicit propagation of the security context (the     * transactional context is always provided). The default is     * <code>false</code>.     */    private boolean secpropag = false;    /**     * <code>true</code> if the GenIC call must be verbose. The default     * is <code>false</code>.     */    private boolean verbose = false;    /** Additional args to send to GenIC. */    private String additionalargs;    /* ------------- */    /* other options */    /* ------------- */    /** JOnAS root directory. */    private File jonasroot;    /**     * <code>true</code> if the generic JAR file used as input to GenIC must be     * retained. The default is <code>false</code>.     */    private boolean keepgeneric = false;    /** Stores the suffix for the JOnAS JAR file. The default is '.jar'. */    private String suffix = ".jar";    /**     *  ORB to use (RMI, JEREMIE or DAVID). If omitted, it defaults to the one     *  present in classpath. If specified, the corresponding JOnAS JAR is     *  automatically added to the classpath.     */    private String orb;    /**     * <code>true</code> if GenIC must not be run on the EJB JAR.     * The default is <code>false</code>.     */    private boolean nogenic = false;    /* -------------------- */    /* GenIC options setter */    /* -------------------- */    /**     * Sets the <code>keepgenerated</code> flag.     *     * @param aBoolean <code>true</code> if the flag must be set.     */    public void setKeepgenerated(boolean aBoolean) {        keepgenerated = aBoolean;    }    /**     * Sets the additional arguments.     *     * @param aString additional args.     */    public void setAdditionalargs(String aString) {        additionalargs = aString;    }    /**     * Sets the <code>nocompil</code> flag.     *     * @param aBoolean <code>true</code> if the flag must be set.     */    public void setNocompil(boolean aBoolean) {        nocompil = aBoolean;    }    /**     * Sets the <code>novalidation</code> flag.     *     * @param aBoolean <code>true</code> if the flag must be set.     */    public void setNovalidation(boolean aBoolean) {        novalidation = aBoolean;    }    /**     * Sets the java compiler to use.     *     * @param aString the java compiler.     */    public void setJavac(String aString) {        javac = aString;    }    /**     * Set the options to pass to the java compiler.     *     * @param aString the options.     */    public void setJavacopts(String aString) {        javacopts = aString;    }    /**     * Set the options to pass to the rmi compiler.     *     * @param aString the options.     */    public void setRmicopts(String aString) {        rmicopts = aString;    }    /**     * Sets the <code>secpropag</code> flag.     *     * @param aBoolean <code>true</code> if the flag must be set.     */    public void setSecpropag(boolean aBoolean) {        secpropag = aBoolean;    }    /**     * Sets the <code>verbose</code> flag.     *     * @param aBoolean <code>true</code> if the flag must be set.     */    public void setVerbose(boolean aBoolean) {        verbose = aBoolean;    }    /* -------------------- */    /* other options setter */    /* -------------------- */    /**     * Set the JOnAS root directory.     *     * @param aFile the JOnAS root directory.     */    public void setJonasroot(File aFile) {        jonasroot = aFile;    }    /**     * Sets the <code>keepgeneric</code> flag.     *     * @param aBoolean <code>true</code> if the flag must be set.     */    public void setKeepgeneric(boolean aBoolean) {        keepgeneric = aBoolean;    }    /**     * Sets the jar suffix.     *     * @param aString the string to use as the suffix.     */    public void setJarsuffix(String aString) {        suffix = aString;    }    /**     * Sets the <code>orb</code> to construct classpath.     *     * @param aString 'RMI', 'JEREMIE', or 'DAVID'.     */    public void setOrb(String aString) {        orb = aString;    }    /**     * Sets the <code>nogenic</code> flag.     *     * @param aBoolean <code>true</code> if the flag must be set.     */    public void setNogenic(boolean aBoolean) {        nogenic = aBoolean;    }    /* ------------- */    /* other methods */    /* ------------- */    /** {@inheritDoc}. */    public void processDescriptor(String aDescriptorName, SAXParser saxParser) {        descriptorName = aDescriptorName;        log("JOnAS Deployment Tool processing: " + descriptorName,            Project.MSG_VERBOSE);        super.processDescriptor(descriptorName, saxParser);        if (outputdir != null) {            // the method deleteOnExit() do not work because the directory is not empty            log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);            deleteAllFiles(outputdir);        }    }    /** {@inheritDoc}. */    protected void writeJar(String baseName, File jarfile, Hashtable ejbFiles, String publicId)    throws BuildException {        // create the generic jar first        File genericJarFile = super.getVendorOutputJarFile(baseName);        super.writeJar(baseName, genericJarFile, ejbFiles, publicId);        // GenIC call on generic jar        addGenICGeneratedFiles(genericJarFile, ejbFiles);        // create the real jar        super.writeJar(baseName, getVendorOutputJarFile(baseName), ejbFiles, publicId);        if (!keepgeneric) {            log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);            genericJarFile.delete();        }    }    /** {@inheritDoc}. */    protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) {    // JOnAS-specific descriptor deployment    jonasDescriptorName = getJonasDescriptorName();        File jonasDD = new File(getConfig().descriptorDir, jonasDescriptorName);        if (jonasDD.exists()) {            ejbFiles.put(META_DIR + JONAS_DD, jonasDD);        } else {            log("Unable to locate the JOnAS deployment descriptor. It was expected to be in: "                + jonasDD.getPath() + ".", Project.MSG_WARN);        }    }    /** {@inheritDoc}. */    protected File getVendorOutputJarFile(String baseName) {        return new File(getDestDir(), baseName + suffix);    }    /**     * Determines the name of the JOnAS-specific EJB descriptor using the     * specified standard EJB descriptor name. In general, the standard     * descriptor will be named "[basename]-ejb-jar.xml", and this method will     * return "[basename]-jonas-ejb-jar.xml" or "jonas-[basename].xml"     *     * @return The name of the JOnAS-specific EJB descriptor file.     */    private String getJonasDescriptorName() {        // descriptorName = <path><basename><basenameterminator><remainder>        // examples = /org/objectweb/fooAppli/foo/Foo-ejb-jar.xml        // examples = /org/objectweb/fooAppli/foo/Foo.xml (JOnAS convention)        String jonasDN; // JOnAS-specific DD        boolean jonasConvention = false; // true if the JOnAS convention is used for the DD        String path;            // Directory path of the EJB descriptor        String fileName;        // EJB descriptor file name        String baseName;        // Filename appearing before name terminator        String remainder;       // Filename appearing after the name terminator        int startOfFileName = descriptorName.lastIndexOf(File.separatorChar);        if (startOfFileName != -1) {            // extract path info            path = descriptorName.substring(0, startOfFileName + 1);            fileName = descriptorName.substring(startOfFileName + 1);        } else {

⌨️ 快捷键说明

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