KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > pluto > om > WebApplicationDefinitionImpl


1 /*
2  * Copyright 2004,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.portal.pluto.om;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Collection JavaDoc;
20 import java.util.HashMap JavaDoc;
21 import java.util.Locale JavaDoc;
22 import java.util.Vector JavaDoc;
23
24 import javax.servlet.ServletContext JavaDoc;
25
26 import org.apache.pluto.om.common.Description;
27 import org.apache.pluto.om.common.DescriptionSet;
28 import org.apache.pluto.om.common.DisplayName;
29 import org.apache.pluto.om.common.DisplayNameSet;
30 import org.apache.pluto.om.common.ObjectID;
31 import org.apache.pluto.om.common.ParameterSet;
32 import org.apache.pluto.om.common.SecurityRoleSet;
33 import org.apache.pluto.om.portlet.PortletApplicationDefinition;
34 import org.apache.pluto.om.servlet.ServletDefinitionList;
35 import org.apache.pluto.om.servlet.WebApplicationDefinition;
36 import org.apache.cocoon.portal.pluto.om.common.ObjectIDImpl;
37 import org.apache.cocoon.portal.pluto.om.common.ParameterSetImpl;
38 import org.apache.cocoon.portal.pluto.om.common.ResourceRefSet;
39 import org.apache.cocoon.portal.pluto.om.common.SecurityRoleSetImpl;
40 import org.apache.cocoon.portal.pluto.om.common.Support;
41 import org.apache.cocoon.portal.pluto.om.common.DescriptionSetImpl;
42 import org.apache.cocoon.portal.pluto.om.common.DisplayNameSetImpl;
43 import org.apache.cocoon.portal.pluto.om.common.TagDefinitionSet;
44
45 /**
46  *
47  *
48  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
49  *
50  * @version CVS $Id: WebApplicationDefinitionImpl.java 326883 2005-10-20 11:01:21Z cziegeler $
51  */

