org.codehaus.cargo.module.webapp
Class WebXmlMerger

java.lang.Object
  extended by org.codehaus.cargo.util.log.LoggedObject
      extended by org.codehaus.cargo.module.webapp.WebXmlMerger
All Implemented Interfaces:
Loggable

public class WebXmlMerger
extends LoggedObject

Helper class that can merge two web deployment descriptors.

Version:
$Id: WebXmlMerger.java 1009 2006-04-28 10:27:05Z magnayn $

Nested Class Summary
protected static interface WebXmlMerger.IMergeImplementation
          Interface used as a callback for descriptors.
 
Field Summary
protected  MergeStrategy mergeContextParamsStrategy
          Strategy for merging context parameters.
protected  MergeStrategy mergeListenerStrategy
          Strategy for merging listeners.
 
Constructor Summary
WebXmlMerger(WebXml theWebXml)
          Constructor.
 
Method Summary
protected  void checkServletVersions(WebXml theWebXml)
          Checks the versions of the servlet API in each descriptor, and logs a warning if a mismatch might result in the loss of definitions.
protected  VendorWebAppDescriptor getVendorWebAppDescriptor(WebXml theWebXml, java.lang.Class clazz)
          Get the vendor web app descriptor out of the web xml.
 void merge(WebXml theMergeWebXml)
          Merges the merge descriptor with the original descriptor.
protected  void mergeContextParams(WebXml theWebXml)
          Merges the context-param definitions from the specified descriptor into the original descriptor.
protected  void mergeEjbLocalRefs(WebXml theWebXml)
          Merges the EJB local references from the provided descriptor into the original descriptor.
protected  void mergeEjbRefs(WebXml theWebXml)
          Merges the EJB references from the provided descriptor into the original descriptor.
protected  void mergeEnvironmentEntries(WebXml theWebXml)
          Merges the environment entries from the provided descriptor into the original descriptor.
protected  void mergeFilters(WebXml theWebXml)
          Merges the servlet definitions from the specified descriptor into the original descriptor.
protected  void mergeListeners(WebXml theWebXml)
          Merges the listener elements from the provided descriptor into the original descriptor.
protected  void mergeLoginConfig(WebXml theWebXml)
          Merges the login configuration from the provided descriptor into the original descriptor, thereby eventually replacing the existing login config.
protected  void mergeResourceEnvironmentReferences(WebXml theWebXml)
          Merges the resource environment references from the provided descriptor into the original descriptor.
protected  void mergeResourceReferences(WebXml theWebXml)
          Merges the resource references from the provided descriptor into the original descriptor.
protected  void mergeSecurityConstraints(WebXml theWebXml)
           
protected  void mergeSecurityRoles(WebXml theWebXml)
          Merges the security roles from the provided descriptor into the original descriptor.
protected  void mergeServlets(WebXml theWebXml)
          Merges the servlet definitions from the specified descriptor into the original descriptor.
protected  void mergeVendorDescriptors(WebXml theWebXml)
          Merge in any vendor specific descriptors.
protected  void mergeVendorDescriptors(WebXml theWebXml, java.lang.Class clazz, WebXmlMerger.IMergeImplementation merger)
          Find vendor descriptors of a specific class, and merge them if they exist.
 void setMergeContextParamsStrategy(MergeStrategy ms)
          Set the merging strategy for context-param nodes.
 
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mergeContextParamsStrategy

protected MergeStrategy mergeContextParamsStrategy
Strategy for merging context parameters.


mergeListenerStrategy

protected MergeStrategy mergeListenerStrategy
Strategy for merging listeners.

Constructor Detail

WebXmlMerger

public WebXmlMerger(WebXml theWebXml)
Constructor.

Parameters:
theWebXml - The original descriptor
Method Detail

setMergeContextParamsStrategy

public void setMergeContextParamsStrategy(MergeStrategy ms)
Set the merging strategy for context-param nodes.

