KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > jboss > ejb > JBossSubTask


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

5 package xdoclet.modules.jboss.ejb;
6
7 import java.io.File JavaDoc;
8 import java.net.MalformedURLException JavaDoc;
9 import java.net.URL JavaDoc;
10
11 import xdoclet.XDocletException;
12 import xdoclet.XDocletMessages;
13 import xdoclet.modules.ejb.EjbDocletTask;
14 import xdoclet.modules.ejb.dd.AbstractEjbDeploymentDescriptorSubTask;
15 import xdoclet.util.Translator;
16
17 /**
18  * Creates jboss.xml, jaws.xml and/or jbosscmp-jdbc.xml deployment descriptors for JBoss. The destinationFile attribute
19  * is ignored because this subtask creates multiple deployment descriptor files.
20  *
21  * @author Ara Abrahamian (ara_e@email.com)
22  * @author Dmitri Colebatch (dim@bigpond.net.au)
23  * @created Oct 15, 2001
24  * @ant.element display-name="JBoss" name="jboss" parent="xdoclet.modules.ejb.EjbDocletTask"
25  * @version $Revision: 1.35 $
26  * @xdoclet.merge-file file="jboss-security.xml" relates-to="jboss.xml" description="An XML unparsed entity containing
27  * the optional enforce-ejb-restrictions, security-domain and/or unauthenticated-principal elements for jboss.xml"
28  * @xdoclet.merge-file file="jboss-beans.xml" relates-to="jboss.xml" description="An XML unparsed entity containing
29  * the session, entity and message-driven elements for beans you wish to include which aren't processed by
30  * XDoclet."
31  * @xdoclet.merge-file file="jboss-{0}.xml" relates-to="jboss.xml" description="An XML document containing the
32  * session, entity or message-driven element for a bean, to be used instead of generating it from the bean's tags."
33  * @xdoclet.merge-file file="jboss-resource-managers.xml" relates-to="jboss.xml" description="An XML document
34  * containing the resource-managers element, to use instead of generating it from jboss.resource-manager tags."
35  * @xdoclet.merge-file file="jboss-container.xml" relates-to="jboss.xml" description="An XML document containing the
36  * optional container-configurations element for jboss.xml"
37  * @xdoclet.merge-file file="jbosscmp-jdbc-defaults.xml" relates-to="jbosscmp-jdbc.xml" description="An XML document
38  * containing the defaults element for jbosscmp-jdbc.xml"
39  * @xdoclet.merge-file file="jbosscmp-jdbc-beans.xml" relates-to="jbosscmp-jdbc.xml" description="An XML unparsed
40  * entity containing entity elements for any beans you wish to include which aren't processed by XDoclet."
41  * @xdoclet.merge-file file="jbosscmp-jdbc-db-settings-{0}.xml" relates-to="jbosscmp-jdbc.xml" description="An XML
42  * unparsed entity containing various database settings for a bean. The contents should consist of (ejb-name,
43  * (datasource, datasource-mapping)?, create-table?, alter-table?, remove-table?, read-only?, read-time-out?,
44  * row-locking?, pk-constraint?, read-ahead?, list-cache-max?, fetch-size?, table-name?) elements."
45  * @xdoclet.merge-file file="jbosscmp-jdbc-{0}.xml" relates-to="jbosscmp-jdbc.xml" description="An XML unparsed entity
46  * containing various other settings for a bean. Should consist of the (cmp-field*, load-groups?,
47  * eager-load-group?, lazy-load-groups?, query*) elements."
48  * @xdoclet.merge-file file="jbosscmp-jdbc-dvc.xml" relates-to="jbosscmp-jdbc.xml" description="An XML unparsed entity
49  * containing any additional dependent-value-class elements not generated from jboss.dvc tags."
50  * @xdoclet.merge-file file="jbosscmp-jdbc-typemappings.xml" relates-to="jbosscmp-jdbc.xml" description="An XML
51  * document containing the optional type-mappings element."
52  * @xdoclet.merge-file file="jbosscmp-jdbc-entity-commands.xml" relates-to="jbosscmp-jdbc.xml" description="An XML
53  * document containing the optional entity-commands element."
54  * @xdoclet.merge-file file="jaws-db-settings-{0}.xml" relates-to="jboss-jaws.xml" description="An XML unparsed entity
55  * containing various database settings for a bean. The contents should consist of (ejb-name , datasource?)
56  * elements."
57  * @xdoclet.merge-file file="jaws-{0}.xml" relates-to="jboss-jaws.xml" description="An XML unparsed entity containing
58  * (cmp-field* , finder*) elements for a bean."
59  * @xdoclet.merge-file file="jaws-db-more-settings-{0}.xml" relates-to="jboss-jaws.xml" description="An XML unparsed
60  * entity containing various database settings for a bean. The contents should consist of (read-only? , table-name?
61  * , tuned-updates? , create-table? , remove-table? , row-locking? , time-out? , pk-constraint?) elements."
62  * @xdoclet.merge-file file="jboss-webservices.ent" relates-to="jboss.xml" description="An XML unparsed entity
63  * containing markup for webservices-description and webservice-context-root elements. This is a Jboss 4 feature
64  * and might work with patched >=3.2.6 version."
65  */

