KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > objectweb > jonas > ejb > JonasSubTask


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet.modules.objectweb.jonas.ejb;
6
7 import org.apache.tools.ant.types.EnumeratedAttribute;
8
9 import xdoclet.XDocletException;
10 import xdoclet.modules.ejb.dd.AbstractEjbDeploymentDescriptorSubTask;
11
12 /**
13  * Generates the deployment descriptor for JOnAS.
14  *
15  * @author Richard Chuo (forthy@mac.com)
16  * @author Mathieu Peltier (mathieu.peltier@inrialpes.fr)
17  * @author Philippe Charaux (philippe.charaux@bull.net)
18  * @author Jerome Camilleri (jerome.camilleri@bull.net)
19  * @created 11 juillet 2002
20  * @ant.element display-name="JOnAS" name="jonas" parent="xdoclet.modules.ejb.EjbDocletTask"
21  * @version $Revision: 1.6 $
22  * @xdoclet.merge-file file="jonas-{0}.xml" relates-to="jonas-ejb-jar.xml" description="An XML document containing the
23  * jonas-session, jonas-entity or jonas-message-driven element for a bean, according to its type."
24  */

25 public class JonasSubTask extends AbstractEjbDeploymentDescriptorSubTask
26 {
27     /**
28      * Default JOnAS deployment descriptor file name.
29      */

30     private final static String JavaDoc DEFAULT_JONAS_DD_FILE_NAME = "jonas-ejb-jar.xml";
31
32     /**
33      * Default template file.
34      */

35     private final static String JavaDoc DEFAULT_TEMPLATE_FILE = "resources/jonas.xdt";
36
37     /**
38      * JOnAS 2.3 deployment descriptor public ID.
39      */

40     private final static String JavaDoc JONAS_DD_PUBLICID_2_3
41          = "-//ObjectWeb//DTD JOnAS 2.3//EN";
42
43     /**
44      * JOnAS 2.3 deployment descriptor system ID.
45      */

46     private final static String JavaDoc JONAS_DD_SYSTEMID_2_3
47          = "@JONAS_ROOT@/xml/jonas-ejb-jar.dtd";
48
49     /**
50      * Location of local copy of JOnAS 2.3 DTD.
51      */

52     private final static String JavaDoc JONAS_DTD_FILE_NAME_2_3
53          = "resources/jonas-ejb-jar_2_3.dtd";
54
55     /**
56      * JOnAS 2.4 deployment descriptor public ID.
57      */

58     private final static String JavaDoc JONAS_DD_PUBLICID_2_4
59          = "-//ObjectWeb//DTD JOnAS 2.4//EN";
60
61     /**
62      * JOnAS 2.4 deployment descriptor system ID.
63      */

64     private final static String JavaDoc JONAS_DD_SYSTEMID_2_4
65          = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_2_4.dtd";
66
67     /**
68      * Location of local copy of JOnAS 2.4 DTD.
69      */

70     private final static String JavaDoc JONAS_DTD_FILE_NAME_2_4
71          = "resources/jonas-ejb-jar_2_4.dtd";
72
73     /**
74      * JOnAS 2.5 deployment descriptor public ID.
75      */

76     private final static String JavaDoc JONAS_DD_PUBLICID_2_5
77          = "-//ObjectWeb//DTD JOnAS 2.5//EN";
78
79     /**
80      * JOnAS 2.5 deployment descriptor system ID.
81      */

82     private final static String JavaDoc JONAS_DD_SYSTEMID_2_5
83          = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_2_5.dtd";
84
85     /**
86      * Location of local copy of JOnAS 2.5 DTD.
87      */

88     private final static String JavaDoc JONAS_DTD_FILE_NAME_2_5
89          = "resources/jonas-ejb-jar_2_5.dtd";
90
91     /**
92      * JOnAS 3.0 deployment descriptor public ID.
93      */

94     private final static String JavaDoc JONAS_DD_PUBLICID_3_0
95          = "-//ObjectWeb//DTD JOnAS 3.0//EN";
96
97     /**
98      * JOnAS 3.0 deployment descriptor system ID.
99      */

100     private final static String JavaDoc JONAS_DD_SYSTEMID_3_0
101          = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_3_0.dtd";
102
103     /**
104      * Location of local copy of JOnAS 3.0 DTD.
105      */

106     private final static String JavaDoc JONAS_DTD_FILE_NAME_3_0
107          = "resources/jonas-ejb-jar_3_0.dtd";
108     /**
109      * JOnAS 3.2 deployment descriptor public ID.
110      */

111     private final static String JavaDoc JONAS_DD_PUBLICID_3_2
112          = "-//ObjectWeb//DTD JOnAS 3.2//EN";
113
114     /**
115      * JOnAS 3.2 deployment descriptor system ID.
116      */

117     private final static String JavaDoc JONAS_DD_SYSTEMID_3_2
118          = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_3_2.dtd";
119
120     /**
121      * Location of local copy of JOnAS 3.2 DTD.
122      */

123     private final static String JavaDoc JONAS_DTD_FILE_NAME_3_2
124          = "resources/jonas-ejb-jar_3_2.dtd";
125
126     /**
127      * Location of local copy of JOnAS 3.3.2 DTD.
128      */

129     private final static String JavaDoc JONAS_DTD_FILE_NAME_3_3_2
130          = "resources/jonas-ejb-jar_3_3_2.dtd";
131
132     /**
133      * JOnAS 3.3.2 deployment descriptor public ID.
134      */

135     private final static String JavaDoc JONAS_DD_PUBLICID_3_3_2
136          = "-//ObjectWeb//DTD JOnAS 3.3.2//EN";
137
138     /**
139      * JOnAS 3.3.2 deployment descriptor system ID.
140      */

141     private final static String JavaDoc JONAS_DD_SYSTEMID_3_3_2
142          = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_3_3_2.dtd";
143     /**
144      * JOnAS 4.0 deployment descriptor no public ID with schema.
145      */

146
147     /**
148      * JOnAS 4.0 deployment descriptor no system ID for schema.
149      */

150     private final static String JavaDoc JONAS_DD_SYSTEMID_4_0
151          = "http://www.objectweb.org/jonas/ns/jonas-ejb-jar_4_0.xsd";
152
153     /**
154      * Location of local copy of JOnAS 4.0 DTD.
155      */

156     private final static String JavaDoc JONAS_DTD_FILE_NAME_4_0
157          = "resources/jonas-ejb-jar_4_0.xsd";
158
159     /**
160      * JOnAS 4.1.4 deployment descriptor no public ID with schema.
161      */

162
163     /**
164      * JOnAS 4.2 deployment descriptor no system ID for schema.
165      */

166     private final static String JavaDoc JONAS_DD_SYSTEMID_4_2
167          = "http://jonas.objectweb.org/ns/jonas-ejb-jar_4_2.xsd";
168
169     /**
170      * Location of local copy of JOnAS 4.0 DTD.
171      */

172     private final static String JavaDoc JONAS_DTD_FILE_NAME_4_2
173          = "resources/jonas-ejb-jar_4_2.xsd";
174
175     /**
176      * JOnAS version to generate files for.
177      */

178     private String JavaDoc version = JonasVersionTypes.DEFAULT_VERSION;
179
180     /*
181      * Default jndi name for all beans which doesn't have specific jndi name for jdbc-mapping section.
182      */

183     private String JavaDoc defaultEntityJndiName;
184
185     /**
186      * Constructor.
187      */

188     public JonasSubTask()
189     {
190         super();
191         setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
192         setDestinationFile(DEFAULT_JONAS_DD_FILE_NAME);
193     }
194
195     /**
196      * Gets the {@link #version} attribute.
197      *
198      * @return The version value.
199      */

200     public String JavaDoc getVersion()
201     {
202         return version;
203     }
204
205     /**
206      * Gets the defaultjndiname attribute of the JOnASSubTask object
207      *
208      * @return The Defaultjndiname value
209      */

210     public String JavaDoc getDefaultEntityJndiName()
211     {
212         return this.defaultEntityJndiName;
213     }
214
215     /**
216      * Sets the version of JOnAS. Supported versions are: 2.3, 2.4, 2.5, 2.6, 3.0, 3.2, 3.3.2, 4.0, 4.2
217      *
218      * @param version The new version value. Supported versions are: 2.3, 2.4, 2.5, 2.6, 3.0, 3.2, 3.3.2, 4.0, 4.2
219      * @ant.not-required No, default is "2.6".
220      */

221     public void setVersion(JonasVersionTypes version)
222     {
223         this.version = version.getValue();
224     }
225
226     /**
227      * Sets the defaultjndiname attribute of the JOnASSubTask object
228      *
229      * @param defaultEntityJndiName
230      */

231     public void setDefaultEntityJndiName(String JavaDoc defaultEntityJndiName)
232     {
233         this.defaultEntityJndiName = defaultEntityJndiName;
234     }
235
236
237     public void execute() throws XDocletException
238     {
239         if (getVersion().equals(JonasVersionTypes.VERSION_4_2)) {
240             if (getSystemId() == null)
241                 setSystemId(JONAS_DD_SYSTEMID_4_2);
242             if (getDtdURL() == null)
243                 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_4_2));
244         }
245         if (getVersion().equals(JonasVersionTypes.VERSION_4_0)) {
246             if (getSystemId() == null)
247                 setSystemId(JONAS_DD_SYSTEMID_4_0);
248             if (getDtdURL() == null)
249                 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_4_0));
250         }
251         else if (getVersion().equals(JonasVersionTypes.VERSION_3_3_2)) {
252             if (getPublicId() == null)
253                 setPublicId(JONAS_DD_PUBLICID_3_3_2);
254             if (getSystemId() == null)
255                 setSystemId(JONAS_DD_SYSTEMID_3_3_2);
256             if (getDtdURL() == null)
257                 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_3_3_2));
258         }
259         else if (getVersion().equals(JonasVersionTypes.VERSION_3_2)) {
260             if (getPublicId() == null)
261                 setPublicId(JONAS_DD_PUBLICID_3_2);
262             if (getSystemId() == null)
263                 setSystemId(JONAS_DD_SYSTEMID_3_2);
264             if (getDtdURL() == null)
265                 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_3_2));
266         }
267         else if (getVersion().equals(JonasVersionTypes.VERSION_3_0)) {
268             if (getPublicId() == null)
269                 setPublicId(JONAS_DD_PUBLICID_3_0);
270             if (getSystemId() == null)
271                 setSystemId(JONAS_DD_SYSTEMID_3_0);
272             if (getDtdURL() == null)
273                 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_3_0));
274         }
275         else if (getVersion().equals(JonasVersionTypes.VERSION_2_5)
276             || getVersion().equals(JonasVersionTypes.VERSION_2_6)) {
277             // nothing changed between 2.5 & 2.6 for EJBs, so use 2.5 DTD for both
278
if (getPublicId() == null)
279                 setPublicId(JONAS_DD_PUBLICID_2_5);
280             if (getSystemId() == null)
281                 setSystemId(JONAS_DD_SYSTEMID_2_5);
282             if (getDtdURL() == null)
283                 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_2_5));
284         }
285         else if (getVersion().equals(JonasVersionTypes.VERSION_2_4)) {
286             if (getPublicId() == null)
287                 setPublicId(JONAS_DD_PUBLICID_2_4);
288             if (getSystemId() == null)
289                 setSystemId(JONAS_DD_SYSTEMID_2_4);
290             if (getDtdURL() == null)
291                 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_2_4));
292         }
293         else if (getVersion().equals(JonasVersionTypes.VERSION_2_3)) {
294             if (getPublicId() == null)
295                 setPublicId(JONAS_DD_PUBLICID_2_3);
296             if (getSystemId() == null)
297                 setSystemId(JONAS_DD_SYSTEMID_2_3);
298             if (getDtdURL() == null)
299                 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_2_3));
300         }
301         startProcess();
302     }
303
304     // --------------------------------------------------------------------------
305

