KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > ejb > dd > EjbDotXmlSubTask


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

5 package xdoclet.modules.ejb.dd;
6
7 import xdoclet.XDocletException;
8 import xdoclet.XDocletMessages;
9 import xdoclet.modules.ejb.EjbDocletTask;
10 import xdoclet.modules.ejb.EjbTagsHandler;
11 import xdoclet.modules.ejb.XDocletModulesEjbMessages;
12
13 import xdoclet.modules.ejb.dd.AbstractEjbDeploymentDescriptorSubTask;
14 import xdoclet.util.Translator;
15
16 /**
17  * Subtask for generating standard EJB deployment descriptor.
18  *
19  * @author Ara Abrahamian (ara_e@email.com)
20  * @created Oct 15, 2001
21  * @ant.element display-name="ejb-jar.xml" name="deploymentdescriptor"
22  * parent="xdoclet.modules.ejb.EjbDocletTask"
23  * @version $Revision: 1.18 $
24  * @xdoclet.merge-file file="session-beans.xml" relates-to="ejb-jar.xml" description="An XML unparsed entity
25  * containing session elements for beans you wish to include which aren't processed by XDoclet."
26  * @xdoclet.merge-file file="entity-beans.xml" relates-to="ejb-jar.xml" description="An XML unparsed entity containing
27  * entity elements for beans you wish to include which aren't processed by XDoclet."
28  * @xdoclet.merge-file file="message-driven-beans.xml" relates-to="ejb-jar.xml" description="An XML unparsed entity
29  * containing message-driven elements for beans you wish to include which aren't processed by XDoclet."
30  * @xdoclet.merge-file file="ejb-env-entries-{0}.xml" relates-to="ejb-jar.xml" description="An XML unparsed entity
31  * containing env-entry elements for a bean, to use instead of generating them from ejb.env-entry tags."
32  * @xdoclet.merge-file file="ejb-ejbrefs-{0}.xml" relates-to="ejb-jar.xml" description="An XML unparsed entity
33  * containing (ejb-ref*, ejb-local-ref*) elements for a bean, to use instead of generating them from ejb.ejb-ref
34  * and ejb.ejb-external-ref tags."
35  * @xdoclet.merge-file file="ejb-sec-rolerefs-{0}.xml" relates-to="ejb-jar.xml" description="An XML unparsed entity
36  * containing security-role-ref elements for a bean, to use instead of generating them from ejb.security-role-ref
37  * tags."
38  * @xdoclet.merge-file file="ejb-resourcerefs-{0}.xml" relates-to="ejb-jar.xml" description="An XML unparsed entity
39  * containing resource-ref elements for a bean, to use instead of generating them from ejb.resource-ref tags."
40  * @xdoclet.merge-file file="ejb-resource-env-refs-{0}.xml" relates-to="ejb-jar.xml" description="An XML unparsed
41  * entity containing resource-env-ref elements for a bean, to use instead of generating them from
42  * ejb.resource-env-ref tags."
43  * @xdoclet.merge-file file="ejb-finders-{0}.xml" relates-to="ejb-jar.xml" description="An XML unparsed entity
44  * containing query elements for a bean, for additional finder and select methods not defined in the bean class or
45  * its tags."
46  * @xdoclet.merge-file file="assembly-descriptor.xml" relates-to="ejb-jar.xml" description="An XML document containing
47  * assembly-descriptor markup, to use instead of generating it."
48  * @xdoclet.merge-file file="ejb-security-roles.xml" relates-to="ejb-jar.xml" description="An XML unparsed entity
49  * containing any additional security-role elements not generated by XDoclet."
50  * @xdoclet.merge-file file="ejb-method-permissions.ent" relates-to="ejb-jar.xml" description="An XML unparsed entity
51  * containing any additional method-permission elements not generated by XDoclet."
52  * @xdoclet.merge-file file="ejb-container-transactions.ent" relates-to="ejb-jar.xml" description="An XML unparsed
53  * entity containing any additional container-transaction elements not generated by XDoclet."
54  * @xdoclet.merge-file file="ejb-message-destinations.ent" relates-to="ejb-jar.xml" description="An XML document containing
55  * message-destination elements. Only used with EJB 2.1+"
56  * @xdoclet.merge-file file="ejb-exclude-list.xml" relates-to="ejb-jar.xml" description="An XML document containing
57  * any exclude-list element. Only used with EJB 2.0+"
58  * @xdoclet.merge-file file="relationships.xml" relates-to="ejb-jar.xml" description="AN XML unparsed entity
59  * containing ejb-relationship elements to add additional relationships that were not generated through Xdoclet."
60  */