66 public class JBossSubTask extends AbstractEjbDeploymentDescriptorSubTask
67 {
68     private final static String JavaDoc DEFAULT_JBOSS_XML_TEMPLATE_FILE = "resources/jboss_xml.xdt";
69
70     private final static String JavaDoc JBOSS_XML_FILE_NAME = "jboss.xml";
71
72     private final static String JavaDoc DEFAULT_JAWS_XML_TEMPLATE_FILE = "resources/jboss-jaws_xml.xdt";
73
74     private final static String JavaDoc JAWS_XML_FILE_NAME = "jaws.xml";
75
76     private final static String JavaDoc DEFAULT_JBOSSCMP_TEMPLATE_FILE = "resources/jbosscmp-jdbc_xml.xdt";
77
78     private final static String JavaDoc JBOSSCMP_DD_FILE_NAME = "jbosscmp-jdbc.xml";
79
80     private final static String JavaDoc JBOSS_DD_PUBLICID_24 = "-//JBoss//DTD JBOSS 2.4//EN";
81
82     private final static String JavaDoc JBOSS_DD_SYSTEMID_24 = "http://www.jboss.org/j2ee/dtd/jboss_2_4.dtd";
83
84     private final static String JavaDoc JBOSS_DTD_FILE_NAME_24 = "resources/jboss_2_4.dtd";
85
86     private final static String JavaDoc JBOSS_DD_PUBLICID_30 = "-//JBoss//DTD JBOSS 3.0//EN";
87
88     private final static String JavaDoc JBOSS_DD_SYSTEMID_30 = "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd";
89
90     private final static String JavaDoc JBOSS_DTD_FILE_NAME_30 = "resources/jboss_3_0.dtd";
91
92     private final static String JavaDoc JBOSS_DD_PUBLICID_32 = "-//JBoss//DTD JBOSS 3.2//EN";
93
94     private final static String JavaDoc JBOSS_DD_SYSTEMID_32 = "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd";
95
96     private final static String JavaDoc JBOSS_DTD_FILE_NAME_32 = "resources/jboss_3_2.dtd";
97
98     private final static String JavaDoc JBOSS_DD_PUBLICID_40 = "-//JBoss//DTD JBOSS 4.0//EN";
99
100     private final static String JavaDoc JBOSS_DD_SYSTEMID_40 = "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd";
101
102     private final static String JavaDoc JBOSS_DTD_FILE_NAME_40 = "resources/jboss_4_0.dtd";
103
104     private final static String JavaDoc JAWS_DD_PUBLICID_24 = "-//JBoss//DTD JAWS 2.4//EN";
105
106     private final static String JavaDoc JAWS_DD_SYSTEMID_24 = "http://www.jboss.org/j2ee/dtd/jaws_2_4.dtd";
107
108     private final static String JavaDoc JAWS_DTD_FILE_NAME_24 = "resources/jaws_2_4.dtd";
109
110     private final static String JavaDoc JAWS_DD_PUBLICID_30 = "-//JBoss//DTD JAWS 3.0//EN";
111
112     private final static String JavaDoc JAWS_DD_SYSTEMID_30 = "http://www.jboss.org/j2ee/dtd/jaws_3_0.dtd";
113
114     private final static String JavaDoc JAWS_DTD_FILE_NAME_30 = "resources/jaws_3_0.dtd";
115
116     private final static String JavaDoc JBOSSCMP_DD_PUBLICID_30 = "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN";
117
118     private final static String JavaDoc JBOSSCMP_DD_SYSTEMID_30 = "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd";
119
120     private final static String JavaDoc JBOSSCMP_DTD_FILE_NAME_30 = "resources/jbosscmp-jdbc_3_0.dtd";
121
122     private final static String JavaDoc JBOSSCMP_DD_PUBLICID_32 = "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN";
123
124     private final static String JavaDoc JBOSSCMP_DD_SYSTEMID_32 = "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd";
125
126     private final static String JavaDoc JBOSSCMP_DTD_FILE_NAME_32 = "resources/jbosscmp-jdbc_3_2.dtd";
127
128     private final static String JavaDoc JBOSSCMP_DD_PUBLICID_40 = "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN";
129
130     private final static String JavaDoc JBOSSCMP_DD_SYSTEMID_40 = "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd";
131
132     private final static String JavaDoc JBOSSCMP_DTD_FILE_NAME_40 = "resources/jbosscmp-jdbc_4_0.dtd";
133
134     private String JavaDoc version = JBossVersionTypes.VERSION_2_4;
135
136     private String JavaDoc datasource;
137
138     private String JavaDoc datasourceMapping;
139
140     private String JavaDoc generateRelations = "false";
141
142     private String JavaDoc preferredRelationMapping;
143
144     private String JavaDoc createTable;
145
146     private String JavaDoc alterTable;
147
148     private String JavaDoc removeTable;
149
150     private String JavaDoc securityDomain = "";
151
152     private String JavaDoc webServiceContextRoot;
153
154     private String JavaDoc unauthenticatedPrincipal = "";
155
156     private String JavaDoc debug = "false";
157
158     private URL JavaDoc jbossTemplateURL = null;
159
160     private URL JavaDoc jawsTemplateURL = null;
161
162     private URL JavaDoc jbosscmpTemplateURL = null;
163
164     /**
165      * Get the web service context root.
166      *
167      * @return the web service context root
168      */

169     public String JavaDoc getWebServiceContextRoot()
170     {
171         return webServiceContextRoot;
172     }
173
174     /**
175      * Gets the template URL for jboss.xml.
176      *
177      * @return the jboss.xml template URL
178      */

179     public URL JavaDoc getJbossTemplateURL()
180     {
181         return jbossTemplateURL;
182     }
183
184     /**
185      * Gets the template URL for jaws.xml .
186      *
187      * @return the jaws.xml template URL
188      */

189     public URL JavaDoc getJawsTemplateURL()
190     {
191         return jawsTemplateURL;
192     }
193
194     /**
195      * Gets the template URL for jbosscmp-jdbc.xml.
196      *
197      * @return the jbosscmp-jdbc.xml template URL
198      */

199     public URL JavaDoc getJbosscmpTemplateURL()
200     {
201         return jbosscmpTemplateURL;
202     }
203
204     /**
205      * Gets the Debug attribute of the JBossSubTask object
206      *
207      * @return The Debug value
208      */

209     public String JavaDoc getDebug()
210     {
211         return debug;
212     }
213
214     /**
215      * Gets the Version attribute of the JBossSubTask object
216      *
217      * @return The Version value
218      */

219     public String JavaDoc getVersion()
220     {
221         return version;
222     }
223
224     /**
225      * Gets the SecurityDomain attribute of the JBossSubTask object
226      *
227      * @return The SecurityDomain value
228      */

229     public String JavaDoc getSecurityDomain()
230     {
231         return securityDomain;
232     }
233
234     /**
235      * Gets the unauthenticated principal name to use.
236      *
237      * @return The unauthenticated principal name
238      */

239     public String JavaDoc getUnauthenticatedPrincipal()
240     {
241         return unauthenticatedPrincipal;
242     }
243
244     /**
245      * Gets the Datasource attribute of the JBossSubTask object
246      *
247      * @return The Datasource value
248      */

249     public String JavaDoc getDatasource()
250     {
251         return datasource;
252     }
253
254     /**
255      * Gets the DatasourceMapping attribute of the JBossSubTask object
256      *
257      * @return The DatasourceMapping value
258      */

259     public String JavaDoc getDatasourceMapping()
260     {
261         return datasourceMapping;
262     }
263
264     /**
265      * Gets the Typemapping attribute of the JBossSubTask object
266      *
267      * @return The Typemapping value
268      */

269     public String JavaDoc getTypemapping()
270     {
271         return datasourceMapping;
272     }
273
274     /**
275      * Gets the GenerateRelations attribute of the JBossSubTask object
276      *
277      * @return The GenerateRelations value
278      */

279     public String JavaDoc getGenerateRelations()
280     {
281         return generateRelations;
282     }
283
284     /**
285      * Gets the preferredRelationMapping attribute of the JBossSubTask object.
286      *
287      * @return The preferredRelationMapping value
288      */

289     public String JavaDoc getPreferredRelationMapping()
290     {
291         return preferredRelationMapping;
292     }
293
294     /**
295      * Gets the createTable attribute of the JBossSubTask object.
296      *
297      * @return The createTable value
298      */

299     public String JavaDoc getCreateTable()
300     {
301         return createTable;
302     }
303
304     /**
305      * Gets the alterTable attribute of the JBossSubTask object.
306      *
307      * @return The alterTable value
308      */

309     public String JavaDoc getAlterTable()
310     {
311         return alterTable;
312     }
313
314     /**
315      * Gets the createTable attribute of the JBossSubTask object.
316      *
317      * @return The removeTable value
318      */

319     public String JavaDoc getRemoveTable()
320     {
321         return removeTable;
322     }
323
324     /**
325      * Set the web service context root.
326      *
327      * @param webServiceContextRoot the web service context root
328      */

329     public void setWebServiceContextRoot(String JavaDoc webServiceContextRoot)
330     {
331         this.webServiceContextRoot = webServiceContextRoot;
332     }
333
334     /**
335      * Sets the template file for jboss.xml.
336      *
337      * @param jbossTemplateFile the jboss.xml file
338      * @exception XDocletException
339      */

340     public void setJbossTemplateFile(File JavaDoc jbossTemplateFile) throws XDocletException
341     {
342         this.jbossTemplateURL = toURL(jbossTemplateFile);
343     }
344
345     /**
346      * Sets the template file for jaws.xml.
347      *
348      * @param jawsTemplateFile the jaws.xml file
349      * @exception XDocletException
350      */

351     public void setJawsTemplateFile(File JavaDoc jawsTemplateFile) throws XDocletException
352     {
353         this.jawsTemplateURL = toURL(jawsTemplateFile);
354     }
355
356     /**
357      * Sets the template file for jbosscmp-jdbc.xml.
358      *
359      * @param jbosscmpTemplateFile the jbosscmp-jdbc.xml file
360      * @exception XDocletException
361      */

362     public void setJbosscmpTemplateFile(File JavaDoc jbosscmpTemplateFile) throws XDocletException
363     {
364         this.jbosscmpTemplateURL = toURL(jbosscmpTemplateFile);
365     }
366
367     /**
368      * Debug flag for jaws.xml.
369      *
370      * @param debug No, default is "false"
371      */

372     public void setDebug(String JavaDoc debug)
373     {
374         this.debug = debug;
375     }
376
377     /**
378      * The version of JBoss. Supported versions are 2.4, 3.0, 3.0.1, 3.0.2, 3.0.3, 3.2 and 4.0.
379      *
380      * @param version The new Version value
381      * @ant.not-required No, default is "2.4".
382      */

383     public void setVersion(JBossVersionTypes version)
384     {
385         this.version = version.getValue();
386     }
387
388     /**
389      * The security domain to use.
390      *
391      * @param aSecurityDomain The new SecurityDomain value
392      */

393     public void setSecurityDomain(String JavaDoc aSecurityDomain)
394     {
395         securityDomain = aSecurityDomain;
396     }
397
398     /**
399      * The unauthenticated principal name to use.
400      *
401      * @param anUnauthenticatedPrincipal The new unauthenticated principal name
402      */

403     public void setUnauthenticatedPrincipal(String JavaDoc anUnauthenticatedPrincipal)
404     {
405         unauthenticatedPrincipal = anUnauthenticatedPrincipal;
406     }
407
408     /**
409      * Sets the Datasource attribute of the JBossSubTask object
410      *
411      * @param datasource The new Datasource value
412      */

413     public void setDatasource(String JavaDoc datasource)
414     {
415         this.datasource = datasource;
416     }
417
418     /**
419      * @param datasourceMapping
420      */

421     public void setDatasourceMapping(String JavaDoc datasourceMapping)
422     {
423         this.datasourceMapping = datasourceMapping;
424     }
425
426     /**
427      * @param typemapping
428      */

429     public void setTypemapping(String JavaDoc typemapping)
430     {
431         datasourceMapping = typemapping;
432     }
433
434     /**
435      * @param generateRelations
436      */

437     public void setGenerateRelations(String JavaDoc generateRelations)
438     {
439         this.generateRelations = generateRelations;
440     }
441
442     /**
443      * @param preferredRelationMapping
444      */

445     public void setPreferredRelationMapping(String JavaDoc preferredRelationMapping)
446     {
447         this.preferredRelationMapping = preferredRelationMapping;
448     }
449
450     /**
451      * @param createTable
452      */

453     public void setCreateTable(String JavaDoc createTable)
454     {
455         this.createTable = createTable;
456     }
457
458     /**
459      * @param alterTable
460      */

461     public void setAlterTable(String JavaDoc alterTable)
462     {
463         this.alterTable = alterTable;
464     }
465
466     /**
467      * @param removeTable
468      */

469     public void setRemoveTable(String JavaDoc removeTable)
470     {
471         this.removeTable = removeTable;
472     }
473
474     /**
475      * Called to validate configuration parameters.
476      *
477      * @exception XDocletException Description of Exception
478      */

479     public void validateOptions() throws XDocletException
480     {
481         if (jbossTemplateURL == null)
482             this.jbossTemplateURL = getClass().getResource(DEFAULT_JBOSS_XML_TEMPLATE_FILE);
483         if (jbosscmpTemplateURL == null)
484             this.jbosscmpTemplateURL = getClass().getResource(DEFAULT_JBOSSCMP_TEMPLATE_FILE);
485         if (jawsTemplateURL == null)
486             this.jawsTemplateURL = getClass().getResource(DEFAULT_JAWS_XML_TEMPLATE_FILE);
487
488         // JBoss does not require a template url or a destination file
489
//
490
// super.validateOptions();
491

492         if (getVersion().startsWith("3")) {
493             // 2.4 and 4.0 don't require that both params are there.
494
if ((hasDatasource() && !hasDatasourceMapping()) ||
495                 (!hasDatasource() && hasDatasourceMapping())) {
496                 throw new XDocletException(Translator.getString(XDocletModulesJBossEjbMessages.class, XDocletModulesJBossEjbMessages.DATASOURCE_DATASOURCEMAPPING_PARAMETER_MISSING, new String JavaDoc[]{hasDatasource() ? "datasource" : "datasourcemapping"}));
497             }
498         }
499     }
500
501     /**
502      * @exception XDocletException Description of Exception
503      */

504     public void execute() throws XDocletException
505     {
506         String JavaDoc jbossVersion = getVersion();
507
508         URL JavaDoc url = getJbossTemplateURL();
509
510         if (url == null) {
511             throw new XDocletException("can't find template for " + JBOSS_XML_FILE_NAME);
512         }
513
514         setTemplateURL(url);
515         setDestinationFile(JBOSS_XML_FILE_NAME);
516         if (jbossVersion.equals(JBossVersionTypes.VERSION_4_0)) {
517             setPublicId(JBOSS_DD_PUBLICID_40);
518             setSystemId(JBOSS_DD_SYSTEMID_40);
519             setDtdURL(getClass().getResource(JBOSS_DTD_FILE_NAME_40));
520         }
521         else if (jbossVersion.equals(JBossVersionTypes.VERSION_3_2)) {
522             setPublicId(JBOSS_DD_PUBLICID_32);
523             setSystemId(JBOSS_DD_SYSTEMID_32);
524             setDtdURL(getClass().getResource(JBOSS_DTD_FILE_NAME_32));
525         }
526         else if (jbossVersion.equals(JBossVersionTypes.VERSION_3_0) ||
527             jbossVersion.equals(JBossVersionTypes.VERSION_3_0_1) ||
528             jbossVersion.equals(JBossVersionTypes.VERSION_3_0_2) ||
529             jbossVersion.equals(JBossVersionTypes.VERSION_3_0_3)) {
530             setPublicId(JBOSS_DD_PUBLICID_30);
531             setSystemId(JBOSS_DD_SYSTEMID_30);
532             setDtdURL(getClass().getResource(JBOSS_DTD_FILE_NAME_30));
533         }
534         else {
535             setPublicId(JBOSS_DD_PUBLICID_24);
536             setSystemId(JBOSS_DD_SYSTEMID_24);
537             setDtdURL(getClass().getResource(JBOSS_DTD_FILE_NAME_24));
538         }
539
540         startProcess();
541
542         String JavaDoc ejbSpec = (String JavaDoc) getContext().getConfigParam("EjbSpec");
543
544         // if there is one CMP 1.x bean or we are using JBoss 2.4, JBoss needs a jaws.xml
545
//
546
if (atLeastOneCmp1EntityBeanExists() || jbossVersion.equals(JBossVersionTypes.VERSION_2_4)) {
547
548             url = getJawsTemplateURL();
549             if (url == null) {
550                 throw new XDocletException("can't find template for " + JAWS_XML_FILE_NAME);
551             }
552             setTemplateURL(url);
553             setDestinationFile(JAWS_XML_FILE_NAME);
554             if (jbossVersion.equals(JBossVersionTypes.VERSION_3_0) ||
555                 jbossVersion.equals(JBossVersionTypes.VERSION_3_0_1) ||
556                 jbossVersion.equals(JBossVersionTypes.VERSION_3_0_2) ||
557                 jbossVersion.equals(JBossVersionTypes.VERSION_3_0_3) ||
558                 jbossVersion.equals(JBossVersionTypes.VERSION_3_2) ||
559                 jbossVersion.equals(JBossVersionTypes.VERSION_4_0)) {
560                 setPublicId(JAWS_DD_PUBLICID_30);
561                 setSystemId(JAWS_DD_SYSTEMID_30);
562                 setDtdURL(getClass().getResource(JAWS_DTD_FILE_NAME_30));
563             }
564             else if (ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_1_1)) {
565                 setPublicId(JAWS_DD_PUBLICID_24);
566                 setSystemId(JAWS_DD_SYSTEMID_24);
567                 setDtdURL(getClass().getResource(JAWS_DTD_FILE_NAME_24));
568             }
569             startProcess();
570         }
571
572         // if we are doing ejb spec 2.0, JBoss 3.0, and one CMP 2.x bean exists, JBoss needs
573
// the jbosscmp-jdbc.xml file
574
//
575
if ((ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_2_0) || ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_2_1))
576             && atLeastOneCmp2EntityBeanExists()) {
577
578             url = getJbosscmpTemplateURL();
579             if (url == null) {
580                 throw new XDocletException("can't find template for " + JBOSSCMP_DD_FILE_NAME);
581             }
582
583             setTemplateURL(url);
584
585             setDestinationFile(JBOSSCMP_DD_FILE_NAME);
586
587             if (jbossVersion.equals(JBossVersionTypes.VERSION_3_0) ||
588                 jbossVersion.equals(JBossVersionTypes.VERSION_3_0_1) ||
589                 jbossVersion.equals(JBossVersionTypes.VERSION_3_0_2) ||
590                 jbossVersion.equals(JBossVersionTypes.VERSION_3_0_3)) {
591
592                 setPublicId(JBOSSCMP_DD_PUBLICID_30);
593                 setSystemId(JBOSSCMP_DD_SYSTEMID_30);
594                 setDtdURL(getClass().getResource(JBOSSCMP_DTD_FILE_NAME_30));
595             }
596             else if (jbossVersion.equals(JBossVersionTypes.VERSION_3_2)) {
597
598                 setPublicId(JBOSSCMP_DD_PUBLICID_32);
599                 setSystemId(JBOSSCMP_DD_SYSTEMID_32);
600                 setDtdURL(getClass().getResource(JBOSSCMP_DTD_FILE_NAME_32));
601             }
602             else if (jbossVersion.equals(JBossVersionTypes.VERSION_4_0)) {
603
604                 setPublicId(JBOSSCMP_DD_PUBLICID_40);
605                 setSystemId(JBOSSCMP_DD_SYSTEMID_40);
606                 setDtdURL(getClass().getResource(JBOSSCMP_DTD_FILE_NAME_40));
607             }
608             // end of else
609
else {
610                 throw new XDocletException("Unknown jboss version number for cmp2 " + jbossVersion);
611             }
612             // end of else
613

614             startProcess();
615         }
616     }
617
618     /**
619      * @exception XDocletException Description of Exception
620      */

