1 | /*
|
---|
2 | * Copyright 2001-2004 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 | package org.apache.tools.ant.taskdefs.optional.ejb;
|
---|
18 |
|
---|
19 | import java.io.File;
|
---|
20 | import java.util.Hashtable;
|
---|
21 | import org.apache.tools.ant.BuildException;
|
---|
22 | import org.apache.tools.ant.Project;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * The deployment tool to add the jboss specific deployment descriptor to the ejb jar file.
|
---|
26 | * Jboss only requires one additional file jboss.xml and does not require any additional
|
---|
27 | * compilation.
|
---|
28 | *
|
---|
29 | * @version 1.0
|
---|
30 | * @see EjbJar#createJboss
|
---|
31 | */
|
---|
32 | public class JbossDeploymentTool extends GenericDeploymentTool {
|
---|
33 | protected static final String JBOSS_DD = "jboss.xml";
|
---|
34 | protected static final String JBOSS_CMP10D = "jaws.xml";
|
---|
35 | protected static final String JBOSS_CMP20D = "jbosscmp-jdbc.xml";
|
---|
36 |
|
---|
37 | /** Instance variable that stores the suffix for the jboss jarfile. */
|
---|
38 | private String jarSuffix = ".jar";
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Setter used to store the suffix for the generated JBoss jar file.
|
---|
42 | * @param inString the string to use as the suffix.
|
---|
43 | */
|
---|
44 | public void setSuffix(String inString) {
|
---|
45 | jarSuffix = inString;
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Add any vendor specific files which should be included in the
|
---|
50 | * EJB Jar.
|
---|
51 | */
|
---|
52 | protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) {
|
---|
53 | File jbossDD = new File(getConfig().descriptorDir, ddPrefix + JBOSS_DD);
|
---|
54 | if (jbossDD.exists()) {
|
---|
55 | ejbFiles.put(META_DIR + JBOSS_DD, jbossDD);
|
---|
56 | } else {
|
---|
57 | log("Unable to locate jboss deployment descriptor. "
|
---|
58 | + "It was expected to be in " + jbossDD.getPath(),
|
---|
59 | Project.MSG_WARN);
|
---|
60 | return;
|
---|
61 | }
|
---|
62 | String descriptorFileName = JBOSS_CMP10D;
|
---|
63 | if (EjbJar.CMPVersion.CMP2_0.equals(getParent().getCmpversion())) {
|
---|
64 | descriptorFileName = JBOSS_CMP20D;
|
---|
65 | }
|
---|
66 | File jbossCMPD
|
---|
67 | = new File(getConfig().descriptorDir, ddPrefix + descriptorFileName);
|
---|
68 |
|
---|
69 | if (jbossCMPD.exists()) {
|
---|
70 | ejbFiles.put(META_DIR + descriptorFileName, jbossCMPD);
|
---|
71 | } else {
|
---|
72 | log("Unable to locate jboss cmp descriptor. "
|
---|
73 | + "It was expected to be in "
|
---|
74 | + jbossCMPD.getPath(), Project.MSG_VERBOSE);
|
---|
75 | return;
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Get the vendor specific name of the Jar that will be output. The modification date
|
---|
81 | * of this jar will be checked against the dependent bean classes.
|
---|
82 | */
|
---|
83 | File getVendorOutputJarFile(String baseName) {
|
---|
84 | if (getDestDir() == null && getParent().getDestdir() == null) {
|
---|
85 | throw new BuildException("DestDir not specified");
|
---|
86 | }
|
---|
87 | if (getDestDir() == null) {
|
---|
88 | return new File(getParent().getDestdir(), baseName + jarSuffix);
|
---|
89 | } else {
|
---|
90 | return new File(getDestDir(), baseName + jarSuffix);
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * Called to validate that the tool parameters have been configured.
|
---|
96 | *
|
---|
97 | * @throws BuildException If the Deployment Tool's configuration isn't
|
---|
98 | * valid
|
---|
99 | * @since ant 1.6
|
---|
100 | */
|
---|
101 | public void validateConfigured() throws BuildException {
|
---|
102 | }
|
---|
103 |
|
---|
104 | private EjbJar getParent() {
|
---|
105 | return (EjbJar) this.getTask();
|
---|
106 | }
|
---|
107 | }
|
---|