KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > metadata > WebMetaData


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.metadata;
23
24 import java.net.URLClassLoader JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.Collection JavaDoc;
27 import java.util.HashMap JavaDoc;
28 import java.util.HashSet JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.Map JavaDoc;
32 import java.util.Set JavaDoc;
33
34 import javax.management.MalformedObjectNameException JavaDoc;
35
36 import org.jboss.deployment.DeploymentException;
37 import org.jboss.logging.Logger;
38 import org.jboss.metadata.web.ErrorPage;
39 import org.jboss.metadata.web.Filter;
40 import org.jboss.metadata.web.FilterMapping;
41 import org.jboss.metadata.web.LoginConfig;
42 import org.jboss.metadata.web.ParamValue;
43 import org.jboss.metadata.web.PassivationConfig;
44 import org.jboss.metadata.web.ReplicationConfig;
45 import org.jboss.metadata.web.Servlet;
46 import org.jboss.metadata.web.ServletMapping;
47 import org.jboss.metadata.web.SessionConfig;
48 import org.jboss.metamodel.descriptor.ResourceEnvRef;
49 import org.jboss.metamodel.descriptor.ResourceRef;
50 import org.jboss.mx.loading.LoaderRepositoryFactory;
51 import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
52 import org.jboss.mx.util.ObjectNameFactory;
53 import org.jboss.security.RunAsIdentity;
54 import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData;
55 import org.w3c.dom.Element JavaDoc;
56
57 /** A representation of the web.xml and jboss-web.xml deployment
58  * descriptors as used by the AbstractWebContainer web container integration
59  * support class.
60  *
61  * @see org.jboss.metadata.web.WebMetaDataObjectFactory
62  * @see org.jboss.web.AbstractWebContainer
63  *
64  * @author Scott.Stark@jboss.org
65  * @version $Revision: 58547 $
66  */

