1 | /*
|
---|
2 | * Copyright 2000-2002,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 |
|
---|
18 | package org.apache.tools.ant.taskdefs.optional.ejb;
|
---|
19 |
|
---|
20 | import java.io.File;
|
---|
21 | import java.util.Hashtable;
|
---|
22 | import org.apache.tools.ant.BuildException;
|
---|
23 | import org.apache.tools.ant.Project;
|
---|
24 |
|
---|
25 | public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool {
|
---|
26 |
|
---|
27 | private static final String TL_DTD_LOC
|
---|
28 | = "http://www.objectpeople.com/tlwl/dtd/toplink-cmp_2_5_1.dtd";
|
---|
29 |
|
---|
30 | private String toplinkDescriptor;
|
---|
31 | private String toplinkDTD;
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Setter used to store the name of the toplink descriptor.
|
---|
35 | * @param inString the string to use as the descriptor name.
|
---|
36 | */
|
---|
37 | public void setToplinkdescriptor(String inString) {
|
---|
38 | this.toplinkDescriptor = inString;
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Setter used to store the location of the toplink DTD file.
|
---|
43 | * This is expected to be an URL (file or otherwise). If running
|
---|
44 | * this on NT using a file URL, the safest thing would be to not use a
|
---|
45 | * drive spec in the URL and make sure the file resides on the drive that
|
---|
46 | * ANT is running from. This will keep the setting in the build XML
|
---|
47 | * platform independent.
|
---|
48 | *
|
---|
49 | * @param inString the string to use as the DTD location.
|
---|
50 | */
|
---|
51 | public void setToplinkdtd(String inString) {
|
---|
52 | this.toplinkDTD = inString;
|
---|
53 | }
|
---|
54 |
|
---|
55 | protected DescriptorHandler getDescriptorHandler(File srcDir) {
|
---|
56 | DescriptorHandler handler = super.getDescriptorHandler(srcDir);
|
---|
57 | if (toplinkDTD != null) {
|
---|
58 | handler.registerDTD("-//The Object People, Inc.//"
|
---|
59 | + "DTD TOPLink for WebLogic CMP 2.5.1//EN", toplinkDTD);
|
---|
60 | } else {
|
---|
61 | handler.registerDTD("-//The Object People, Inc.//"
|
---|
62 | + "DTD TOPLink for WebLogic CMP 2.5.1//EN", TL_DTD_LOC);
|
---|
63 | }
|
---|
64 | return handler;
|
---|
65 | }
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Add any vendor specific files which should be included in the
|
---|
69 | * EJB Jar.
|
---|
70 | */
|
---|
71 | protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) {
|
---|
72 | super.addVendorFiles(ejbFiles, ddPrefix);
|
---|
73 | // Then the toplink deployment descriptor
|
---|
74 |
|
---|
75 | // Setup a naming standard here?.
|
---|
76 |
|
---|
77 |
|
---|
78 | File toplinkDD = new File(getConfig().descriptorDir, ddPrefix + toplinkDescriptor);
|
---|
79 |
|
---|
80 | if (toplinkDD.exists()) {
|
---|
81 | ejbFiles.put(META_DIR + toplinkDescriptor,
|
---|
82 | toplinkDD);
|
---|
83 | } else {
|
---|
84 | log("Unable to locate toplink deployment descriptor. "
|
---|
85 | + "It was expected to be in "
|
---|
86 | + toplinkDD.getPath(), Project.MSG_WARN);
|
---|
87 | }
|
---|
88 | }
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Called to validate that the tool parameters have been configured.
|
---|
92 | *
|
---|
93 | */
|
---|
94 | public void validateConfigured() throws BuildException {
|
---|
95 | super.validateConfigured();
|
---|
96 | if (toplinkDescriptor == null) {
|
---|
97 | throw new BuildException("The toplinkdescriptor attribute must "
|
---|
98 | + "be specified");
|
---|
99 | }
|
---|
100 | }
|
---|
101 | }
|
---|