52 public class WebApplicationDefinitionImpl
53 implements WebApplicationDefinition, Support {
54
55
56     // <not used variables - only for castor>
57
public String JavaDoc icon;
58     public String JavaDoc distributable;
59     public String JavaDoc sessionConfig;
60     public String JavaDoc mimeMapping;
61     public String JavaDoc welcomeFileList;
62     public String JavaDoc errorPage;
63     public String JavaDoc taglib;
64     public String JavaDoc resourceRef;
65     public String JavaDoc loginConfig;
66     public String JavaDoc securityRole;
67     public String JavaDoc envEntry;
68     public String JavaDoc ejbRef;
69     private Collection JavaDoc castorMimeMappings = new ArrayList JavaDoc();
70     // </not used variables - only for castor>
71
private Collection JavaDoc securityConstraints = new ArrayList JavaDoc();
72
73     private String JavaDoc contextPath;
74     private DescriptionSet descriptions = new DescriptionSetImpl();
75     private DisplayNameSet displayNames = new DisplayNameSetImpl();
76     private String JavaDoc id = "";
77     private ParameterSet initParams = new ParameterSetImpl();
78     /** The object id */
79     private ObjectID objectId;
80     private Collection JavaDoc servletMappings = new ArrayList JavaDoc();
81     private ServletDefinitionList servlets = new ServletDefinitionListImpl();
82     private SecurityRoleSet securityRoles = new SecurityRoleSetImpl();
83
84     // modified by YCLI: START :: to handle multiple taglib tags and resource-ref tag
85
// private TagDefinition castorTagDefinition = new TagDefinition();
86
private TagDefinitionSet taglibs = new TagDefinitionSet();
87     private ResourceRefSet castorResourceRef = new ResourceRefSet();
88     // modified by YCLI: END
89

90     // WebApplicationDefinition implementation.
91

92     public ObjectID getId() {
93         if (this.objectId == null) {
94             this.objectId = ObjectIDImpl.createFromString(id);
95         }
96         return this.objectId;
97     }
98
99     /* (non-Javadoc)
100      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getDisplayName(Locale)
101      */

102     public DisplayName getDisplayName(Locale JavaDoc locale) {
103         return displayNames.get(locale);
104     }
105
106     /* (non-Javadoc)
107      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getDescription(java.util.Locale)
108      */

109     public Description getDescription(Locale JavaDoc locale) {
110         return descriptions.get(locale);
111     }
112
113     /* (non-Javadoc)
114      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getInitParameterSet()
115      */

116     public ParameterSet getInitParameterSet() {
117         return initParams;
118     }
119
120     /* (non-Javadoc)
121      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getServletDefinitionList()
122      */

123     public ServletDefinitionList getServletDefinitionList() {
124         return servlets;
125     }
126
127     /* (non-Javadoc)
128      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getServletContext(javax.servlet.ServletContext)
129      */

130     public ServletContext JavaDoc getServletContext(ServletContext JavaDoc servletContext) {
131         return servletContext.getContext(contextPath);
132     }
133
134     /* (non-Javadoc)
135      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getContextRoot()
136      */

137     public String JavaDoc getContextRoot() {
138         return contextPath;
139     }
140
141     /* (non-Javadoc)
142      * @see org.apache.cocoon.portal.pluto.om.common.Support#postBuild(java.lang.Object)
143      */

144     public void postBuild(Object JavaDoc parameter) throws Exception JavaDoc {
145         // not needed in this implementation
146
}
147
148     /* (non-Javadoc)
149      * @see org.apache.cocoon.portal.pluto.om.common.Support#postLoad(java.lang.Object)
150      */

151     public void postLoad(Object JavaDoc parameter) throws Exception JavaDoc {
152         Vector JavaDoc structure = (Vector JavaDoc)parameter;
153         PortletApplicationDefinition portletApplication = (PortletApplicationDefinition)structure.get(0);
154
155         ((Support)portletApplication).postLoad(this);
156
157         ((Support)servlets).postLoad(this);
158
159         ((Support)descriptions).postLoad(parameter);
160         ((Support)displayNames).postLoad(parameter);
161
162     }
163
164     /* (non-Javadoc)
165      * @see org.apache.cocoon.portal.pluto.om.common.Support#postStore(java.lang.Object)
166      */

167     public void postStore(Object JavaDoc parameter) throws Exception JavaDoc {
168         ((Support)servlets).postStore(this);
169     }
170
171     /* (non-Javadoc)
172      * @see org.apache.cocoon.portal.pluto.om.common.Support#preBuild(java.lang.Object)
173      */

174     public void preBuild(Object JavaDoc parameter) throws Exception JavaDoc {
175         Vector JavaDoc structure = (Vector JavaDoc)parameter;
176         PortletApplicationDefinition portletApplication = (PortletApplicationDefinition)structure.get(0);
177         String JavaDoc contextString = (String JavaDoc)structure.get(1);
178
179         setContextRoot(contextString);
180
181         HashMap JavaDoc servletMap = new HashMap JavaDoc(1);
182         Vector JavaDoc structure2 = new Vector JavaDoc();
183         structure2.add(this);
184         structure2.add(servletMappings);
185         structure2.add(servletMap);
186
187         ((Support)servlets).preBuild(structure2);
188
189         Vector JavaDoc structure3 = new Vector JavaDoc();
190         structure3.add(contextString);
191         structure3.add(this);
192         structure3.add(servletMap);
193         ((Support)portletApplication).preBuild(structure3);
194     }
195
196     /* (non-Javadoc)
197      * @see org.apache.cocoon.portal.pluto.om.common.Support#preStore(java.lang.Object)
198      */

199     public void preStore(Object JavaDoc parameter) throws Exception JavaDoc {
200         Vector JavaDoc structure = (Vector JavaDoc)parameter;
201         PortletApplicationDefinition portletApplication = (PortletApplicationDefinition)structure.get(0);
202
203         ((Support)portletApplication).preStore(null);
204
205         ((Support)servlets).preStore(this);
206     }
207
208     // additional methods.
209

210     public String JavaDoc getCastorId() {
211         if (id.length() > 0) {
212             return getId().toString();
213         }
214         return null;
215     }
216
217     public Collection JavaDoc getCastorInitParams() {
218         return(ParameterSetImpl)initParams;
219     }
220
221     public Collection JavaDoc getCastorServlets() {
222         return(ServletDefinitionListImpl)servlets;
223     }
224
225     public Collection JavaDoc getCastorDisplayNames() {
226         return(DisplayNameSetImpl)displayNames;
227     }
228
229     public Collection JavaDoc getCastorDescriptions() {
230         return(DescriptionSetImpl)descriptions;
231     }
232
233     public SecurityRoleSet getSecurityRoles() {
234         return securityRoles;
235     }
236
237     public Collection JavaDoc getServletMappings() {
238         return servletMappings;
239     }
240     public void setCastorId(String JavaDoc id) {
241         setId(id);
242     }
243     
244     protected void setContextRoot(String JavaDoc contextPath)
245     {
246         // Test for IBM WebSphere
247
if (contextPath != null && contextPath.endsWith(".war"))
248         {
249             contextPath = contextPath.substring(0, contextPath.length()-4);
250         }
251         this.contextPath = contextPath;
252     }
253
254     public void setDescriptions(DescriptionSet descriptions) {
255         this.descriptions = descriptions;
256     }
257
258     public void setDisplayNames(DisplayNameSet displayNames) {
259         this.displayNames = displayNames;
260     }
261
262     public void setCastorDescriptions(DescriptionSet castorDescriptions) {
263         this.descriptions = castorDescriptions;
264     }
265
266     public void setCastorDisplayNames(DisplayNameSet castorDisplayNames) {
267         this.displayNames = castorDisplayNames;
268     }
269
270     public void setId(String JavaDoc id) {
271         this.id = id;
272         objectId = null;
273     }
274
275      // modified by YCLI: START :: handling multiple taglib tags and resource-ref tag
276

277     /**
278      * @return Custom tag definitions configured in the webapp.
279      */

280     public TagDefinitionSet getTagDefinitionSet() {
281         return taglibs;
282     }
283
284     public Collection JavaDoc getCastorTagDefinitions() {
285         return taglibs;
286     }
287
288     public void setCastorTagDefinitions(TagDefinitionSet taglibs) {
289         this.taglibs = taglibs;
290     }
291
292     public ResourceRefSet getCastorResourceRefSet() {
293         return castorResourceRef;
294     }
295
296     public void setCastorResourceRefSet(ResourceRefSet resourceRefs) {
297         castorResourceRef = resourceRefs;
298     }
299     // modified by YCLI: END
300

301     /**
302      * @return Returns the castorMimeMappings.
303      */

304     public Collection JavaDoc getCastorMimeMappings() {
305         return castorMimeMappings;
306     }
307
308     public Collection JavaDoc getSecurityConstraints() {
309         return securityConstraints;
310     }
311
312     /**
313      * @param castorMimeMappings The castorMimeMappings to set.
314      */

315     public void setCastorMimeMappings(Collection JavaDoc castorMimeMappings) {
316         this.castorMimeMappings = castorMimeMappings;
317     }
318
319     public void setSecurityConstraints(Collection JavaDoc securityConstraints) {
320         this.securityConstraints = securityConstraints;
321     }
322 }
323
Popular Tags