61 public class EjbDotXmlSubTask extends AbstractEjbDeploymentDescriptorSubTask
62 {
63     private final static String JavaDoc DEFAULT_TEMPLATE_FILE = "resources/ejb-jar_xml.xdt";
64
65     private final static String JavaDoc DD_FILE_NAME = "ejb-jar.xml";
66
67     private final static String JavaDoc DD_PUBLICID_11 = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
68
69     private final static String JavaDoc DD_SYSTEMID_11 = "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd";
70
71     private final static String JavaDoc DTD_FILE_NAME_11 = "resources/ejb11-jar.dtd";
72
73     private final static String JavaDoc DD_PUBLICID_20 = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN";
74
75     private final static String JavaDoc DD_SYSTEMID_20 = "http://java.sun.com/dtd/ejb-jar_2_0.dtd";
76
77     private final static String JavaDoc DTD_FILE_NAME_20 = "resources/ejb20-jar.dtd";
78
79     private final static String JavaDoc XSD_LOCATION_21 = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
80
81     private final static String JavaDoc XSD_FILE_NAME_21 = "resources/ejb-jar_2_1.xsd";
82
83     protected String JavaDoc description;
84
85     protected String JavaDoc displayname;
86
87     protected String JavaDoc smallicon = "";
88
89     protected String JavaDoc largeicon = "";
90
91     protected String JavaDoc clientjar = "false";
92
93     public EjbDotXmlSubTask()
94     {
95         setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
96         setDestinationFile(DD_FILE_NAME);
97         setDescription(Translator.getString(XDocletMessages.class, XDocletMessages.NO_DESCRIPTION));
98         setDisplayname(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATED_BY_XDOCLET));
99     }
100
101     /**
102      * Gets the Smallicon attribute of the EjbDotXmlSubTask object
103      *
104      * @return The Smallicon value
105      */

106     public String JavaDoc getSmallicon()
107     {
108         return smallicon;
109     }
110
111     /**
112      * Gets the Largeicon attribute of the EjbDotXmlSubTask object
113      *
114      * @return The Largeicon value
115      */

116     public String JavaDoc getLargeicon()
117     {
118         return largeicon;
119     }
120
121
122     /**
123      * Gets the Displayname attribute of the EjbDotXmlSubTask object
124      *
125      * @return The Displayname value
126      */

127     public String JavaDoc getDisplayname()
128     {
129         return displayname;
130     }
131
132     /**
133      * Gets the Description attribute of the EjbDotXmlSubTask object
134      *
135      * @return The Description value
136      */

137     public String JavaDoc getDescription()
138     {
139         return description;
140     }
141
142     /**
143      * Gets the Clientjar attribute of the EjbDotXmlSubTask object
144      *
145      * @return The Clientjar value
146      */

147     public String JavaDoc getClientjar()
148     {
149         return clientjar;
150     }
151
152     /**
153      * Sets the Smallicon attribute of the EjbDotXmlSubTask object
154      *
155      * @param smallicon The new Smallicon value
156      */

157     public void setSmallicon(String JavaDoc smallicon)
158     {
159         this.smallicon = smallicon;
160     }
161
162     /**
163      * Sets the Largeicon attribute of the EjbDotXmlSubTask object
164      *
165      * @param largeicon The new Largeicon value
166      */

167     public void setLargeicon(String JavaDoc largeicon)
168     {
169         this.largeicon = largeicon;
170     }
171
172     /**
173      * Sets the Displayname attribute of the EjbDotXmlSubTask object
174      *
175      * @param displayname The new Displayname value
176      */

177     public void setDisplayname(String JavaDoc displayname)
178     {
179         this.displayname = displayname;
180     }
181
182     /**
183      * Sets the Description attribute of the EjbDotXmlSubTask object
184      *
185      * @param description The new Description value
186      */

187     public void setDescription(String JavaDoc description)
188     {
189         this.description = description;
190     }
191
192     /**
193      * Sets the Clientjar attribute of the EjbDotXmlSubTask object
194      *
195      * @param clientjar The new Clientjar value
196      */

197     public void setClientjar(String JavaDoc clientjar)
198     {
199         this.clientjar = clientjar;
200     }
201
202     /**
203      * Called to validate configuration parameters.
204      *
205      * @exception XDocletException
206      */

207     public void validateOptions() throws XDocletException
208     {
209         super.validateOptions();
210
211         if (getDestinationFile() == null || getDestinationFile().trim().equals("")) {
212             throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.PARAMETER_MISSING_OR_EMPTY, new String JavaDoc[]{"destinationFile"}));
213         }
214     }
215
216     /**
217      * Describe what the method does
218      *
219      * @exception XDocletException
220      */

221     public void execute() throws XDocletException
222     {
223         String JavaDoc ejbSpec = EjbTagsHandler.getEjbSpec();
224
225         if (ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_1_1)) {
226             setPublicId(DD_PUBLICID_11);
227             setSystemId(DD_SYSTEMID_11);
228             setDtdURL(getClass().getResource(DTD_FILE_NAME_11));
229         }
230         else if (ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_2_1)) {
231             setSchema(XSD_LOCATION_21);
232             setSchemaURL(getClass().getResource(XSD_FILE_NAME_21));
233         }
234         else {
235             setPublicId(DD_PUBLICID_20);
236             setSystemId(DD_SYSTEMID_20);
237             setDtdURL(getClass().getResource(DTD_FILE_NAME_20));
238         }
239
240         startProcess();
241     }
242
243     /**
244      * Describe what the method does
245      *
246      * @exception XDocletException
247      */

248     protected void engineStarted() throws XDocletException
249     {
250         System.out.println(Translator.getString(XDocletModulesEjbMessages.class, XDocletModulesEjbMessages.GENERATING_DD, new String JavaDoc[]{getDestinationFile()}));
251     }
252 }
253
Popular Tags