67 public class WebMetaData extends MetaData
68 {
69    private static Logger log = Logger.getLogger(WebMetaData.class);
70
71    /** web-app/description */
72    private String JavaDoc description;
73    /** web-app/display-name */
74    private String JavaDoc displayName;
75    /** An alternate web.xml descriptor the web container should parse */
76    private String JavaDoc altDDPath;
77    /** web-app/context-param */
78    private List JavaDoc<ParamValue> contextParams = new ArrayList JavaDoc<ParamValue>();
79    /** web-app/init-param */
80    private List JavaDoc<ParamValue> initParams = new ArrayList JavaDoc<ParamValue>();
81    
82    private HashMap JavaDoc<String JavaDoc, Servlet> servlets = new HashMap JavaDoc<String JavaDoc, Servlet>();
83    /** The web.xml servlet-mapping <String, String> */
84    private HashMap JavaDoc<String JavaDoc, ServletMapping> servletMappings = new HashMap JavaDoc<String JavaDoc, ServletMapping>();
85    /** The web.xml resource-refs */
86    private HashMap JavaDoc<String JavaDoc, ResourceRefMetaData> resourceReferences =
87       new HashMap JavaDoc<String JavaDoc, ResourceRefMetaData>();
88    /** The web.xml resource-env-refs */
89    private HashMap JavaDoc<String JavaDoc, ResourceEnvRefMetaData> resourceEnvReferences =
90       new HashMap JavaDoc<String JavaDoc, ResourceEnvRefMetaData>();
91    /** The web.xml message-destination-refs */
92    private HashMap JavaDoc<String JavaDoc, MessageDestinationRefMetaData> messageDestinationReferences
93       = new HashMap JavaDoc<String JavaDoc, MessageDestinationRefMetaData>();
94    /** The web.xml message-destination */
95    private HashMap JavaDoc<String JavaDoc, MessageDestinationMetaData> messageDestinations =
96          new HashMap JavaDoc<String JavaDoc, MessageDestinationMetaData>();
97    /** web-app/filter */
98    protected HashMap JavaDoc<String JavaDoc, Filter> filters = new HashMap JavaDoc<String JavaDoc, Filter>();
99    /** web-app/filter-mapping */
100    protected HashMap JavaDoc<String JavaDoc, FilterMapping> filterMappings =
101       new HashMap JavaDoc<String JavaDoc, FilterMapping>();
102    protected HashMap JavaDoc listeners = new HashMap JavaDoc();
103    protected List JavaDoc<SessionConfig> sessionConfigs = new ArrayList JavaDoc<SessionConfig>();
104    /** web.xml security-constraint */
105    protected List JavaDoc<WebSecurityMetaData> securityConstraints =
106       new ArrayList JavaDoc<WebSecurityMetaData>();
107    protected LoginConfig loginConfig;
108    protected HashMap JavaDoc<String JavaDoc, ErrorPage> errorPages = new HashMap JavaDoc<String JavaDoc, ErrorPage>();
109    protected List JavaDoc<String JavaDoc> dependencies = new ArrayList JavaDoc<String JavaDoc>();
110    protected ReplicationConfig replicationConfig;
111    protected PassivationConfig passivationConfig;
112
113    /** web.xml env-entrys */
114    private ArrayList JavaDoc<EnvEntryMetaData> environmentEntries = new ArrayList JavaDoc<EnvEntryMetaData>();
115    /** The HashMap for the security-roles */
116    private HashMap JavaDoc<String JavaDoc, SecurityRoleMetaData> securityRoles = new HashMap JavaDoc<String JavaDoc, SecurityRoleMetaData>();
117    /** web.xml ejb-refs */
118    private HashMap JavaDoc ejbReferences = new HashMap JavaDoc();
119    /** web.xml ejb-local-refs */
120    private HashMap JavaDoc<String JavaDoc, EjbLocalRefMetaData> ejbLocalReferences = new HashMap JavaDoc<String JavaDoc, EjbLocalRefMetaData>();
121    /** The web.xml service-refs */
122    private HashMap JavaDoc serviceReferences = new HashMap JavaDoc();
123    /** web.xml security-role-refs <String servlet-name, ArrayList<SecurityRoleRefMetaData>> */
124    private HashMap JavaDoc securityRoleReferences = new HashMap JavaDoc();
125    /** The web.xml servlet/run-as <String servlet-name, String role> */
126    private HashMap JavaDoc runAsNames = new HashMap JavaDoc();
127    /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity> */
128    private HashMap JavaDoc runAsIdentity = new HashMap JavaDoc();
129    /** The web.xml distributable flag */
130    private boolean distributable = false;
131    /** The jboss-web.xml class-loading.java2ClassLoadingCompliance flag */
132    private boolean java2ClassLoadingCompliance = false;
133    /** The jboss-web.xml class-loading/loader-repository */
134    private LoaderRepositoryConfig loaderConfig;
135    /** The war context root as specified at the jboss-web.xml descriptor level. */
136    private String JavaDoc contextRoot;
137    /** The JACC context id for the container */
138    private String JavaDoc jaccContextID;
139    /** The jboss-web.xml server container virtual hosts the war should be deployed into */
140    private ArrayList JavaDoc virtualHosts = new ArrayList JavaDoc();
141    /** The jboss-web.xml JNDI name of the security domain implementation */
142    private String JavaDoc securityDomain;
143    /** The jboss-web.xml securityDomain flushOnSessionInvalidation attribute */
144    private boolean flushOnSessionInvalidation;
145    /** A HashMap<String, String> for webservice description publish locations */
146    private HashMap JavaDoc wsdlPublishLocationMap = new HashMap JavaDoc();
147    /** True if this is a web service deployment */
148    private boolean webServiceDeployment;
149    /** The optional JBossWS config-name */
150    private String JavaDoc configName;
151    /** The optional JBossWS config-file */
152    private String JavaDoc configFile;
153    /** The web context class loader used to create the java:comp context */
154    private ClassLoader JavaDoc encLoader;
155    /** The web context class loader, used to create the ws4ee service endpoint */
156    private ClassLoader JavaDoc cxtLoader;
157    /** ArrayList<ObjectName> of the web app dependencies */
158    private ArrayList JavaDoc depends = new ArrayList JavaDoc();
159
160    /**
161     * this is really a hack for new injection code so that we can reparse web.xml/jbossweb.xml for JavaEE 5 injections
162     * todo remove this when we clean up
163     */

164    private HashMap JavaDoc arbitraryMetadata = new HashMap JavaDoc();
165
166    public static final int SESSION_INVALIDATE_ACCESS =0;
167    public static final int SESSION_INVALIDATE_SET_AND_GET =1;
168    public static final int SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET =2;
169    public static final int SESSION_INVALIDATE_SET =3;
170
171    private int invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
172
173    public static final int REPLICATION_TYPE_SYNC = 0;
174    public static final int REPLICATION_TYPE_ASYNC = 1;
175
176    /**
177     * @deprecated Since JBoss3.2.6.
178     */

179    private int replicationType = REPLICATION_TYPE_SYNC;
180
181    /** Specify the session replication granularity level: session --- whole session level,
182     * attribute --- per attribute change, field --- fine grained user object level.
183     *
184     */

185    public static final int REPLICATION_GRANULARITY_SESSION = 0;
186    public static final int REPLICATION_GRANULARITY_ATTRIBUTE = 1;
187    public static final int REPLICATION_GRANULARITY_FIELD = 2;
188    private int replicationGranularity = REPLICATION_GRANULARITY_SESSION;
189
190    /**
191     * If the replication granularity is FIELD, specify whether to use batch mode
192     * for pojo replication or not.
193     */

194    private boolean replicationFieldBatchMode = true;
195    
196    /**
197     * If true then the session passivation is enabled for this web app.
198     * If false then the session passivation is disabled for this web app.
199     */

200    private boolean sessionPassivationMode = false;
201    
202    /**
203     * Min time (seconds) the session must be idle since lastAccesstime before it's eligable for passivation
204     * This overrides maxActive_, to prevent thrashing if the there are lots of active sessions.
205     * Setting to -1 means it's ignored
206     */

207    private int sessionPassivationMinIdleTime = -1;
208    
209    /**
210     * Max time (seconds) the session must be idle since lastAccesstime before it's eligable for passivation
211     * This overrides maxActive_, to prevent thrashing if the there are lots of active sessions.
212     * Setting to -1 means session should not be forced out.
213     */

214    private int sessionPassivationMaxIdleTime = -1;
215    
216    /**
217     * The maximum number of active sessions allowed, or -1 for no limit
218     */

219    private int maxActiveSessions = -1;
220    
221
222    /** Should the context use session cookies or use default */
223    private int sessionCookies = SESSION_COOKIES_DEFAULT;
224
225    public static final int SESSION_COOKIES_DEFAULT=0;
226    public static final int SESSION_COOKIES_ENABLED=1;
227    public static final int SESSION_COOKIES_DISABLED=2;
228
229    /** The ClassLoader to load additional resources */
230    private URLClassLoader JavaDoc resourceCl;
231
232    public String JavaDoc getDescription()
233    {
234       return description;
235    }
236
237    public void setDescription(String JavaDoc description)
238    {
239       this.description = description;
240    }
241
242    public String JavaDoc getDisplayName()
243    {
244       return displayName;
245    }
246
247    public void setDisplayName(String JavaDoc displayName)
248    {
249       this.displayName = displayName;
250    }
251
252    public String JavaDoc getAltDDPath()
253    {
254       return altDDPath;
255    }
256    public void setAltDDPath(String JavaDoc altDDPath)
257    {
258       this.altDDPath = altDDPath;
259    }
260
261    public List JavaDoc<ParamValue> getContextParams()
262    {
263       return contextParams;
264    }
265    public void addContextParam(ParamValue pv)
266    {
267       contextParams.add(pv);
268    }
269    public List JavaDoc<ParamValue> getInitParams()
270    {
271       return initParams;
272    }
273    public void addInitParam(ParamValue pv)
274    {
275       initParams.add(pv);
276    }
277
278    public HashMap JavaDoc getArbitraryMetadata()
279    {
280       return arbitraryMetadata;
281    }
282
283    /** Set the ClassLoader to load additional resources */
284    public void setResourceClassLoader(URLClassLoader JavaDoc resourceCl)
285    {
286       this.resourceCl = resourceCl;
287    }
288
289    public void addFilter(Filter filter)
290    {
291       filters.put(filter.getName(), filter);
292    }
293    
294    public Collection JavaDoc getFilterMappings()
295    {
296       return filterMappings.values();
297    }
298
299    public void addFilterMapping(FilterMapping mapping)
300    {
301       filterMappings.put(mapping.getFilterName(), mapping);
302    }
303    
304    public Collection JavaDoc getListeners()
305    {
306       return listeners.values();
307    }
308
309    public void addListener(Listener listener)
310    {
311       listeners.put(listener.getListenerClass(), listener);
312    }
313    
314    public Collection JavaDoc getServlets()
315    {
316       return servlets.values();
317    }
318
319    public void addServlet(Servlet servlet)
320    {
321       String JavaDoc servletName = servlet.getName();
322       servlets.put(servletName, servlet);
323    }
324    
325    public void updateServlet(Servlet updatedServlet)
326    {
327       Servlet servlet = (Servlet)servlets.get(updatedServlet.getName());
328       if (servlet != null)
329       {
330          servlet.setRunAsPrincipals(updatedServlet.getRunAsPrincipals());
331       }
332       else
333       {
334          servlets.put(updatedServlet.getName(), updatedServlet);
335       }
336    }
337    
338    public Collection JavaDoc getServletMappings()
339    {
340       return servletMappings.values();
341    }
342
343    public void addServletMapping(ServletMapping mapping)
344    {
345       servletMappings.put(mapping.getName(), mapping);
346    }
347    
348    public Collection JavaDoc getSessionConfigs()
349    {
350       return sessionConfigs;
351    }
352
353    public void addSessionConfig(SessionConfig config)
354    {
355       sessionConfigs.add(config);
356    }
357    
358    public void addSecurityRole(SecurityRoleMetaData securityRole)
359    {
360       securityRoles.put(securityRole.getRoleName(), securityRole);
361    }
362    
363    public void updateSecurityRole(SecurityRoleMetaData updatedRole)
364    {
365       SecurityRoleMetaData role = securityRoles.get(updatedRole.getRoleName());
366       if (role != null)
367       {
368          role.setRoleName(updatedRole.getRoleName());
369       }
370       else
371       {
372          securityRoles.put(updatedRole.getRoleName(), updatedRole);
373       }
374    }
375    
376    public Collection JavaDoc getSecurityConstraints()
377    {
378       return securityConstraints;
379    }
380
381    public void addSecurityConstraint(WebSecurityMetaData constraint)
382    {
383       securityConstraints.add(constraint);
384    }
385    
386    public LoginConfig getLoginConfig()
387    {
388       return loginConfig;
389    }
390    
391    public void setLoginConfig(LoginConfig loginConfig)
392    {
393       this.loginConfig = loginConfig;
394    }
395    
396    public Collection JavaDoc getErrorPages()
397    {
398       return errorPages.values();
399    }
400
401    public void addErrorPage(ErrorPage errorPage)
402    {
403       errorPages.put(errorPage.getErrorCode(), errorPage);
404    }
405    
406    public Collection JavaDoc getMessageDestinations()
407    {
408       return messageDestinations.values();
409    }
410
411    public void addEjbLocalRef(EjbLocalRefMetaData ref)
412    {
413       this.ejbLocalReferences.put(ref.getName(), ref);
414    }
415    public void addEjbRef(EjbRefMetaData ref)
416    {
417       this.ejbReferences.put(ref.getName(), ref);
418    }
419    public void addEnvEntry(EnvEntryMetaData ref)
420    {
421       this.environmentEntries.add(ref);
422    }
423    public void addMessageDestinationRef(MessageDestinationRefMetaData ref)
424    {
425       this.messageDestinationReferences.put(ref.getRefName(), ref);
426    }
427    public void addMessageDestination(MessageDestinationMetaData destination)
428    {
429       log.debug("addMessageDestination, "+destination);
430       messageDestinations.put(destination.getName(), destination);
431    }
432    public void updateMessageDestination(MessageDestinationMetaData updatedDestination)
433    {
434       MessageDestinationMetaData destination = (MessageDestinationMetaData)
435          messageDestinations.get(updatedDestination.getName());
436       if (destination != null)
437       {
438          destination.setJNDIName(updatedDestination.getMappedName());
439       }
440       else
441       {
442          messageDestinations.put(updatedDestination.getName(), updatedDestination);
443       }
444    }
445    public void addResourceEnvRef(ResourceEnvRefMetaData ref)
446    {
447       this.resourceEnvReferences.put(ref.getRefName(), ref);
448    }
449    public void updateResourceEnvRef(ResourceEnvRefMetaData updatedRef)
450    {
451       ResourceEnvRefMetaData ref = (ResourceEnvRefMetaData)resourceEnvReferences.get(updatedRef.getRefName());
452       if (ref != null)
453       {
454          ref.setJndiName(updatedRef.getJndiName());
455       }
456       else
457       {
458          this.addResourceEnvRef(updatedRef);
459       }
460    }
461
462    public void addResourceRef(ResourceRefMetaData ref)
463    {
464       this.resourceReferences.put(ref.getRefName(), ref);
465    }
466    public void updateResourceRef(ResourceRefMetaData updatedRef)
467    {
468       ResourceRefMetaData ref = (ResourceRefMetaData)resourceReferences.get(updatedRef.getRefName());
469       if (ref != null)
470       {
471          ref.setJndiName(updatedRef.getJndiName());
472          ref.setResURL(updatedRef.getResURL());
473          ref.setResourceName(updatedRef.getResourceName());
474       }
475       else
476       {
477          this.addResourceRef(updatedRef);
478       }
479    }
480
481    public void addDependency(String JavaDoc depends)
482    {
483       dependencies.add(depends);
484    }
485
486    public Collection JavaDoc<String JavaDoc> getDependencies()
487    {
488       return dependencies;
489    }
490    
491    public ReplicationConfig getReplicationConfig()
492    {
493       return replicationConfig;
494    }
495    
496    public void setReplicationConfig(ReplicationConfig replicationConfig)
497    {
498       this.replicationConfig = replicationConfig;
499    }
500
501    public PassivationConfig getPassivationConfig()
502    {
503       return passivationConfig;
504    }
505
506    public void setPassivationConfig(PassivationConfig passivationConfig)
507    {
508       this.passivationConfig = passivationConfig;
509    }
510
511    /** Return an iterator of the env-entry mappings.
512     @return Iterator of EnvEntryMetaData objects.
513     */

514    public Iterator JavaDoc<EnvEntryMetaData> getEnvironmentEntries()
515    {
516       return environmentEntries.iterator();
517    }
518    /**
519     *
520     * @param environmentEntries - Collection<EnvEntryMetaData>
521     */

522    public void setEnvironmentEntries(Collection JavaDoc environmentEntries)
523    {
524       this.environmentEntries.clear();
525       this.environmentEntries.addAll(environmentEntries);
526    }
527
528    /** Return an iterator of the ejb-ref mappings.
529     @return Iterator of EjbRefMetaData objects.
530     */

531    public Iterator JavaDoc getEjbReferences()
532    {
533       return ejbReferences.values().iterator();
534    }
535    /**
536     *
537     * @param ejbReferences - Map<String, EjbRefMetaData>
538     */

539    public void setEjbReferences(Map JavaDoc ejbReferences)
540    {
541       this.ejbReferences.clear();
542       this.ejbReferences.putAll(ejbReferences);
543    }
544
545    /** Return an iterator of the ejb-local-ref mappings.
546     @return Iterator of EjbLocalRefMetaData objects.
547     */

548    public Iterator JavaDoc<EjbLocalRefMetaData> getEjbLocalReferences()
549    {
550       return ejbLocalReferences.values().iterator();
551    }
552    public Map JavaDoc<String JavaDoc, EjbLocalRefMetaData> getEjbLocalReferenceMap()
553    {
554       return ejbLocalReferences;
555    }
556    /**
557     *
558     * @param ejbReferences - Map<String, EjbRefMetaData>
559     */

560    public void setEjbLocalReferences(Map JavaDoc ejbReferences)
561    {
562       this.ejbLocalReferences.clear();
563       this.ejbLocalReferences.putAll(ejbReferences);
564    }
565
566    /** Return an iterator of the resource-ref mappings.
567     @return Iterator of ResourceRefMetaData objects.
568     */

569    public Iterator JavaDoc getResourceReferences()
570    {
571       return resourceReferences.values().iterator();
572    }
573    /**
574     *
575     * @param resourceReferences - Map<String, ResourceRefMetaData>
576     */

577    public void setResourceReferences(Map JavaDoc resourceReferences)
578    {
579       this.resourceReferences.clear();
580       this.resourceReferences.putAll(resourceReferences);
581    }
582
583    /** Return an iterator of the resource-ref mappings.
584     @return Iterator of ResourceEnvRefMetaData objects.
585     */

586    public Iterator JavaDoc getResourceEnvReferences()
587    {
588       return resourceEnvReferences.values().iterator();
589    }
590    /**
591     *
592     * @param resourceReferences - Map<String, ResourceEnvRefMetaData>
593     */

594    public void setResourceEnvReferences(Map JavaDoc resourceReferences)
595    {
596       this.resourceEnvReferences.clear();
597       this.resourceEnvReferences.putAll(resourceReferences);
598    }
599
600    /**
601     * Return an iterator of message-destination-refs.
602     *
603     * @return Iterator of MessageDestinationRefMetaData objects.
604     */

605    public Iterator JavaDoc getMessageDestinationReferences()
606    {
607       return messageDestinationReferences.values().iterator();
608    }
609    /**
610     *
611     * @param messageDestinationReferences - Map<String, MessageDestinationRefMetaData>
612     */

613    public void setMessageDestinationReferences(Map JavaDoc messageDestinationReferences)
614    {
615       this.messageDestinationReferences.clear();
616       this.messageDestinationReferences.putAll(messageDestinationReferences);
617    }
618
619    /**
620     * Get a message destination metadata
621     *
622     * @param name the name of the message destination
623     * @return the message destination metadata
624     */

625    public MessageDestinationMetaData getMessageDestination(String JavaDoc name)
626    {
627       return (MessageDestinationMetaData) messageDestinations.get(name);
628    }
629    /**
630     *
631     * @param messageDestinations - Map<String, MessageDestinationMetaData>
632     */

633    public void setMessageDestination(Map JavaDoc messageDestinations)
634    {
635       this.messageDestinations.clear();
636       this.messageDestinations.putAll(messageDestinations);
637    }
638
639    /** Return an iterator of the service-ref mappings.
640     * @return Iterator of ServiceRefMetaData objects
641     */

642    public Iterator JavaDoc getServiceReferences()
643    {
644       return serviceReferences.values().iterator();
645    }
646    /**
647     *
648     * @param serviceReferences - Map<String, ServiceRefMetaData>
649     */

650    public void setServiceReferences(Map JavaDoc serviceReferences)
651    {
652       this.serviceReferences.clear();
653       this.serviceReferences.putAll(serviceReferences);
654    }
655
656    /** This the the jboss-web.xml descriptor context-root and it
657     *is only meaningful if a war is deployed outside of an ear.
658     */

659    public String JavaDoc getContextRoot()
660    {
661       return contextRoot;
662    }
663    public void setContextRoot(String JavaDoc contextRoot)
664    {
665       this.contextRoot = contextRoot;
666    }
667
668    public String JavaDoc getConfigFile()
669    {
670       return configFile;
671    }
672
673    public void setConfigFile(String JavaDoc configFile)
674    {
675       this.configFile = configFile;
676    }
677
678    public String JavaDoc getConfigName()
679    {
680       return configName;
681    }
682
683    public void setConfigName(String JavaDoc configName)
684    {
685       this.configName = configName;
686    }
687
688    public HashMap JavaDoc getWsdlPublishLocations()
689    {
690       return wsdlPublishLocationMap;
691    }
692
693    /** Get the optional wsdl publish location from jboss-web.xml. */
694    public String JavaDoc getWsdlPublishLocationByName(String JavaDoc name)
695    {
696       return (String JavaDoc)wsdlPublishLocationMap.get(name);
697    }
698    /**
699     *
700     * @param wsdlPublishLocationMap - Map<String, String>
701     */

702    public void setWsdlPublishLocationMap(Map JavaDoc wsdlPublishLocationMap)
703    {
704       this.wsdlPublishLocationMap.clear();
705       this.wsdlPublishLocationMap.putAll(wsdlPublishLocationMap);
706    }
707
708    public boolean isWebServiceDeployment()
709    {
710       return webServiceDeployment;
711    }
712
713    public void setWebServiceDeployment(boolean webServiceDeployment)
714    {
715       this.webServiceDeployment = webServiceDeployment;
716    }
717
718    public String JavaDoc getJaccContextID()
719    {
720       return jaccContextID;
721    }
722    public void setJaccContextID(String JavaDoc jaccContextID)
723    {
724       this.jaccContextID = jaccContextID;
725    }
726
727    /** Return the optional security-domain jboss-web.xml element.
728     @return The jndiName of the security manager implementation that is
729     responsible for security of the web application. May be null if
730     there was no security-domain specified in the jboss-web.xml
731     descriptor.
732     */

733    public String JavaDoc getSecurityDomain()
734    {
735       return securityDomain;
736    }
737
738    /** Set the security domain for this web application
739     */

740    public void setSecurityDomain(String JavaDoc securityDomain)
741    {
742       this.securityDomain = securityDomain;
743    }
744
745    /** The flag indicating whether the associated security domain cache
746     * should be flushed when the session is invalidated.
747     * @return true if the flush should occur, false otherwise.
748     */

749    public boolean isFlushOnSessionInvalidation()
750    {
751       return flushOnSessionInvalidation;
752    }
753    /** The flag indicating whether the associated security domain cache
754     * should be flushed when the session is invalidated.
755     * @param flag - true if the flush should occur, false otherwise.
756     */

757    public void setFlushOnSessionInvalidation(boolean flag)
758    {
759       this.flushOnSessionInvalidation = flag;
760    }
761
762    /** Get the security-constraint settings
763     */

764    public Iterator JavaDoc<WebSecurityMetaData> getSecurityContraints()
765    {
766       return securityConstraints.iterator();
767    }
768
769    /**
770     *
771     * @param securityContraints - Collection<WebSecurityMetaData>
772     */

773    public void setSecurityConstraints(Collection JavaDoc<WebSecurityMetaData> securityContraints)
774    {
775       this.securityConstraints.clear();
776       this.securityConstraints.addAll(securityContraints);
777    }
778
779    /**
780     * @return <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
781     */

782    public Map JavaDoc getSecurityRoleRefs()
783    {
784       return this.securityRoleReferences;
785    }
786    /**
787     *
788     * @param servletName
789     * @return List<SecurityRoleRefMetaData> for the given servlet name
790     */

791    public List JavaDoc getSecurityRoleRefs(String JavaDoc servletName)
792    {
793       List JavaDoc roles = (List JavaDoc) this.securityRoleReferences.get(servletName);
794       return roles;
795    }
796    /**
797     *
798     * @param securityRoleReferences - <String servlet-name, ArrayList<SecurityRoleRefMetaData>>
799     */

800    public void setSecurityRoleReferences(Map JavaDoc securityRoleReferences)
801    {
802       this.securityRoleReferences.clear();
803       this.securityRoleReferences.putAll(securityRoleReferences);
804    }
805
806    /**
807     * Get the security-role names from the web.xml descriptor
808     * @return Set<String> of the security-role names from the web.xml
809     */

810    public Set JavaDoc getSecurityRoleNames()
811    {
812       return new HashSet JavaDoc(securityRoles.keySet());
813    }
814
815    /** Get the optional map of security role/user mapping.
816     * @return Map<String, SecurityRoleMetaData>
817     */

818    public Map JavaDoc getSecurityRoles()
819    {
820       return new HashMap JavaDoc(securityRoles);
821    }
822    /**
823     *
824     * @param securityRoles - Map<String, SecurityRoleMetaData>
825     */

826    public void setSecurityRoles(Map JavaDoc securityRoles)
827    {
828       this.securityRoles.clear();
829       this.securityRoles.putAll(securityRoles);
830    }
831
832    /**
833     *
834     * @param userName
835     * @return Set<String>
836     */

837    public Set JavaDoc getSecurityRoleNamesByPrincipal(String JavaDoc userName)
838    {
839       HashSet JavaDoc roleNames = new HashSet JavaDoc();
840       Iterator JavaDoc it = securityRoles.values().iterator();
841       while (it.hasNext())
842       {
843          SecurityRoleMetaData srMetaData = (SecurityRoleMetaData) it.next();
844          if (srMetaData.getPrincipals().contains(userName))
845             roleNames.add(srMetaData.getRoleName());
846       }
847       return roleNames;
848    }
849    
850    /**
851     * Get a map of principals versus set of roles
852     * that may be configured by the user at the deployment level
853     * @return
854     */

855    public Map JavaDoc getPrincipalVersusRolesMap()
856    {
857       Map JavaDoc principalRolesMap = null;
858       
859       Iterator JavaDoc iter = securityRoles.keySet().iterator();
860       while(iter.hasNext())
861       {
862          if(principalRolesMap == null)
863             principalRolesMap = new HashMap JavaDoc();
864          String JavaDoc rolename = (String JavaDoc)iter.next();
865          SecurityRoleMetaData srm = (SecurityRoleMetaData) securityRoles.get(rolename);
866          Iterator JavaDoc principalIter = srm.getPrincipals().iterator();
867          while(principalIter.hasNext())
868          {
869             String JavaDoc pr = (String JavaDoc)principalIter.next();
870             Set JavaDoc roleset = (Set JavaDoc)principalRolesMap.get(pr);
871             if(roleset == null)
872                roleset = new HashSet JavaDoc();
873             if(!roleset.contains(rolename))
874                roleset.add(rolename);
875             principalRolesMap.put(pr, roleset);
876          }
877       }
878       return principalRolesMap;
879    }
880
881    /**
882     * Access the RunAsIdentity associated with the given servlet
883     * @param servletName - the servlet-name from the web.xml
884     * @return RunAsIdentity for the servet if one exists, null otherwise
885     */

886    public RunAsIdentity getRunAsIdentity(String JavaDoc servletName)
887    {
888       RunAsIdentity runAs = (RunAsIdentity) runAsIdentity.get(servletName);
889       if( runAs == null )
890       {
891          // Check for a web.xml run-as only specification
892
synchronized( runAsIdentity )
893          {
894             String JavaDoc roleName = (String JavaDoc) runAsNames.get(servletName);
895             if( roleName != null )
896             {
897                runAs = new RunAsIdentity(roleName, null);
898                runAsIdentity.put(servletName, runAs);
899             }
900          }
901       }
902       return runAs;
903    }
904    /**
905     *
906     * @return servlet/run-as <String servlet-name, RunAsIdentity>
907     */

908    public Map JavaDoc getRunAsIdentity()
909    {
910       return runAsIdentity;
911    }
912    /** The jboss-web.xml servlet/run-as <String servlet-name, RunAsIdentity>
913     */

914    public void setRunAsIdentity(Map JavaDoc runAsIdentity)
915    {
916       this.runAsIdentity.clear();
917       this.runAsIdentity.putAll(runAsIdentity);
918    }
919
920    /**
921     * Get the servlet-name values from the web.xml descriptor
922     * @return Set<String> of the servlet-names from the servlet-mappings
923     */

924    public Set JavaDoc getServletNames()
925    {
926       return new HashSet JavaDoc(servletMappings.keySet());
927    }
928
929    /**
930     * Merge the security role/principal mapping defined in jboss-web.xml
931     * with the one defined at jboss-app.xml.
932     */

933    public void mergeSecurityRoles(Map JavaDoc<String JavaDoc, SecurityRoleMetaData> applRoles)
934    {
935       Iterator JavaDoc<Map.Entry JavaDoc<String JavaDoc, SecurityRoleMetaData>> it = applRoles.entrySet().iterator();
936       while (it.hasNext())
937       {
938          Map.Entry JavaDoc<String JavaDoc, SecurityRoleMetaData> entry = it.next();
939          String JavaDoc roleName = entry.getKey();
940          SecurityRoleMetaData appRole = entry.getValue();
941          SecurityRoleMetaData srMetaData = securityRoles.get(roleName);
942          if (srMetaData != null)
943          {
944             Set JavaDoc principalNames = appRole.getPrincipals();
945             srMetaData.addPrincipalNames(principalNames);
946          }
947          else
948          {
949             securityRoles.put(roleName, entry.getValue());
950          }
951       }
952    }
953
954    /** The servlet container virtual host the war should be deployed into. If
955     null then the servlet container default host should be used.
956     */

957    public Iterator JavaDoc getVirtualHosts()
958    {
959       return virtualHosts.iterator();
960    }
961    /**
962     *
963     * @param virtualHosts - Collection<String>
964     */

965    public void setVirtualHosts(Collection JavaDoc virtualHosts)
966    {
967       this.virtualHosts.clear();
968       this.virtualHosts.addAll(virtualHosts);
969    }
970
971    /**
972      The distributable flag.
973      @return true if the web-app is marked distributable
974     */

975    public boolean getDistributable()
976    {
977       return distributable;
978    }
979    /**
980     * Mark the web-app as distributable
981     * @param distributable - true for distributable
982     */

983    public void setDistributable(boolean distributable)
984    {
985       this.distributable = distributable;
986    }
987
988    /** Access the web application depends
989     * @return Iterator of JMX ObjectNames the web app depends on.
990     */

991    public Collection JavaDoc getDepends()
992    {
993       return depends;
994    }
995    /**
996     @param depends - Collection<ObjectName> of the web app dependencies
997     */

998    public void setDepends(Collection JavaDoc depends)
999    {
1000      this.depends.clear();
1001      this.depends.addAll(depends);
1002   }
1003
1004   /** A flag indicating if the normal Java2 parent first class loading model
1005    * should be used over the servlet 2.3 web container first model.
1006    * @return true for parent first, false for the servlet 2.3 model
1007    */

1008   public boolean getJava2ClassLoadingCompliance()
1009   {
1010      return java2ClassLoadingCompliance;
1011   }
1012   public void setJava2ClassLoadingCompliance(boolean flag)
1013   {
1014      java2ClassLoadingCompliance = flag;
1015   }
1016
1017   public LoaderRepositoryConfig getLoaderConfig()
1018   {
1019      return loaderConfig;
1020   }
1021   public void setLoaderConfig(LoaderRepositoryConfig loaderConfig)
1022   {
1023      this.loaderConfig = loaderConfig;
1024   }
1025
1026   public ClassLoader JavaDoc getENCLoader()
1027   {
1028      return encLoader;
1029   }
1030   public void setENCLoader(ClassLoader JavaDoc encLoader)
1031   {
1032      this.encLoader = encLoader;
1033   }
1034
1035   public ClassLoader JavaDoc getContextLoader()
1036   {
1037      return cxtLoader;
1038   }
1039
1040   /** Make sure this is called during performDeploy */
1041   public void setContextLoader(ClassLoader JavaDoc cxtLoader)
1042   {
1043      this.cxtLoader = cxtLoader;
1044   }
1045
1046   public int getSessionCookies()
1047   {
1048      return this.sessionCookies;
1049   }
1050   public void setSessionCookies(int sessionCookies)
1051   {
1052      this.sessionCookies = sessionCookies;
1053   }
1054
1055   public int getInvalidateSessionPolicy()
1056   {
1057      return this.invalidateSessionPolicy;
1058   }
1059   public void setInvalidateSessionPolicy(int invalidateSessionPolicy)
1060   {
1061      this.invalidateSessionPolicy = invalidateSessionPolicy;
1062   }
1063
1064   public int getReplicationType()
1065   {
1066      return replicationType;
1067   }
1068
1069   public int getReplicationGranularity()
1070   {
1071      return replicationGranularity;
1072   }
1073   public void setReplicationGranularity(int replicationGranularity)
1074   {
1075      this.replicationGranularity = replicationGranularity;
1076   }
1077
1078   public boolean getReplicationFieldBatchMode()
1079   {
1080      return replicationFieldBatchMode;
1081   }
1082   
1083   public boolean getSessionPassivationMode()
1084   {
1085      return sessionPassivationMode;
1086   }
1087   
1088   public void setSessionPassivationMode(boolean mode)
1089   {
1090      this.sessionPassivationMode = mode;
1091   }
1092   
1093   public int getSessionPassivationMinIdleTime()
1094   {
1095      return sessionPassivationMinIdleTime;
1096   }
1097   
1098   public void setSessionPassivationMinIdleTime(int time)
1099   {
1100      this.sessionPassivationMinIdleTime = time;
1101   }
1102   
1103   public int getSessionPassivationMaxIdleTime()
1104   {
1105      return sessionPassivationMaxIdleTime;
1106   }
1107   
1108   public void setSessionPassivationMaxIdleTime(int time)
1109   {
1110      this.sessionPassivationMaxIdleTime = time;
1111   }
1112   
1113   public int getMaxActiveSessionsAllowed()
1114   {
1115      return maxActiveSessions;
1116   }
1117   
1118   public void setMaxActiveSessionsAllowed(int maxActive)
1119   {
1120      this.maxActiveSessions = maxActive;
1121   }
1122
1123   /** Parse the elements of the jboss-web element used by the integration layer.
1124    */

1125   protected void importJBossWebXml(Element JavaDoc jbossWeb) throws DeploymentException
1126   {
1127      // Parse the jboss-web/root-context element
1128
Element JavaDoc contextRootElement = getOptionalChild(jbossWeb, "context-root");
1129      if( contextRootElement != null )
1130         contextRoot = getElementContent(contextRootElement);
1131
1132      // Parse the jboss-web/security-domain element
1133
Element JavaDoc securityDomainElement = getOptionalChild(jbossWeb, "security-domain");
1134      if( securityDomainElement != null )
1135      {
1136         securityDomain = getElementContent(securityDomainElement);
1137         // Check the flushOnSessionInvalidation attribute
1138
Boolean JavaDoc flag = Boolean.valueOf(securityDomainElement.getAttribute("flushOnSessionInvalidation"));
1139         flushOnSessionInvalidation = flag.booleanValue();
1140      }
1141
1142      // Parse the jboss-web/virtual-host elements
1143
for( Iterator JavaDoc virtualHostElements = getChildrenByTagName(jbossWeb, "virtual-host");
1144         virtualHostElements.hasNext();)
1145      {
1146         Element JavaDoc virtualHostElement = (Element JavaDoc)virtualHostElements.next();
1147         String JavaDoc virtualHostName = getElementContent(virtualHostElement);
1148         virtualHosts.add(virtualHostName);
1149      } // end of for ()
1150

1151      // Parse the jboss-web/resource-ref elements
1152
Iterator JavaDoc iterator = getChildrenByTagName(jbossWeb, "resource-ref");
1153      while( iterator.hasNext() )
1154      {
1155         Element JavaDoc resourceRef = (Element JavaDoc) iterator.next();
1156         String JavaDoc resRefName = getElementContent(getUniqueChild(resourceRef, "res-ref-name"));
1157         ResourceRefMetaData refMetaData = (ResourceRefMetaData) resourceReferences.get(resRefName);
1158         if( refMetaData == null )
1159         {
1160            throw new DeploymentException("resource-ref " + resRefName
1161               + " found in jboss-web.xml but not in web.xml");
1162         }
1163         refMetaData.importJbossXml(resourceRef);
1164      }
1165
1166      // Parse the jboss-web/resource-env-ref elements
1167
iterator = getChildrenByTagName(jbossWeb, "resource-env-ref");
1168      while( iterator.hasNext() )
1169      {
1170         Element JavaDoc resourceRef = (Element JavaDoc) iterator.next();
1171         String JavaDoc resRefName = getElementContent(getUniqueChild(resourceRef, "resource-env-ref-name"));
1172         ResourceEnvRefMetaData refMetaData = (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName);
1173         if( refMetaData == null )
1174         {
1175            throw new DeploymentException("resource-env-ref " + resRefName
1176               + " found in jboss-web.xml but not in web.xml");
1177         }
1178         refMetaData.importJbossXml(resourceRef);
1179      }
1180
1181      // update the message destination references (optional)
1182
iterator = getChildrenByTagName(jbossWeb, "message-destination-ref");
1183      while (iterator.hasNext())
1184      {
1185         Element JavaDoc messageDestinationRef = (Element JavaDoc) iterator.next();
1186         String JavaDoc messageDestinationRefName = getElementContent(getUniqueChild(messageDestinationRef, "message-destination-ref-name"));
1187         MessageDestinationRefMetaData messageDestinationRefMetaData = (MessageDestinationRefMetaData) messageDestinationReferences.get(messageDestinationRefName);
1188         if (messageDestinationRefMetaData == null)
1189            throw new DeploymentException("message-destination-ref " + messageDestinationRefName + " found in jboss-web.xml but not in web.xml");
1190         messageDestinationRefMetaData.importJbossXml(messageDestinationRef);
1191      }
1192
1193      // set the message destinations (optional)
1194
iterator = getChildrenByTagName(jbossWeb, "message-destination");
1195      while (iterator.hasNext())
1196      {
1197         Element JavaDoc messageDestination = (Element JavaDoc) iterator.next();
1198         try
1199         {
1200            String JavaDoc messageDestinationName = getUniqueChildContent(messageDestination, "message-destination-name");
1201            MessageDestinationMetaData messageDestinationMetaData = (MessageDestinationMetaData) messageDestinations.get(messageDestinationName);
1202            if (messageDestinationMetaData == null)
1203               throw new DeploymentException("message-destination " + messageDestinationName + " found in jboss-web.xml but not in web.xml");
1204            messageDestinationMetaData.importJbossXml(messageDestination);
1205         }
1206         catch (Throwable JavaDoc t)
1207         {
1208            throw new DeploymentException("Error in web.xml " +
1209               "for message destination: " + t.getMessage());
1210         }
1211      }
1212
1213      // set the security roles (optional)
1214
iterator = getChildrenByTagName(jbossWeb, "security-role");
1215      while (iterator.hasNext())
1216      {
1217         Element JavaDoc securityRole = (Element JavaDoc) iterator.next();
1218         String JavaDoc roleName = getElementContent(getUniqueChild(securityRole, "role-name"));
1219         SecurityRoleMetaData securityRoleMetaData = (SecurityRoleMetaData)securityRoles.get(roleName);
1220         if (securityRoleMetaData == null)
1221            throw new DeploymentException("Security role '" + roleName + "' defined in jboss-web.xml" +
1222                    " is not defined in web.xml");
1223
1224         Iterator JavaDoc itPrincipalNames = getChildrenByTagName(securityRole, "principal-name");
1225         while (itPrincipalNames.hasNext())
1226         {
1227            String JavaDoc principalName = getElementContent((Element JavaDoc) itPrincipalNames.next());
1228            securityRoleMetaData.addPrincipalName(principalName);
1229         }
1230      }
1231
1232      // Parse the jboss-web/ejb-ref elements
1233
iterator = getChildrenByTagName(jbossWeb, "ejb-ref");
1234      while( iterator.hasNext() )
1235      {
1236         Element JavaDoc ejbRef = (Element JavaDoc) iterator.next();
1237         String JavaDoc ejbRefName = getElementContent(getUniqueChild(ejbRef, "ejb-ref-name"));
1238         EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName);
1239         if( ejbRefMetaData == null )
1240         {
1241            throw new DeploymentException("ejb-ref " + ejbRefName
1242               + " found in jboss-web.xml but not in web.xml");
1243         }
1244         ejbRefMetaData.importJbossXml(ejbRef);
1245      }
1246
1247      // Parse the jboss-web/ejb-local-ref elements
1248
iterator = getChildrenByTagName(jbossWeb, "ejb-local-ref");
1249      while( iterator.hasNext() )
1250      {
1251         Element JavaDoc ejbLocalRef = (Element JavaDoc) iterator.next();
1252         String JavaDoc ejbLocalRefName = getElementContent(getUniqueChild(ejbLocalRef, "ejb-ref-name"));
1253         EjbLocalRefMetaData ejbLocalRefMetaData = (EjbLocalRefMetaData) ejbLocalReferences.get(ejbLocalRefName);
1254         if( ejbLocalRefMetaData == null )
1255         {
1256            throw new DeploymentException("ejb-local-ref " + ejbLocalRefName
1257               + " found in jboss-web.xml but not in web.xml");
1258         }
1259         ejbLocalRefMetaData.importJbossXml(ejbLocalRef);
1260      }
1261
1262      // Parse the service-ref elements
1263
iterator = MetaData.getChildrenByTagName(jbossWeb, "service-ref");
1264      while (iterator.hasNext())
1265      {
1266         Element JavaDoc serviceRef = (Element JavaDoc) iterator.next();
1267         String JavaDoc serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name");
1268         ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName);
1269         if (refMetaData == null)
1270         {
1271            log.warn("service-ref " + serviceRefName + " found in jboss-web.xml but not in web.xml");
1272            refMetaData = new ServiceRefMetaData(serviceRefName);
1273            serviceReferences.put(serviceRefName, refMetaData);
1274         }
1275         refMetaData.importJBossXml(serviceRef);
1276      }
1277
1278      // WebserviceDescriptions
1279
iterator = getChildrenByTagName(jbossWeb, "webservice-description");
1280      while (iterator.hasNext())
1281      {
1282         Element JavaDoc wsd = (Element JavaDoc)iterator.next();
1283         String JavaDoc wsdName = getElementContent(getUniqueChild(wsd, "webservice-description-name"));
1284         configName = MetaData.getOptionalChildContent(wsd, "config-name");
1285         configFile = MetaData.getOptionalChildContent(wsd, "config-file");
1286         String JavaDoc wsdlPublishLocation = getOptionalChildContent(wsd, "wsdl-publish-location");
1287         wsdlPublishLocationMap.put(wsdName, wsdlPublishLocation);
1288      }
1289
1290      // Parse the jboss-web/depends elements
1291
for( Iterator JavaDoc dependsElements = getChildrenByTagName(jbossWeb, "depends");
1292         dependsElements.hasNext();)
1293      {
1294         Element JavaDoc dependsElement = (Element JavaDoc)dependsElements.next();
1295         String JavaDoc dependsName = getElementContent(dependsElement);
1296         depends.add(ObjectNameFactory.create(dependsName));
1297      } // end of for ()
1298

