KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > objectweb > jonas > web > JonasWebSubTask


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

5 package xdoclet.modules.objectweb.jonas.web;
6
7 import org.apache.tools.ant.types.EnumeratedAttribute;
8
9 import xdoclet.XDocletException;
10 import xdoclet.XmlSubTask;
11
12 /**
13  * Generates the web application deployment descriptor for JOnAS.
14  *
15  * @author <a HREF="mailto:stevensa@users.sourceforge.net">Andrew Stevens</a>
16  * @created 03 October 2002
17  * @ant.element display-name="JOnAS" name="jonaswebxml" parent="xdoclet.modules.web.WebDocletTask"
18  * @version $Revision: 1.1 $
19  */

20 public class JonasWebSubTask extends XmlSubTask
21 {
22     /**
23      * Default JOnAS deployment descriptor file name.
24      */

25     private final static String JavaDoc DEFAULT_JONAS_DD_FILE_NAME = "jonas-web.xml";
26
27     /**
28      * Default template file.
29      */

30     private final static String JavaDoc DEFAULT_TEMPLATE_FILE = "resources/jonas-web_xml.xdt";
31
32     /**
33      * Location of local copy of JOnAS 2.6 DTD.
34      */

35     private final static String JavaDoc JONAS_DTD_FILE_NAME_2_6
36          = "resources/jonas-web-app_2_6.dtd";
37
38     /**
39      * JOnAS 2.6 deployment descriptor system ID.
40      */

41     private final static String JavaDoc JONAS_DD_SYSTEMID_2_6
42          = "http://www.objectweb.org/jonas/dtds/jonas-web-app_2_6.dtd";
43
44     /**
45      * JOnAS 2.6 deployment descriptor public ID.
46      */

47     private final static String JavaDoc JONAS_DD_PUBLICID_2_6
48          = "-//ObjectWeb//DTD JOnAS Web App 2.6//EN";
49
50     /**
51      * JOnAS version to generate files for.
52      */

53     private String JavaDoc version = JonasVersionTypes.DEFAULT_VERSION;
54
55     /**
56      * The host element specifies the name of host used for deploy the web application.
57      */

58     private String JavaDoc host = null;
59
60     /**
61      * The context-root element specifies the context root for the web application.
62      */

63     private String JavaDoc contextRoot = null;
64
65     /**
66      * Constructor.
67      */

68     public JonasWebSubTask()
69     {
70         setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
71         setDestinationFile(DEFAULT_JONAS_DD_FILE_NAME);
72     }
73
74     /**
75      * Return the Context Root.
76      *
77      * @return The Context Root value
78      */

79     public String JavaDoc getContextroot()
80     {
81         return contextRoot;
82     }
83
84     /**
85      * Return the Host.
86      *
87      * @return The Host value
88      */

89     public String JavaDoc getHost()
90     {
91         return host;
92     }
93
94     /**
95      * Gets the {@link #version} attribute.
96      *
97      * @return The version value.
98      */

99     public String JavaDoc getVersion()
100     {
101         return version;
102     }
103
104     /**
105      * The context-root element specifies the context root for the web application.
106      *
107      * @param contextRoot The new Context Root value
108      * @ant.not-required
109      */

110     public void setContextroot(String JavaDoc contextRoot)
111     {
112         this.contextRoot = contextRoot;
113     }
114
115     /**
116      * The host element specifies the name of host used for deploy the web application.
117      *
118      * @param host The new Host value
119      * @ant.not-required
120      */

121     public void setHost(String JavaDoc host)
122     {
123         this.host = host;
124     }
125
126     /**
127      * Sets the version of JOnAS. Supported versions are: 2.6.
128      *
129      * @param version The new version value. Supported versions are: 2.6.
130      * @ant.not-required No, default is "2.6".
131      */

132     public void setVersion(JonasVersionTypes version)
133     {
134         this.version = version.getValue();
135     }
136
137     public void execute() throws XDocletException
138     {
139         if (getVersion().equals(JonasVersionTypes.VERSION_2_6)) {
140             if (getPublicId() == null)
141                 setPublicId(JONAS_DD_PUBLICID_2_6);
142             if (getSystemId() == null)
143                 setSystemId(JONAS_DD_SYSTEMID_2_6);
144             if (getDtdURL() == null)
145                 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_2_6));
146         }
147         startProcess();
148     }
149
150     // --------------------------------------------------------------------------
151

152     /**
153      * JonasVersionTypes class.
154      *
155      * @author <a HREF="mailto:stevensa@users.sourceforge.net">Andrew Stevens</a>
156      * @created 03 October 2002
157      */

158     public static class JonasVersionTypes extends EnumeratedAttribute
159     {
160         public final static String JavaDoc VERSION_2_6 = "2.6";
161         public final static String JavaDoc DEFAULT_VERSION = VERSION_2_6;
162
163         /**
164          * Gets the possible values.
165          *
166          * @return The possible values.
167          */

168         public String JavaDoc[] getValues()
169         {
170             return (new String JavaDoc[]{VERSION_2_6});
171         }
172     }
173
174 }
175
Popular Tags