KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > borland > bes > ejb > BorlandSubTask


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

5 package xdoclet.modules.borland.bes.ejb;
6
7 import xdoclet.XDocletException;
8 import xdoclet.XDocletMessages;
9 import xdoclet.modules.ejb.dd.AbstractEjbDeploymentDescriptorSubTask;
10 import xdoclet.util.Translator;
11
12 /**
13  * @author Michal Maczka
14  * @created December 5, 2002
15  * @ant.element display-name="Borland" name="borland" parent="xdoclet.modules.ejb.EjbDocletTask"
16  * @xdoclet.merge-file file="ejb-borland-datasources.xml" relates-to="ejb-borland.xml" description="An XML unparsed
17  * entity containing the datasource elements."
18  * @xdoclet.merge-file file="ejb-borland-authorization-domain.xml" relates-to="ejb-borland.xml" description="An XML
19  * document containing the optional authorization-domain element."
20  * @xdoclet.merge-file file="ejb-borland-ejb-refs-{0}.xml" relates-to="ejb-borland.xml" description="An XML unparsed
21  * entity containing the ejb-ref elements for a bean, to be used instead of generating from bes.ejb-ref tags."
22  * @xdoclet.merge-file file="ejb-borland-ejb-local-refs-{0}.xml" relates-to="ejb-borland.xml" description="An XML
23  * unparsed entity containing the ejb-local-ref elements for a bean, to be used instead of generating from
24  * bes.ejb-local-ref tags."
25  * @xdoclet.merge-file file="ejb-borland-resource-refs-{0}.xml" relates-to="ejb-borland.xml" description="An XML
26  * unparsed entity containing the resource-ref elements for a bean, to be used instead of generating from
27  * bes.resource-ref tags."
28  * @xdoclet.merge-file file="ejb-borland-resource-env-refs-{0}.xml" relates-to="ejb-borland.xml" description="An XML
29  * unparsed entity containing the resource-env-ref elements for a bean, to be used instead of generating from
30  * bes.resource-env-ref tags."
31  * @xdoclet.merge-file file="ejb-borland-properties-{0}.xml" relates-to="ejb-borland.xml" description="An XML unparsed
32  * entity containing the property elements for a bean, to be used instead of generating from bes.property tags."
33  */

34 public class BorlandSubTask extends AbstractEjbDeploymentDescriptorSubTask
35 {
36     private final static String JavaDoc BORLAND_DD_FILE_NAME = "ejb-borland.xml";
37
38     private final static String JavaDoc BORLAND_DD_PUBLICID =
39         "-//Borland Software Corporation//DTD Enterprise JavaBeans 2.0//EN";
40
41     private final static String JavaDoc BORLAND_DD_SYSTEMID =
42         "http://www.borland.com/devsupport/appserver/dtds/ejb-jar_2_0-borland.dtd";
43
44     private final static String JavaDoc BORLAND_DTD_FILE_NAME =
45         "resources/ejb-borland_2_0.dtd";
46
47     private static String JavaDoc DEFAULT_TEMPLATE_FILE =
48         "resources/ejb-borland_2_0.xdt";
49
50     private String JavaDoc _version = "5.1";
51
52     private String JavaDoc _datasource = "NO DATA SOURCE!";
53
54     private String JavaDoc _datasourceMapping = "NO DATASOURCE MAPPING!";
55
56     private boolean _createTables = false;
57
58     public BorlandSubTask()
59     {
60         setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
61         setDestinationFile(BORLAND_DD_FILE_NAME);
62         setPublicId(BORLAND_DD_PUBLICID);
63         setSystemId(BORLAND_DD_SYSTEMID);
64         setDtdURL(getClass().getResource(BORLAND_DTD_FILE_NAME));
65     }
66
67     /**
68      * Gets the Version attribute of the BorlandSubTask object
69      *
70      * @return The Version value
71      */

72     public String JavaDoc getVersion()
73     {
74         return _version;
75     }
76
77     /**
78      * Gets the Createtables attribute of the BorlandSubTask object
79      *
80      * @return The Createtables value
81      */

82     public String JavaDoc getCreatetables()
83     {
84         return _createTables ? "True" : "False";
85     }
86
87     /**
88      * Gets the Createtables attribute of the BorlandSubTask object
89      *
90      * @return The Createtables value
91      */

92     public String JavaDoc getDatasource()
93     {
94         return _datasource;
95     }
96
97
98     public String JavaDoc getDatasourceMapping()
99     {
100         return _datasourceMapping;
101     }
102
103     /**
104      * Sets the Version attribute of the BorlandSubTask object
105      *
106      * @param version The new Version value
107      */

108     public void setVersion(String JavaDoc version)
109     {
110         _version = version;
111     }
112
113     /**
114      * Sets the Createtables attribute of the BorlandSubTask object
115      *
116      * @param flag The new Createtables value
117      */

118     public void setCreatetables(boolean flag)
119     {
120         _createTables = flag;
121     }
122
123     /**
124      * Sets the Datasource attribute of the JBossSubTask object
125      *
126      * @param datasource
127      */

128     public void setDatasource(String JavaDoc datasource)
129     {
130         _datasource = datasource;
131     }
132
133     /**
134      * @param datasourceMapping
135      */

136     public void setDatasourceMapping(String JavaDoc datasourceMapping)
137     {
138         _datasourceMapping = datasourceMapping;
139     }
140
141     /**
142      * Called to validate configuration parameters.
143      *
144      * @exception XDocletException Description of Exception
145      */

146     public void validateOptions() throws XDocletException
147     {
148         //
149
//super.validateOptions();
150
}
151
152     /**
153      * Describe what the method does
154      *
155      * @exception XDocletException Describe the exception
156      */

157     protected void engineStarted() throws XDocletException
158     {
159         if (getDestinationFile().equals(BORLAND_DD_FILE_NAME)) {
160             System.out.println(
161                 Translator.getString(
162                 XDocletMessages.class,
163                 XDocletMessages.GENERATING_SOMETHING,
164                 new String JavaDoc[]{BORLAND_DD_FILE_NAME}));
165         }
166     }
167
168     private boolean hasDatasource()
169     {
170         return getDatasource() != null && getDatasource().trim().length() > 0;
171     }
172
173     private boolean hasDatasourceMapping()
174     {
175         return getDatasourceMapping() != null
176             && getDatasourceMapping().trim().length() > 0;
177     }
178
179 }
180
Popular Tags