1299      // Parse the jboss-web/use-session-cookies element
1300
iterator = getChildrenByTagName(jbossWeb, "use-session-cookies");
1301      if ( iterator.hasNext() )
1302      {
1303         Element JavaDoc useCookiesElement = (Element JavaDoc) iterator.next();
1304         String JavaDoc useCookiesElementContent = getElementContent(useCookiesElement);
1305         Boolean JavaDoc useCookies=Boolean.valueOf(useCookiesElementContent);
1306
1307         if (useCookies.booleanValue())
1308         {
1309            sessionCookies=SESSION_COOKIES_ENABLED;
1310         }
1311         else
1312         {
1313            sessionCookies=SESSION_COOKIES_DISABLED;
1314         }
1315      }
1316      
1317      // parse the jboss-web/max-active-sessions
1318
Element JavaDoc maxActiveSessionsElement = getOptionalChild(jbossWeb, "max-active-sessions");
1319      if(maxActiveSessionsElement != null)
1320      {
1321         maxActiveSessions = Integer.valueOf(getElementContent(maxActiveSessionsElement)).intValue();
1322      }
1323
1324      log.info("WebMetaData:importJBossWebXml: maxActiveSessions = " + maxActiveSessions);
1325      // parse the jboss-web/passivation-config element
1326
Element JavaDoc sessionPassivationRootElement = getOptionalChild(jbossWeb, "passivation-config");
1327      if( sessionPassivationRootElement != null)
1328      {
1329         // manage "use-session-passivation" first ...
1330
Element JavaDoc usePassivationElement = MetaData.getOptionalChild(sessionPassivationRootElement, "use-session-passivation");
1331         if (usePassivationElement != null && Boolean.valueOf(getElementContent(usePassivationElement)).booleanValue())
1332         {
1333            sessionPassivationMode = true;
1334         }
1335         else
1336         {
1337            sessionPassivationMode = false;
1338         }
1339         log.info("WebMetaData:importJBossWebXml: sessionPassivationMode = " + sessionPassivationMode);
1340         // then manage passivation-min-idle-time and -passivation-max-idle-time
1341
if (getSessionPassivationMode())
1342         {
1343            Element JavaDoc minIdleTimeElement = MetaData.getOptionalChild(sessionPassivationRootElement, "passivation-min-idle-time");
1344            if (minIdleTimeElement != null)
1345            {
1346               Long JavaDoc minIdleTimeValue = Long.valueOf(getElementContent(minIdleTimeElement));
1347               sessionPassivationMinIdleTime = minIdleTimeValue.intValue();
1348               log.info("WebMetaData:importJBossWebXml: sessionPassivationMinIdleTime = " + sessionPassivationMinIdleTime);
1349            }
1350            
1351            Element JavaDoc maxIdleTimeElement = MetaData.getOptionalChild(sessionPassivationRootElement, "passivation-max-idle-time");
1352            if (maxIdleTimeElement != null)
1353            {
1354               Long JavaDoc maxIdleTimeValue = Long.valueOf(getElementContent(maxIdleTimeElement));
1355               sessionPassivationMaxIdleTime = maxIdleTimeValue.intValue();
1356               log.info("WebMetaData:importJBossWebXml: sessionPassivationMaxIdleTime = " + sessionPassivationMaxIdleTime);
1357            }
1358         }
1359      }
1360      // Parse the jboss-web/session-replication element
1361