306     /**
307      * JonasVersionTypes class.
308      *
309      * @author Mathieu Peltier.
310      * @created June, 24 2002
311      */

312     public static class JonasVersionTypes extends EnumeratedAttribute
313     {
314         public final static String JavaDoc VERSION_2_3 = "2.3";
315         public final static String JavaDoc VERSION_2_4 = "2.4";
316         public final static String JavaDoc VERSION_2_5 = "2.5";
317         public final static String JavaDoc VERSION_2_6 = "2.6";
318         public final static String JavaDoc VERSION_3_0 = "3.0";
319         public final static String JavaDoc VERSION_3_2 = "3.2";
320         public final static String JavaDoc VERSION_3_3_2 = "3.3.2";
321         public final static String JavaDoc VERSION_4_0 = "4.0";
322         public final static String JavaDoc VERSION_4_2 = "4.2";
323         public final static String JavaDoc DEFAULT_VERSION = VERSION_4_2;
324
325         /**
326          * Gets the possible values.
327          *
328          * @return The possible values.
329          */

330         public String JavaDoc[] getValues()
331         {
332             return (new String JavaDoc[]{VERSION_2_3, VERSION_2_4, VERSION_2_5, VERSION_2_6, VERSION_3_0, VERSION_3_2, VERSION_3_3_2, VERSION_4_0, VERSION_4_2});
333         }
334     }
335
336 }
337
Popular Tags