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

📄 ejbjar.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     */    public Path createClasspath() {        if (config.classpath == null) {            config.classpath = new Path(getProject());        }        return config.classpath.createPath();    }    /**     * Create a DTD location record. This stores the location of a DTD. The     * DTD is identified by its public Id. The location may either be a file     * location or a resource location.     *     * @return the DTD location object to be configured by Ant     */    public DTDLocation createDTD() {        DTDLocation dtdLocation = new DTDLocation();        config.dtdLocations.add(dtdLocation);        return dtdLocation;    }    /**     * Adds a fileset for support elements.     *     * @return a fileset which can be populated with support files.     */    public FileSet createSupport() {        FileSet supportFileSet = new FileSet();        config.supportFileSets.add(supportFileSet);        return supportFileSet;    }    /**     * Set the Manifest file to use when jarring. As of EJB 1.1, manifest     * files are no longer used to configure the EJB. However, they still     * have a vital importance if the EJB is intended to be packaged in an     * EAR file. By adding "Class-Path" settings to a Manifest file, the EJB     * can look for classes inside the EAR file itself, allowing for easier     * deployment. This is outlined in the J2EE specification, and all J2EE     * components are meant to support it.     *     * @param manifest the manifest to be used in the EJB jar     */     public void setManifest(File manifest) {         config.manifest = manifest;     }    /**     * Sets the source directory, which is the directory that     * contains the classes that will be added to the EJB jar. Typically     * this will include the home and remote interfaces and the bean class.     *     * @param inDir the source directory.     */    public void setSrcdir(File inDir) {        config.srcDir = inDir;    }    /**     * Set the descriptor directory. The descriptor directory contains the     * EJB deployment descriptors. These are XML files that declare the     * properties of a bean in a particular deployment scenario. Such     * properties include, for example, the transactional nature of the bean     * and the security access control to the bean's methods.     *     * @param inDir the directory containing the deployment descriptors.     */    public void setDescriptordir(File inDir) {        config.descriptorDir = inDir;    }    /**     * Set the analyzer to use when adding in dependencies to the JAR.     *     * @param analyzer the name of the dependency analyzer or a class.     */    public void setDependency(String analyzer) {        config.analyzer = analyzer;    }    /**     * Set the base name of the EJB JAR that is to be created if it is not     * to be determined from the name of the deployment descriptor files.     *     * @param inValue the basename that will be used when writing the jar     *      file containing the EJB     */    public void setBasejarname(String inValue) {        config.baseJarName = inValue;        if (config.namingScheme == null) {            config.namingScheme = new NamingScheme();            config.namingScheme.setValue(NamingScheme.BASEJARNAME);        } else if (!config.namingScheme.getValue().equals(NamingScheme.BASEJARNAME)) {            throw new BuildException("The basejarname attribute is not "                + "compatible with the "                + config.namingScheme.getValue() + " naming scheme");        }    }    /**     * Set the naming scheme used to determine the name of the generated jars     * from the deployment descriptor     *     * @param namingScheme the naming scheme to be used     */    public void setNaming(NamingScheme namingScheme) {        config.namingScheme = namingScheme;        if (!config.namingScheme.getValue().equals(NamingScheme.BASEJARNAME)            && config.baseJarName != null) {            throw new BuildException("The basejarname attribute is not "                + "compatible with the "                + config.namingScheme.getValue() + " naming scheme");        }    }    /**     * Gets the destination directory.     *     * @return destination directory     * @since ant 1.6     */    public File getDestdir() {        return this.destDir;    }    /**     * Set the destination directory. The EJB jar files will be written into     * this directory. The jar files that exist in this directory are also     * used when determining if the contents of the jar file have changed.     * Note that this parameter is only used if no deployment tools are     * specified. Typically each deployment tool will specify its own     * destination directory.     *     * @param inDir the destination directory in which to generate jars     */    public void setDestdir(File inDir) {        this.destDir = inDir;    }    /**     * Gets the CMP version.     *     * @return CMP version     * @since ant 1.6     */    public String getCmpversion() {        return this.cmpVersion;    }    /**     * Sets the CMP version.     *     * @param version CMP version.     * Must be either <code>1.0</code> or <code>2.0</code>.<br/>     * Default is <code>1.0</code>.<br/>     * Initially, only the JBoss implementation does something specific for CMP 2.0.<br/>     * @since ant 1.6     */    public void setCmpversion(CMPVersion version) {        this.cmpVersion = version.getValue();    }    /**     * Set the classpath to use when resolving classes for inclusion in the jar.     *     * @param classpath the classpath to use.     */    public void setClasspath(Path classpath) {        config.classpath = classpath;    }    /**     * Controls whether the     * destination JARs are written out in the destination directory with     * the same hierarchical structure from which the deployment descriptors     * have been read. If this is set to true the generated EJB jars are     * written into the root of the destination directory, otherwise they     * are written out in the same relative position as the deployment     * descriptors in the descriptor directory.     *     * @param inValue the new value of the flatdestdir flag.     */    public void setFlatdestdir(boolean inValue) {        config.flatDestDir = inValue;    }    /**     * Set the suffix for the generated jar file. When generic jars are     * generated, they have a suffix which is appended to the the bean name     * to create the name of the jar file. Note that this suffix includes     * the extension fo te jar file and should therefore end with an     * appropriate extension such as .jar or .ear     *     * @param inString the string to use as the suffix.     */    public void setGenericjarsuffix(String inString) {        this.genericJarSuffix = inString;    }    /**     * The string which terminates the bean name.     * The convention used by this task is     * that bean descriptors are named as the BeanName with some suffix. The     * baseNameTerminator string separates the bean name and the suffix and     * is used to determine the bean name.     *     * @param inValue a string which marks the end of the basename.     */    public void setBasenameterminator(String inValue) {        config.baseNameTerminator = inValue;    }    /**     * Validate the config that has been configured from the build file     *     * @throws BuildException if the config is not valid     */    private void validateConfig() throws BuildException {        if (config.srcDir == null) {            throw new BuildException("The srcDir attribute must be specified");        }        if (config.descriptorDir == null) {            config.descriptorDir = config.srcDir;        }        if (config.namingScheme == null) {            config.namingScheme = new NamingScheme();            config.namingScheme.setValue(NamingScheme.DESCRIPTOR);        } else if (config.namingScheme.getValue().equals(NamingScheme.BASEJARNAME)                    && config.baseJarName == null) {            throw new BuildException("The basejarname attribute must "                + "be specified with the basejarname naming scheme");        }    }    /**     * Invoked by Ant after the task is prepared, when it is ready to execute     * this task.     *     * This will configure all of the nested deployment tools to allow them to     * process the jar. If no deployment tools have been configured a generic     * tool is created to handle the jar.     *     * A parser is configured and then each descriptor found is passed to all     * the deployment tool elements for processing.     *     * @exception BuildException thrown whenever a problem is     *            encountered that cannot be recovered from, to signal to ant     *            that a major problem occurred within this task.     */    public void execute() throws BuildException {        validateConfig();        if (deploymentTools.size() == 0) {            GenericDeploymentTool genericTool = new GenericDeploymentTool();            genericTool.setTask(this);            genericTool.setDestdir(destDir);            genericTool.setGenericJarSuffix(genericJarSuffix);            deploymentTools.add(genericTool);        }        for (Iterator i = deploymentTools.iterator(); i.hasNext();) {            EJBDeploymentTool tool = (EJBDeploymentTool) i.next();            tool.configure(config);            tool.validateConfigured();        }        try {            // Create the parser using whatever parser the system dictates            SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();            saxParserFactory.setValidating(true);            SAXParser saxParser = saxParserFactory.newSAXParser();            DirectoryScanner ds = getDirectoryScanner(config.descriptorDir);            ds.scan();            String[] files = ds.getIncludedFiles();            log(files.length + " deployment descriptors located.",                Project.MSG_VERBOSE);            // Loop through the files. Each file represents one deployment            // descriptor, and hence one bean in our model.            for (int index = 0; index < files.length; ++index) {                // process the deployment descriptor in each tool                for (Iterator i = deploymentTools.iterator(); i.hasNext();) {                    EJBDeploymentTool tool = (EJBDeploymentTool) i.next();                    tool.processDescriptor(files[index], saxParser);                }            }        } catch (SAXException se) {            String msg = "SAXException while creating parser."                + "  Details: "                + se.getMessage();            throw new BuildException(msg, se);        } catch (ParserConfigurationException pce) {            String msg = "ParserConfigurationException while creating parser. "                       + "Details: " + pce.getMessage();            throw new BuildException(msg, pce);        }    } // end of execute()}

⌨️ 快捷键说明

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