KickJava   Java API By Example, From Geeks To Geeks.

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


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
19 package org.apache.tools.ant.taskdefs.optional.ejb;
20
21 import java.io.File JavaDoc;
22 import java.util.Hashtable JavaDoc;
23 import org.apache.tools.ant.BuildException;
24 import org.apache.tools.ant.Project;
25
26 /**
27  * Deployment tool for Weblogic TOPLink.
28  */

29 public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool {
30
31     private static final String JavaDoc TL_DTD_LOC
32         = "http://www.objectpeople.com/tlwl/dtd/toplink-cmp_2_5_1.dtd";
33
34     private String JavaDoc toplinkDescriptor;
35     private String JavaDoc toplinkDTD;
36
37     /**
38      * Setter used to store the name of the toplink descriptor.
39      * @param inString the string to use as the descriptor name.
40      */

41     public void setToplinkdescriptor(String JavaDoc inString) {
42         this.toplinkDescriptor = inString;
43     }
44
45     /**
46      * Setter used to store the location of the toplink DTD file.
47      * This is expected to be an URL (file or otherwise). If running
48      * this on NT using a file URL, the safest thing would be to not use a
49      * drive spec in the URL and make sure the file resides on the drive that
50      * ANT is running from. This will keep the setting in the build XML
51      * platform independent.
52      *
53      * @param inString the string to use as the DTD location.
54      */

55     public void setToplinkdtd(String JavaDoc inString) {
56         this.toplinkDTD = inString;
57     }
58
59     /**
60      * Get the descriptor handler.
61      * @param srcDir the source file.
62      * @return the descriptor handler.
63      */

64     protected DescriptorHandler getDescriptorHandler(File JavaDoc srcDir) {
65         DescriptorHandler handler = super.getDescriptorHandler(srcDir);
66         if (toplinkDTD != null) {
67             handler.registerDTD("-//The Object People, Inc.//"
68                 + "DTD TOPLink for WebLogic CMP 2.5.1//EN", toplinkDTD);
69         } else {
70             handler.registerDTD("-//The Object People, Inc.//"
71                 + "DTD TOPLink for WebLogic CMP 2.5.1//EN", TL_DTD_LOC);
72         }
73         return handler;
74     }
75
76     /**
77      * Add any vendor specific files which should be included in the
78      * EJB Jar.
79      * @param ejbFiles the hashtable to add files to.
80      * @param ddPrefix the prefix to use.
81      */

82     protected void addVendorFiles(Hashtable JavaDoc ejbFiles, String JavaDoc ddPrefix) {
83         super.addVendorFiles(ejbFiles, ddPrefix);
84         // Then the toplink deployment descriptor
85

86         // Setup a naming standard here?.
87

88
89         File JavaDoc toplinkDD = new File JavaDoc(getConfig().descriptorDir, ddPrefix + toplinkDescriptor);
90
91         if (toplinkDD.exists()) {
92             ejbFiles.put(META_DIR + toplinkDescriptor,
93                          toplinkDD);
94         } else {
95             log("Unable to locate toplink deployment descriptor. "
96                 + "It was expected to be in "
97                 + toplinkDD.getPath(), Project.MSG_WARN);
98         }
99     }
100
101     /**
102      * Called to validate that the tool parameters have been configured.
103      * @throws BuildException if there is an error.
104      */

105     public void validateConfigured() throws BuildException {
106         super.validateConfigured();
107         if (toplinkDescriptor == null) {
108             throw new BuildException("The toplinkdescriptor attribute must "
109                 + "be specified");
110         }
111     }
112 }
113
Popular Tags