001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.pluto.descriptors.servlet;
018:
019: import org.apache.pluto.descriptors.common.IconDD;
020:
021: import java.util.ArrayList;
022: import java.util.Iterator;
023: import java.util.List;
024:
025: /**
026: * WebApplication configuration as contained
027: * within the web.xml Deployment Descriptor.
028: *
029: * @version $Id: WebAppDD.java 157475 2005-03-14 22:13:18Z ddewolf $
030: * @since Feb 28, 2005
031: */
032: public class WebAppDD {
033:
034: private IconDD icon;
035: private String displayName;
036: private String description;
037: private List contextParams = new ArrayList();
038: private List filters = new ArrayList();
039: private List filterMappings = new ArrayList();
040: private List listeners = new ArrayList();
041: private List servlets = new ArrayList();
042: private List servletMappings = new ArrayList();
043: private SessionConfigDD sessionConfig;
044: private List mimeMappings = new ArrayList();
045: private WelcomeFileListDD welcomeFileList;
046: private List errorPages = new ArrayList();
047: private List taglibs = new ArrayList();
048: private List resourceRefs = new ArrayList();
049: private List securityConstraints = new ArrayList();
050: private LoginConfigDD loginConfig;
051: private List securityRoles = new ArrayList();
052: private List envEntrys = new ArrayList();
053: private List ejbRefs = new ArrayList();
054: // Default to servletVersion 2.3. If a <web-app>
055: // element is present with a version attribute,
056: // the Castor mapping will update this field.
057: private String servletVersion = "2.3";
058: // Default to false. If a <web-app>
059: // contains a <distributable/> element, then
060: // Castor will update this field to true.
061: private DistributableDD distributableDD = new DistributableDD();
062:
063: public WebAppDD() {
064:
065: }
066:
067: public IconDD getIcon() {
068: return icon;
069: }
070:
071: public void setIcon(IconDD icon) {
072: this .icon = icon;
073: }
074:
075: public String getDisplayName() {
076: return displayName;
077: }
078:
079: public void setDisplayName(String displayName) {
080: this .displayName = displayName;
081: }
082:
083: public String getDescription() {
084: return description;
085: }
086:
087: public void setDescription(String description) {
088: this .description = description;
089: }
090:
091: public boolean isDistributable() {
092: return distributableDD.isDistributable().booleanValue();
093: }
094:
095: public DistributableDD getDistributable() {
096: return distributableDD;
097: }
098:
099: public void setDistributable() {
100: this .distributableDD.setDistributable(true);
101: }
102:
103: public void setDistributable(boolean distributable) {
104: this .distributableDD.setDistributable(distributable);
105: }
106:
107: /**
108: * Retrieve the context parameters.
109: * @return InitParamDD instances.
110: */
111: public List getContextParams() {
112: return contextParams;
113: }
114:
115: public void setContextParams(List contextParams) {
116: this .contextParams = contextParams;
117: }
118:
119: public List getFilters() {
120: return filters;
121: }
122:
123: public void setFilters(List filters) {
124: this .filters = filters;
125: }
126:
127: public List getFilterMappings() {
128: return filterMappings;
129: }
130:
131: public void setFilterMappings(List filterMappings) {
132: this .filterMappings = filterMappings;
133: }
134:
135: public List getListeners() {
136: return listeners;
137: }
138:
139: public void setListeners(List listeners) {
140: this .listeners = listeners;
141: }
142:
143: public List getServlets() {
144: return servlets;
145: }
146:
147: public void setServlets(List servlets) {
148: this .servlets = servlets;
149: }
150:
151: public List getServletMappings() {
152: return servletMappings;
153: }
154:
155: public void setServletMappings(List servletMappings) {
156: this .servletMappings = servletMappings;
157: }
158:
159: public SessionConfigDD getSessionConfig() {
160: return sessionConfig;
161: }
162:
163: public void setSessionConfig(SessionConfigDD sessionConfig) {
164: this .sessionConfig = sessionConfig;
165: }
166:
167: public List getMimeMappings() {
168: return mimeMappings;
169: }
170:
171: public void setMimeMappings(List mimeMappings) {
172: this .mimeMappings = mimeMappings;
173: }
174:
175: public WelcomeFileListDD getWelcomeFileList() {
176: return welcomeFileList;
177: }
178:
179: public void setWelcomeFileList(WelcomeFileListDD welcomeFileList) {
180: this .welcomeFileList = welcomeFileList;
181: }
182:
183: public List getErrorPages() {
184: return errorPages;
185: }
186:
187: public void setErrorPages(List errorPages) {
188: this .errorPages = errorPages;
189: }
190:
191: public List getTaglibs() {
192: return taglibs;
193: }
194:
195: public void setTaglibs(List taglibs) {
196: this .taglibs = taglibs;
197: }
198:
199: public List getResourceRefs() {
200: return resourceRefs;
201: }
202:
203: public void setResourceRefs(List resourceRefs) {
204: this .resourceRefs = resourceRefs;
205: }
206:
207: public List getSecurityConstraints() {
208: return securityConstraints;
209: }
210:
211: public void setSecurityConstraints(List securityConstraints) {
212: this .securityConstraints = securityConstraints;
213: }
214:
215: public LoginConfigDD getLoginConfig() {
216: return loginConfig;
217: }
218:
219: public void setLoginConfig(LoginConfigDD loginConfig) {
220: this .loginConfig = loginConfig;
221: }
222:
223: public List getSecurityRoles() {
224: return securityRoles;
225: }
226:
227: public void setSecurityRoles(List securityRoles) {
228: this .securityRoles = securityRoles;
229: }
230:
231: public List getEnvEntrys() {
232: return envEntrys;
233: }
234:
235: public void setEnvEntrys(List envEntrys) {
236: this .envEntrys = envEntrys;
237: }
238:
239: public List getEjbRefs() {
240: return ejbRefs;
241: }
242:
243: public void setEjbRefs(List ejbRefs) {
244: this .ejbRefs = ejbRefs;
245: }
246:
247: public String getServletVersion() {
248: return servletVersion;
249: }
250:
251: public void setServletVersion(String servletVersion) {
252: this .servletVersion = servletVersion;
253: }
254:
255: // Helpers
256:
257: public ServletDD getServlet(String name) {
258: ArrayList set = new ArrayList(servlets);
259: Iterator it = set.iterator();
260: ServletDD dd;
261: while (name != null && it.hasNext()) {
262: dd = (ServletDD) it.next();
263: if (name.equals(dd.getServletName())) {
264: return dd;
265: }
266: }
267: return null;
268: }
269:
270: public ServletMappingDD getServletMapping(String uri) {
271: ArrayList set = new ArrayList(servletMappings);
272: Iterator it = set.iterator();
273: ServletMappingDD dd;
274: while (uri != null && it.hasNext()) {
275: dd = (ServletMappingDD) it.next();
276: if (uri.equals(dd.getUrlPattern())) {
277: return dd;
278: }
279: }
280: return null;
281: }
282:
283: }
|