1362      Element JavaDoc sessionReplicationRootElement = getOptionalChild(jbossWeb, "replication-config");
1363      if( sessionReplicationRootElement != null )
1364      {
1365         // manage "replication-trigger" first ...
1366
//
1367
Element JavaDoc replicationTriggerElement = getOptionalChild(sessionReplicationRootElement, "replication-trigger");
1368         if (replicationTriggerElement != null)
1369         {
1370            String JavaDoc repMethod = getElementContent(replicationTriggerElement);
1371            if ("SET_AND_GET".equalsIgnoreCase(repMethod))
1372               this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_GET;
1373            else if ("SET_AND_NON_PRIMITIVE_GET".equalsIgnoreCase(repMethod))
1374               this.invalidateSessionPolicy = SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
1375            else if ("SET".equalsIgnoreCase(repMethod))
1376               this.invalidateSessionPolicy = SESSION_INVALIDATE_SET;
1377            else
1378               throw new DeploymentException("replication-trigger value set to a non-valid value: '" + repMethod
1379                  + "' (should be ['SET_AND_GET', 'SET_AND_NON_PRIMITIVE_GET', 'SET']) in jboss-web.xml");
1380         }
1381
1382         // ... then manage "replication-type".
1383
//
1384
Element JavaDoc replicationTypeElement = getOptionalChild(sessionReplicationRootElement, "replication-type");
1385         if (replicationTypeElement != null)
1386         {
1387            String JavaDoc repType = getElementContent(replicationTypeElement);
1388            if ("SYNC".equalsIgnoreCase(repType))
1389               this.replicationType = REPLICATION_TYPE_SYNC;
1390            else if ("ASYNC".equalsIgnoreCase(repType))
1391               this.replicationType = REPLICATION_TYPE_ASYNC;
1392            else
1393               throw new DeploymentException("replication-type value set to a non-valid value: '" + repType
1394                  + "' (should be ['SYNC', 'ASYNC']) in jboss-web.xml");
1395         }
1396
1397         // ... then manage "replication-type".
1398
//
1399
Element JavaDoc replicationGranularityElement = MetaData.getOptionalChild(sessionReplicationRootElement, "replication-granularity");
1400         if (replicationGranularityElement != null)
1401         {
1402            String JavaDoc repType = MetaData.getElementContent(replicationGranularityElement);
1403            if ("SESSION".equalsIgnoreCase(repType))
1404               this.replicationGranularity = REPLICATION_GRANULARITY_SESSION;
1405            else if ("ATTRIBUTE".equalsIgnoreCase(repType))
1406               this.replicationGranularity = REPLICATION_GRANULARITY_ATTRIBUTE;
1407            else if ("FIELD".equalsIgnoreCase(repType))
1408               this.replicationGranularity = REPLICATION_GRANULARITY_FIELD;
1409            else
1410               throw new DeploymentException("replication-granularity value set to a non-valid value: '" + repType
1411                  + "' (should be ['SESSION', 'ATTRIBUTE', or 'FIELD'']) in jboss-web.xml");
1412         }
1413
1414         Element JavaDoc batchModeElement = MetaData.getOptionalChild(sessionReplicationRootElement, "replication-field-batch-mode");
1415         if (batchModeElement != null)
1416         {
1417            Boolean JavaDoc flag = Boolean.valueOf(MetaData.getElementContent(batchModeElement));
1418            replicationFieldBatchMode = flag.booleanValue();
1419         }
1420      }
1421
1422      // Check for a war level class loading config
1423
Element JavaDoc classLoading = MetaData.getOptionalChild(jbossWeb, "class-loading");
1424      if( classLoading != null )
1425      {
1426         String JavaDoc flagString = classLoading.getAttribute("java2ClassLoadingCompliance");
1427         if( flagString.length() == 0 )
1428            flagString = "true";
1429         boolean flag = Boolean.valueOf(flagString).booleanValue();
1430         setJava2ClassLoadingCompliance(flag);
1431         // Check for a loader-repository for scoping
1432
Element JavaDoc loader = MetaData.getOptionalChild(classLoading, "loader-repository");
1433         if( loader != null )
1434         {
1435            try
1436            {
1437               loaderConfig = LoaderRepositoryFactory.parseRepositoryConfig(loader);
1438            }
1439            catch (MalformedObjectNameException JavaDoc e)
1440            {
1441               throw new DeploymentException(e);
1442            }
1443         }
1444      }
1445
1446      // Parse the jboss-web/servlet elements
1447
iterator = getChildrenByTagName(jbossWeb, "servlet");
1448      while (iterator.hasNext())
1449      {
1450         Element JavaDoc servlet = (Element JavaDoc)iterator.next();
1451         String JavaDoc servletName = getElementContent(getUniqueChild(servlet, "servlet-name"));
1452         String JavaDoc principalName = getOptionalChildContent(servlet, "run-as-principal");
1453         // Get the web.xml run-as primary role
1454
String JavaDoc webXmlRunAs = (String JavaDoc) runAsNames.get(servletName);
1455         if( principalName != null )
1456         {
1457            if( webXmlRunAs == null )
1458            {
1459               throw new DeploymentException("run-as-principal: " + principalName
1460               + " found in jboss-web.xml but there was no run-as in web.xml");
1461            }
1462            // See if there are any additional roles for this principal
1463
Set JavaDoc extraRoles = getSecurityRoleNamesByPrincipal(principalName);
1464            RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, principalName, extraRoles);
1465            runAsIdentity.put(servletName, runAs);
1466         }
1467         else if( webXmlRunAs != null )
1468         {
1469            RunAsIdentity runAs = new RunAsIdentity(webXmlRunAs, null);
1470            runAsIdentity.put(servletName, runAs);
1471         }
1472      }
1473   }
1474
1475}
1476
Popular Tags