KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > ejb > JbossDeploymentTool


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18 package org.apache.tools.ant.taskdefs.optional.ejb;
19
20 import java.io.File JavaDoc;
21 import java.util.Hashtable JavaDoc;
22 import org.apache.tools.ant.BuildException;
23 import org.apache.tools.ant.Project;
24
25 /**
26  * The deployment tool to add the jboss specific deployment descriptor to the ejb jar file.
27  * Jboss only requires one additional file jboss.xml and does not require any additional
28  * compilation.
29  *
30  * @version 1.0
31  * @see EjbJar#createJboss
32  */

33 public class JbossDeploymentTool extends GenericDeploymentTool {
34     protected static final String JavaDoc JBOSS_DD = "jboss.xml";
35     protected static final String JavaDoc JBOSS_CMP10D = "jaws.xml";
36     protected static final String JavaDoc JBOSS_CMP20D = "jbosscmp-jdbc.xml";
37
38     /** Instance variable that stores the suffix for the jboss jarfile. */
39     private String JavaDoc jarSuffix = ".jar";
40
41     /**
42      * Setter used to store the suffix for the generated JBoss jar file.
43      * @param inString the string to use as the suffix.
44      */

45     public void setSuffix(String JavaDoc inString) {
46         jarSuffix = inString;
47     }
48
49     /**
50      * Add any vendor specific files which should be included in the
51      * EJB Jar.
52      * @param ejbFiles the hashtable of files to populate.
53      * @param ddPrefix the prefix to use.
54      */

55     protected void addVendorFiles(Hashtable JavaDoc ejbFiles, String JavaDoc ddPrefix) {
56         File JavaDoc jbossDD = new File JavaDoc(getConfig().descriptorDir, ddPrefix + JBOSS_DD);
57         if (jbossDD.exists()) {
58             ejbFiles.put(META_DIR + JBOSS_DD, jbossDD);
59         } else {
60             log("Unable to locate jboss deployment descriptor. "
61                 + "It was expected to be in " + jbossDD.getPath(),
62                 Project.MSG_WARN);
63             return;
64         }
65         String JavaDoc descriptorFileName = JBOSS_CMP10D;
66         if (EjbJar.CMPVersion.CMP2_0.equals(getParent().getCmpversion())) {
67             descriptorFileName = JBOSS_CMP20D;
68         }
69         File JavaDoc jbossCMPD
70             = new File JavaDoc(getConfig().descriptorDir, ddPrefix + descriptorFileName);
71
72         if (jbossCMPD.exists()) {
73             ejbFiles.put(META_DIR + descriptorFileName, jbossCMPD);
74         } else {
75             log("Unable to locate jboss cmp descriptor. "
76                 + "It was expected to be in "
77                 + jbossCMPD.getPath(), Project.MSG_VERBOSE);
78             return;
79         }
80     }
81
82     /**
83      * Get the vendor specific name of the Jar that will be output. The modification date
84      * of this jar will be checked against the dependent bean classes.
85      */

86     File JavaDoc getVendorOutputJarFile(String JavaDoc baseName) {
87         if (getDestDir() == null && getParent().getDestdir() == null) {
88             throw new BuildException("DestDir not specified");
89         }
90         if (getDestDir() == null) {
91             return new File JavaDoc(getParent().getDestdir(), baseName + jarSuffix);
92         } else {
93             return new File JavaDoc(getDestDir(), baseName + jarSuffix);
94         }
95     }
96
97     /**
98      * Called to validate that the tool parameters have been configured.
99      *
100      * @throws BuildException If the Deployment Tool's configuration isn't
101      * valid
102      * @since ant 1.6
103      */

104     public void validateConfigured() throws BuildException {
105     }
106
107     private EjbJar getParent() {
108         return (EjbJar) this.getTask();
109     }
110 }
111
Popular Tags