KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > jboss > web > JBossWebXmlSubTask


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

5 package xdoclet.modules.jboss.web;
6
7 import xdoclet.XDocletException;
8
9 import xdoclet.XmlSubTask;
10 import xdoclet.modules.jboss.ejb.JBossSubTask;
11
12 /**
13  * Generates jboss-web.xml deployment descriptor.
14  *
15  * @author Dmitri Colebatch (dim@bigpond.net.au)
16  * @created August 9, 2001
17  * @modified Jon Barnett (jbarnett@pobox.com)
18  * @ant.element display-name="JBoss" name="jbosswebxml" parent="xdoclet.modules.web.WebDocletTask"
19  * @xdoclet.merge-file file="jbossweb-resource-env-ref.xml" relates-to="jboss-web.xml" description="An XML document
20  * containing the optional resource-env-ref elements."
21  * @xdoclet.merge-file file="jbossweb-resource-ref.xml" relates-to="jboss-web.xml" description="An XML document
22  * containing the optional resource-ref elements."
23  * @xdoclet.merge-file file="jbossweb-ejb-ref.xml" relates-to="jboss-web.xml" description="An XML document containing
24  * the optional ejb-ref elements."
25  * @xdoclet.merge-file file="jbossweb-ejb-local-ref.xml" relates-to="jboss-web.xml" description="An XML document
26  * containing the optional ejb-local-ref elements."
27  * @version $Revision: 1.13 $
28  */