621     protected void engineStarted() throws XDocletException
622     {
623         if (getDestinationFile().equals(JBOSS_XML_FILE_NAME)) {
624             System.out.println(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATING_SOMETHING, new String JavaDoc[]{JBOSS_XML_FILE_NAME}));
625         }
626         else if (getDestinationFile().equals(JAWS_XML_FILE_NAME)) {
627             System.out.println(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATING_SOMETHING, new String JavaDoc[]{JAWS_XML_FILE_NAME}));
628         }
629         else if (getDestinationFile().equals(JBOSSCMP_DD_FILE_NAME)) {
630             System.out.println(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATING_SOMETHING, new String JavaDoc[]{JBOSSCMP_DD_FILE_NAME}));
631         }
632     }
633
634     private boolean hasDatasource()
635     {
636         return getDatasource() != null && getDatasource().trim().length() > 0;
637     }
638
639     private boolean hasDatasourceMapping()
640     {
641         return getDatasourceMapping() != null && getDatasourceMapping().trim().length() > 0;
642     }
643
644
645     private URL JavaDoc toURL(File JavaDoc file) throws XDocletException
646     {
647         if (file.exists()) {
648             try {
649                 return file.toURL();
650             }
651             catch (MalformedURLException JavaDoc mue) {
652                 throw new XDocletException(mue, "Illegal file url: " + file.getAbsolutePath());
653             }
654         }
655         else {
656             throw new XDocletException("Couldn't find file: " + file.getAbsolutePath());
657         }
658     }
659
660     /**
661      * @author Ara Abrahamian (ara_e@email.com)
662      * @created October 20, 2001
663      */

664     public static class JBossVersionTypes extends org.apache.tools.ant.types.EnumeratedAttribute
665     {
666         public final static String JavaDoc VERSION_2_4 = "2.4";
667         public final static String JavaDoc VERSION_3_0 = "3.0";
668         public final static String JavaDoc VERSION_3_0_1 = "3.0.1";
669         public final static String JavaDoc VERSION_3_0_2 = "3.0.2";
670         public final static String JavaDoc VERSION_3_0_3 = "3.0.3";
671         public final static String JavaDoc VERSION_3_2 = "3.2";
672         public final static String JavaDoc VERSION_4_0 = "4.0";
673
674         /**
675          * Gets the Values attribute of the JBossVersionTypes object
676          *
677          * @return The Values value
678          */

679         public String JavaDoc[] getValues()
680         {
681             return new String JavaDoc[]{VERSION_2_4, VERSION_3_0, VERSION_3_0_1, VERSION_3_0_2, VERSION_3_0_3, VERSION_3_2, VERSION_4_0};
682         }
683     }
684 }
685
Popular Tags