Parameters:
ms - in the merging strategy

merge

public final void merge(WebXml theMergeWebXml)
Merges the merge descriptor with the original descriptor.

Parameters:
theMergeWebXml - The descriptor to merge in

mergeVendorDescriptors

protected final void mergeVendorDescriptors(WebXml theWebXml)
Merge in any vendor specific descriptors.

Parameters:
theWebXml - xml to merge in

mergeVendorDescriptors

protected final void mergeVendorDescriptors(WebXml theWebXml,
                                            java.lang.Class clazz,
                                            WebXmlMerger.IMergeImplementation merger)
Find vendor descriptors of a specific class, and merge them if they exist.

Parameters:
theWebXml - in the web xml to be merged
clazz - in the class of vendor webxml to merge
merger - in the callback class that does the merging

getVendorWebAppDescriptor

protected VendorWebAppDescriptor getVendorWebAppDescriptor(WebXml theWebXml,
                                                           java.lang.Class clazz)
Get the vendor web app descriptor out of the web xml.

Parameters:
theWebXml - in the web xml
clazz - the class of vendor descriptor
Returns:
the VendorWebAppDescriptor, or null if it does not exist in theWebXml

checkServletVersions

protected final void checkServletVersions(WebXml theWebXml)
Checks the versions of the servlet API in each descriptor, and logs a warning if a mismatch might result in the loss of definitions.

Parameters:
theWebXml - The descriptor that will be merged with the original

mergeContextParams

protected final void mergeContextParams(WebXml theWebXml)
                                 throws MergeException
Merges the context-param definitions from the specified descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the context-params definitions that are to be merged into the original descriptor
Throws:
MergeException - if there is a problem performing the merge

mergeFilters

protected final void mergeFilters(WebXml theWebXml)
Merges the servlet definitions from the specified descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the filter definitions that are to be merged into the original descriptor

mergeServlets

protected final void mergeServlets(WebXml theWebXml)
Merges the servlet definitions from the specified descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the servlet definitions that are to be merged into the original descriptor

mergeListeners

protected final void mergeListeners(WebXml theWebXml)
Merges the listener elements from the provided descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the references that are to be merged into the original descriptor

mergeResourceEnvironmentReferences

protected final void mergeResourceEnvironmentReferences(WebXml theWebXml)
Merges the resource environment references from the provided descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the references that are to be merged into the original descriptor

mergeResourceReferences

protected final void mergeResourceReferences(WebXml theWebXml)
Merges the resource references from the provided descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the resource refs that are to be merged into the original descriptor

mergeSecurityConstraints

protected final void mergeSecurityConstraints(WebXml theWebXml)
Parameters:
theWebXml - The descriptor that contains the security constraints that are to be merged into the original descriptor

mergeLoginConfig

protected final void mergeLoginConfig(WebXml theWebXml)
Merges the login configuration from the provided descriptor into the original descriptor, thereby eventually replacing the existing login config.

Parameters:
theWebXml - The descriptor that contains the login config that is to be merged into the original descriptor

mergeSecurityRoles

protected final void mergeSecurityRoles(WebXml theWebXml)
Merges the security roles from the provided descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the security roles that are to be merged into the original descriptor

mergeEnvironmentEntries

protected final void mergeEnvironmentEntries(WebXml theWebXml)
Merges the environment entries from the provided descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the environment entries that are to be merged into the original descriptor

mergeEjbRefs

protected final void mergeEjbRefs(WebXml theWebXml)
Merges the EJB references from the provided descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the EJB refs that are to be merged into the original descriptor

mergeEjbLocalRefs

protected final void mergeEjbLocalRefs(WebXml theWebXml)
Merges the EJB local references from the provided descriptor into the original descriptor.

Parameters:
theWebXml - The descriptor that contains the EJB local refs that are to be merged into the original descriptor


Copyright © 2004-2011 Codehaus. All Rights Reserved.