KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > web > metamodel > descriptor > WebDD


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.web.metamodel.descriptor;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.Collection JavaDoc;
26 import java.util.HashMap JavaDoc;
27 import java.util.List JavaDoc;
28
29 import org.jboss.logging.Logger;
30 import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
31 import org.jboss.metamodel.descriptor.Listener;
32 import org.jboss.metamodel.descriptor.MessageDestination;
33
34 /**
35  * Represents the web.xml deployment descriptor for the 2.5 schema
36  *
37  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
38  * @version <tt>$Revision: 56236 $</tt>
39  */

40 public class WebDD extends EnvironmentRefGroup
41 {
42    private static final Logger log = Logger.getLogger(WebDD.class);
43    
44    protected String JavaDoc securityDomain;
45    protected HashMap JavaDoc filters = new HashMap JavaDoc();
46    protected HashMap JavaDoc filterMappings = new HashMap JavaDoc();
47    protected HashMap JavaDoc listeners = new HashMap JavaDoc();
48    protected HashMap JavaDoc servlets = new HashMap JavaDoc();
49    protected HashMap JavaDoc servletMappings = new HashMap JavaDoc();
50    protected List JavaDoc sessionConfigs = new ArrayList JavaDoc();
51    protected List JavaDoc securityConstraints = new ArrayList JavaDoc();
52    protected HashMap JavaDoc securityRoles = new HashMap JavaDoc();
53    protected LoginConfig loginConfig;
54    protected HashMap JavaDoc errorPages = new HashMap JavaDoc();
55    protected HashMap JavaDoc messageDestinations = new HashMap JavaDoc();
56    protected List JavaDoc dependencies = new ArrayList JavaDoc();
57    protected ReplicationConfig replicationConfig;
58    
59    public String JavaDoc getSecurityDomain()
60    {
61       return securityDomain;
62    }
63    
64    public void setSecurityDomain(String JavaDoc securityDomain)
65    {
66       this.securityDomain = securityDomain;
67    }
68    
69    public Collection JavaDoc getFilters()
70    {
71       return filters.values();
72    }
73
74    public void addFilter(Filter filter)
75    {
76       filters.put(filter.getName(), filter);
77    }
78    
79    public Collection JavaDoc getFilterMappings()
80    {
81       return filterMappings.values();
82    }
83
84    public void addFilterMapping(FilterMapping mapping)
85    {
86       filterMappings.put(mapping.getFilterName(), mapping);
87    }
88    
89    public Collection JavaDoc getListeners()
90    {
91       return listeners.values();
92    }
93
94    public void addListener(Listener listener)
95    {
96       listeners.put(listener.getListenerClass(), listener);
97    }
98    
99    public Collection JavaDoc getServlets()
100    {
101       return servlets.values();
102    }
103
104    public void addServlet(Servlet servlet)
105    {
106       servlets.put(servlet.getName(), servlet);
107    }
108    
109    public void updateServlet(Servlet updatedServlet)
110    {
111       Servlet servlet = (Servlet)servlets.get(updatedServlet.getName());
112       if (servlet != null)
113       {
114          servlet.setRunAsPrincipals(updatedServlet.getRunAsPrincipals());
115       }
116       else
117       {
118          servlets.put(updatedServlet.getName(), updatedServlet);
119       }
120    }
121    
122    public Collection JavaDoc getServletMappings()
123    {
124       return servletMappings.values();
125    }
126
127    public void addServletMapping(ServletMapping mapping)
128    {
129       servletMappings.put(mapping.getName(), mapping);
130    }
131    
132    public Collection JavaDoc getSessionConfigs()
133    {
134       return sessionConfigs;
135    }
136
137    public void addSessionConfig(SessionConfig config)
138    {
139       sessionConfigs.add(config);
140    }
141    
142    public Collection JavaDoc getSecurityRoles()
143    {
144       return securityRoles.values();
145    }
146
147    public void addSecurityRole(SecurityRole securityRole)
148    {
149       securityRoles.put(securityRole.getRoleName(), securityRole);
150    }
151    
152    public void updateSecurityRole(SecurityRole updatedRole)
153    {
154       SecurityRole role = (SecurityRole)securityRoles.get(updatedRole.getRoleName());
155       if (role != null)
156       {
157          role.setPrincipalName(updatedRole.getPrincipalName());
158       }
159       else
160       {
161          securityRoles.put(updatedRole.getRoleName(), updatedRole);
162       }
163    }
164    
165    public Collection JavaDoc getSecurityConstraints()
166    {
167       return securityConstraints;
168    }
169
170    public void addSecurityConstraint(SecurityConstraint constraint)
171    {
172       securityConstraints.add(constraint);
173    }
174    
175    public LoginConfig getLoginConfig()
176    {
177       return loginConfig;
178    }
179    
180    public void setLoginConfig(LoginConfig loginConfig)
181    {
182       this.loginConfig = loginConfig;
183    }
184    
185    public Collection JavaDoc getErrorPages()
186    {
187       return errorPages.values();
188    }
189
190    public void addErrorPage(ErrorPage errorPage)
191    {
192       errorPages.put(errorPage.getErrorCode(), errorPage);
193    }
194    
195    public Collection JavaDoc getMessageDestinations()
196    {
197       return messageDestinations.values();
198    }
199
200    public void addMessageDestination(MessageDestination destination)
201    {
202       log.debug("addMessageDestination, "+destination);
203       messageDestinations.put(destination.getMessageDestinationName(), destination);
204    }
205    public void updateMessageDestination(MessageDestination updatedDestination)
206    {
207       MessageDestination destination = (MessageDestination)
208          messageDestinations.get(updatedDestination.getMessageDestinationName());
209       if (destination != null)
210       {
211          destination.setMappedName(updatedDestination.getMappedName());
212       }
213       else
214       {
215          messageDestinations.put(updatedDestination.getMessageDestinationName(), updatedDestination);
216       }
217    }
218
219    public void addDependency(String JavaDoc depends)
220    {
221       dependencies.add(depends);
222    }
223
224    public Collection JavaDoc getDependencies()
225    {
226       return dependencies;
227    }
228    
229    public ReplicationConfig getReplicationConfig()
230    {
231       return replicationConfig;
232    }
233    
234    public void setReplicationConfig(ReplicationConfig replicationConfig)
235    {
236       this.replicationConfig = replicationConfig;
237    }
238    
239    public String JavaDoc toString()
240    {
241       StringBuffer JavaDoc sb = new StringBuffer JavaDoc(100);
242       sb.append('[');
243       sb.append(']');
244       return sb.toString();
245    }
246 }
247
Popular Tags