You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by cm...@apache.org on 2003/04/30 17:38:41 UTC

cvs commit: jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/webxml WebXmlMerger.java

cmlenz      2003/04/30 08:38:41

  Modified:    integration/ant/src/java/org/apache/cactus/integration/ant/webxml
                        Tag: CACTUS_14_ANT_BRANCH WebXmlMerger.java
  Log:
  Make most of the methods protected, so that the only entry point from outside is the main merge(WebXml) method. Also, move the generation of a warning when a 2.3 descriptor is merged into a 2.2 descriptor into this class.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.2   +39 -19    jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/webxml/WebXmlMerger.java
  
  Index: WebXmlMerger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/webxml/WebXmlMerger.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- WebXmlMerger.java	27 Apr 2003 10:00:50 -0000	1.4.2.1
  +++ WebXmlMerger.java	30 Apr 2003 15:38:41 -0000	1.4.2.2
  @@ -105,7 +105,8 @@
        */
       public final void merge(WebXml theMergeWebXml)
       {
  -        if (WebXml.SERVLET_VERSION_2_3.equals(this.webXml.getVersion()))
  +        checkServletVersions(theMergeWebXml);
  +        if (this.webXml.getVersion() == WebXmlVersion.V2_3)
           {
               mergeFilters(theMergeWebXml);
           }
  @@ -116,13 +117,44 @@
       }
   
       /**
  +     * Sets the log to which events should be written. This method must be 
  +     * called before any of the other methods, because the class will rely on 
  +     * being able to log.
  +     * 
  +     * @param theLog The log to use
  +     */
  +    public final void setLog(Log theLog)
  +    {
  +        this.log = theLog;
  +    }
  +
  +    // Protected Methods -------------------------------------------------------
  +
  +    /**
  +     * Checks the versions of the servlet API in each descriptor, and logs
  +     * a warning if a mismatch might result in the loss of definitions.
  +     * 
  +     * @param theWebXml The descriptor that will be merged with the original
  +     */
  +    protected final void checkServletVersions(WebXml theWebXml)
  +    {
  +        if (this.webXml.getVersion().compareTo(theWebXml.getVersion()) < 0)
  +        {
  +            this.log.warn(
  +                "Merging elements from a version " + theWebXml.getVersion()
  +                + " descriptor into a version " + this.webXml.getVersion() 
  +                + ", some elements may be skipped");
  +        }
  +    }
  +
  +    /**
        * Merges the servlet definitions from the specified descriptor into the 
        * original descriptor.
        * 
        * @param theWebXml The descriptor that contains the filter definitions
        *         that are to be merged into the original descriptor
        */
  -    public final void mergeFilters(WebXml theWebXml)
  +    protected final void mergeFilters(WebXml theWebXml)
       {
           Iterator filterNames = theWebXml.getFilterNames();
           int count = 0;
  @@ -167,7 +199,7 @@
        * @param theWebXml The descriptor that contains the servlet definitions
        *         that are to be merged into the original descriptor
        */
  -    public final void mergeServlets(WebXml theWebXml)
  +    protected final void mergeServlets(WebXml theWebXml)
       {
           Iterator servletNames = theWebXml.getServletNames();
           int count = 0;
  @@ -212,7 +244,7 @@
        * @param theWebXml The descriptor that contains the security constraints
        *         that are to be merged into the original descriptor
        */
  -    public final void mergeSecurityConstraints(WebXml theWebXml)
  +    protected final void mergeSecurityConstraints(WebXml theWebXml)
       {
           Iterator securityConstraints =
               theWebXml.getElements(WebXmlTag.SECURITY_CONSTRAINT);
  @@ -234,7 +266,7 @@
        * @param theWebXml The descriptor that contains the login config that
        *         is to be merged into the original descriptor
        */
  -    public final void mergeLoginConfig(WebXml theWebXml)
  +    protected final void mergeLoginConfig(WebXml theWebXml)
       {
           Iterator loginConfigs = theWebXml.getElements(WebXmlTag.LOGIN_CONFIG);
           if (loginConfigs.hasNext())
  @@ -252,7 +284,7 @@
        * @param theWebXml The descriptor that contains the security roles that
        *         are to be merged into the original descriptor
        */
  -    public final void mergeSecurityRoles(WebXml theWebXml)
  +    protected final void mergeSecurityRoles(WebXml theWebXml)
       {
           Iterator securityRoles =
               theWebXml.getElements(WebXmlTag.SECURITY_ROLE);
  @@ -266,18 +298,6 @@
           }
           this.log.trace("Merged " + count + " security role"
               + (count != 1 ? "s " : " ") + "into the descriptor");
  -    }
  -
  -    /**
  -     * Sets the log to which events should be written. This method must be 
  -     * called before any of the other methods, because the class will rely on 
  -     * being able to log.
  -     * 
  -     * @param theLog The log to use
  -     */
  -    public final void setLog(Log theLog)
  -    {
  -        this.log = theLog;
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org