001: /*
002: * Copyright (c) 2001, 2002 The XDoclet team
003: * All rights reserved.
004: */
005: package xdoclet.modules.bea.wls.web;
006:
007: import xdoclet.XDocletException;
008:
009: import xdoclet.XmlSubTask;
010: import xdoclet.util.Translator;
011:
012: /**
013: * Generates weblogic.xml deployment descriptor for Web apps.
014: *
015: * @author <a href="aslak.nospam@users.sf.net">Aslak Hellesøy</a>
016: * @author <a href="mailto:adrianprice at users.sf.net">Adrian Price</a>
017: * @created October 9, 2001
018: * @ant.element display-name="WebLogic Server" name="weblogicwebxml" parent="xdoclet.modules.web.WebDocletTask"
019: * @version $Revision: 1.1 $
020: */
021: public class WeblogicWebXmlSubTask extends XmlSubTask {
022: /**
023: * The default template file - weblogic_web_xml.xdt.
024: */
025: private final static String DEFAULT_TEMPLATE_FILE = "resources/weblogic_web_xml.xdt";
026:
027: /**
028: * The generated file name - weblogic.xml.
029: */
030: private final static String GENERATED_FILE_NAME = "weblogic.xml";
031:
032: private final static String WEBLOGIC_WEB_PUBLICID = "-//BEA Systems, Inc.//DTD Web Application 6.0//EN";
033:
034: private final static String WEBLOGIC_WEB_SYSTEMID = "http://www.bea.com/servers/wls600/dtd/weblogic-web-jar.dtd";
035:
036: private final static String WEBLOGIC_WEB_DTD_FILE_NAME = "resources/weblogic-web-jar.dtd";
037:
038: private final static String WEBLOGIC_WEB700_PUBLICID = "-//BEA Systems, Inc.//DTD Web Application 7.0//EN";
039:
040: private final static String WEBLOGIC_WEB700_SYSTEMID = "http://www.bea.com/servers/wls700/dtd/weblogic-web-jar.dtd";
041:
042: private final static String WEBLOGIC_WEB700_DTD_FILE_NAME = "resources/weblogic700-web-jar.dtd";
043:
044: private final static String WEBLOGIC_WEB810_PUBLICID = "-//BEA Systems, Inc.//DTD Web Application 8.1//EN";
045:
046: private final static String WEBLOGIC_WEB810_SYSTEMID = "http://www.bea.com/servers/wls810/dtd/weblogic-web-jar.dtd";
047:
048: private final static String WEBLOGIC_WEB810_DTD_FILE_NAME = "resources/weblogic810-web-jar.dtd";
049:
050: /**
051: * The Security Domain, defaults to "" because it is not included if not set in the build.xml.
052: */
053: private String securityDomain = "";
054:
055: /**
056: * The description of the Web App.
057: */
058: private String description;
059:
060: /**
061: * The web app's context root (overrides any value in application.xml)
062: */
063: private String contextRoot = null;
064:
065: /**
066: * The WLS version.
067: */
068: private String version = "6.1";
069:
070: /**
071: * Describe what the WeblogicWebXmlSubTask constructor does
072: *
073: * @exception XDocletException Describe the exception
074: */
075: public WeblogicWebXmlSubTask() throws XDocletException {
076: setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
077: setDestinationFile(GENERATED_FILE_NAME);
078: setPublicId(WEBLOGIC_WEB_PUBLICID);
079: setSystemId(WEBLOGIC_WEB_SYSTEMID);
080: setDtdURL(getClass().getResource(WEBLOGIC_WEB_DTD_FILE_NAME));
081: setDescription(Translator.getString(
082: XDocletModulesBeaWlsWebMessages.class,
083: XDocletModulesBeaWlsWebMessages.GENERATED_ATTRIBUTE));
084: }
085:
086: /**
087: * Return the WLS version.
088: *
089: * @return The WLS version
090: */
091: public String getVersion() {
092: return version;
093: }
094:
095: /**
096: * Return the Security Domain.
097: *
098: * @return The Security Domain value
099: */
100: public String getSecuritydomain() {
101: return securityDomain;
102: }
103:
104: /**
105: * Return the Description.
106: *
107: * @return The Description value
108: */
109: public String getDescription() {
110: return description;
111: }
112:
113: /**
114: * Return the Context Root.
115: *
116: * @return The ContextRoot value
117: */
118: public String getContextRoot() {
119: return contextRoot;
120: }
121:
122: /**
123: * Set the WLS version.
124: *
125: * @param version The new Version value
126: */
127: public void setVersion(Version version) {
128: this .version = version.getValue();
129: if (this .version.equals("6.0") || this .version.equals("6.1")) {
130: setPublicId(WEBLOGIC_WEB_PUBLICID);
131: setSystemId(WEBLOGIC_WEB_SYSTEMID);
132: setDtdURL(getClass()
133: .getResource(WEBLOGIC_WEB_DTD_FILE_NAME));
134: } else if (this .version.equals("7.0")) {
135: setPublicId(WEBLOGIC_WEB700_PUBLICID);
136: setSystemId(WEBLOGIC_WEB700_SYSTEMID);
137: setDtdURL(getClass().getResource(
138: WEBLOGIC_WEB700_DTD_FILE_NAME));
139: } else if (this .version.equals("8.1")) {
140: setPublicId(WEBLOGIC_WEB810_PUBLICID);
141: setSystemId(WEBLOGIC_WEB810_SYSTEMID);
142: setDtdURL(getClass().getResource(
143: WEBLOGIC_WEB810_DTD_FILE_NAME));
144: }
145: }
146:
147: /**
148: * Set the Security Domain.
149: *
150: * @param securityDomain The new Security Domain value
151: */
152: public void setSecuritydomain(String securityDomain) {
153: this .securityDomain = securityDomain;
154: }
155:
156: /**
157: * Set the Description.
158: *
159: * @param description The new Description value
160: */
161: public void setDescription(String description) {
162: this .description = description;
163: }
164:
165: /**
166: * Set the Context Root.
167: *
168: * @param contextRoot The new ContextRoot value
169: */
170: public void setContextRoot(String contextRoot) {
171: this .contextRoot = contextRoot;
172: }
173:
174: /**
175: * @created 20 Feb 2004
176: */
177: public static class Version extends
178: org.apache.tools.ant.types.EnumeratedAttribute {
179: public final static String VERSION_6_1 = "6.1";
180: // NOT FULLY SUPPORTED YET
181: public final static String VERSION_7_0 = "7.0";
182: public final static String VERSION_8_1 = "8.1";
183:
184: /**
185: * Gets the Values attribute of the WebLogic Version object
186: *
187: * @return The Values value
188: */
189: public java.lang.String[] getValues() {
190: return (new java.lang.String[] { VERSION_6_1, VERSION_7_0,
191: VERSION_8_1 });
192: }
193: }
194: }
|