29 public class JBossWebXmlSubTask extends XmlSubTask
30 {
31     private final static String JavaDoc JBOSS_WEB_PUBLICID_4_0 = "-//JBoss//DTD Web Application 2.4//EN";
32     private final static String JavaDoc JBOSS_WEB_PUBLICID_3_2 = "-//JBoss//DTD Web Application 2.3V2//EN";
33     private final static String JavaDoc JBOSS_WEB_PUBLICID_3_0 = "-//JBoss//DTD Web Application 2.3//EN";
34     private final static String JavaDoc JBOSS_WEB_PUBLICID_2_4 = "-//JBoss//DTD Web Application 2.2//EN";
35
36     private final static String JavaDoc JBOSS_WEB_SYSTEMID_4_0 = "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd";
37     private final static String JavaDoc JBOSS_WEB_SYSTEMID_3_2 = "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd";
38     private final static String JavaDoc JBOSS_WEB_SYSTEMID_3_0 = "http://www.jboss.org/j2ee/dtd/jboss-web_3_0.dtd";
39     private final static String JavaDoc JBOSS_WEB_SYSTEMID_2_4 = "http://www.jboss.org/j2ee/dtd/jboss-web.dtd";
40
41     private final static String JavaDoc JBOSS_WEB_DTD_FILE_NAME_4_0 = "resources/jboss-web_4_0.dtd";
42     private final static String JavaDoc JBOSS_WEB_DTD_FILE_NAME_3_2 = "resources/jboss-web_3_2.dtd";
43     private final static String JavaDoc JBOSS_WEB_DTD_FILE_NAME_3_0 = "resources/jboss-web_3_0.dtd";
44     private final static String JavaDoc JBOSS_WEB_DTD_FILE_NAME_2_4 = "resources/jboss-web.dtd";
45
46     /**
47      * The default template file - jboss_web_xml.xdt.
48      */

49     private static String JavaDoc DEFAULT_TEMPLATE_FILE = "resources/jboss_web_xml.xdt";
50
51     /**
52      * The generated file name - jboss-web.xml.
53      */

54     private static String JavaDoc GENERATED_FILE_NAME = "jboss-web.xml";
55
56     /**
57      * The Security Domain, defaults to "" because it is not included if not set in the build.xml.
58      */

59     protected String JavaDoc securityDomain = "";
60
61     /**
62      * The Context Root, defaults to "" because it is not included if not set in the build.xml.
63      */

64     protected String JavaDoc contextRoot = "";
65
66     /**
67      * The Virtual Host, defaults to "" because it is not included if not set in the build.xml.
68      */

69     protected String JavaDoc virtualHost = "";
70
71     /**
72      * The JBoss version to target. Possible subversion are the values present in JBossSubTask.JBossVersionTypes
73      */

74     protected String JavaDoc version = JBossSubTask.JBossVersionTypes.VERSION_3_2;
75
76     /**
77      * Describe what the JBossWebXmlSubTask constructor does
78      */

79     public JBossWebXmlSubTask()
80     {
81         setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
82         setDestinationFile(GENERATED_FILE_NAME);
83     }
84
85     /**
86      * Return the Security Domain.
87      *
88      * @return The Security Domain value
89      */

90     public String JavaDoc getSecuritydomain()
91     {
92         return securityDomain;
93     }
94
95     /**
96      * Return the Context Root.
97      *
98      * @return The Context Root value
99      */

100     public String JavaDoc getContextroot()
101     {
102         return contextRoot;
103     }
104
105     /**
106      * Return the Virtual Host.
107      *
108      * @return The Virtual Host value
109      */

110     public String JavaDoc getVirtualhost()
111     {
112         return virtualHost;
113     }
114
115     /**
116      * Get the target JBoss version
117      *
118      * @return the version
119      */

120     public String JavaDoc getVersion()
121     {
122         return version;
123     }
124
125     /**
126      * Set the Security Domain.
127      *
128      * @param securityDomain The new Security Domain value
129      */

130     public void setSecuritydomain(String JavaDoc securityDomain)
131     {
132         this.securityDomain = securityDomain;
133     }
134
135     /**
136      * Set the Context Root.
137      *
138      * @param contextRoot The new Context Root value
139      */

140     public void setContextroot(String JavaDoc contextRoot)
141     {
142         this.contextRoot = contextRoot;
143     }
144
145     /**
146      * Set the Virtual Host.
147      *
148      * @param virtualHost The new Virtual Host value
149      */

150     public void setVirtualhost(String JavaDoc virtualHost)
151     {
152         this.virtualHost = virtualHost;
153     }
154
155     /**
156      * Set the target JBoss version
157      *
158      * @param version the version
159      */

160     public void setVersion(JBossSubTask.JBossVersionTypes version)
161     {
162         this.version = version.getValue();
163     }
164
165     public void execute() throws XDocletException
166     {
167         if (getVersion().equals(JBossSubTask.JBossVersionTypes.VERSION_2_4)) {
168             setPublicId(JBOSS_WEB_PUBLICID_2_4);
169             setSystemId(JBOSS_WEB_SYSTEMID_2_4);
170             setDtdURL(getClass().getResource(JBOSS_WEB_DTD_FILE_NAME_2_4));
171         }
172         else if (getVersion().startsWith(JBossSubTask.JBossVersionTypes.VERSION_3_0)) {
173             setPublicId(JBOSS_WEB_PUBLICID_3_0);
174             setSystemId(JBOSS_WEB_SYSTEMID_3_0);
175             setDtdURL(getClass().getResource(JBOSS_WEB_DTD_FILE_NAME_3_0));
176         }
177         else if (getVersion().startsWith(JBossSubTask.JBossVersionTypes.VERSION_3_2)) {
178             setPublicId(JBOSS_WEB_PUBLICID_3_2);
179             setSystemId(JBOSS_WEB_SYSTEMID_3_2);
180             setDtdURL(getClass().getResource(JBOSS_WEB_DTD_FILE_NAME_3_2));
181         }
182         else {
183             setPublicId(JBOSS_WEB_PUBLICID_4_0);
184             setSystemId(JBOSS_WEB_SYSTEMID_4_0);
185             setDtdURL(getClass().getResource(JBOSS_WEB_DTD_FILE_NAME_4_0));
186         }
187
188         super.execute();
189     }
190 }
191
Popular Tags