struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject cvs commit: jakarta-struts/src/share/org/apache/struts/action ActionServlet.java
Date Tue, 12 Aug 2003 00:38:40 GMT
dgraham     2003/08/11 17:38:40

  Modified:    src/share/org/apache/struts/action ActionServlet.java
  Log:
  Refactored initConfigDigester() into several smaller methods.
  
  Revision  Changes    Path
  1.168     +43 -20    jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
  
  Index: ActionServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
  retrieving revision 1.167
  retrieving revision 1.168
  diff -u -r1.167 -r1.168
  --- ActionServlet.java	10 Aug 2003 06:00:49 -0000	1.167
  +++ ActionServlet.java	12 Aug 2003 00:38:40 -0000	1.168
  @@ -942,23 +942,13 @@
               return (configDigester);
           }
   
  -        // Check the status of the "validating" initialization parameter
  -        boolean validating = true;
  -        String value = getServletConfig().getInitParameter("validating");
  -        if ("false".equalsIgnoreCase(value)
  -            || "no".equalsIgnoreCase(value)
  -            || "n".equalsIgnoreCase(value)
  -            || "0".equalsIgnoreCase(value)) {
  -
  -            validating = false;
  -        }
  -
           // Create a new Digester instance with standard capabilities
           configDigester = new Digester();
           configDigester.setNamespaceAware(true);
  -        configDigester.setValidating(validating);
  +        configDigester.setValidating(this.isValidating());
           configDigester.setUseContextClassLoader(true);
           configDigester.addRuleSet(new ConfigRuleSet());
  +        
           for (int i = 0; i < registrations.length; i += 2) {
               URL url = this.getClass().getResource(registrations[i+1]);
               if (url != null) {
  @@ -966,11 +956,25 @@
               }
           }
   
  -        // Add any custom RuleSet instances that have been specified
  +        this.addRuleSets();
  +
  +        // Return the completely configured Digester instance
  +        return (configDigester);
  +    }
  +
  +
  +    /**
  +     * Add any custom RuleSet instances to configDigester that have 
  +     * been specified in the <code>rulesets</code> init. parameter.
  +     * @throws ServletException
  +     */
  +    private void addRuleSets() throws ServletException {
  +        
           String rulesets = getServletConfig().getInitParameter("rulesets");
           if (rulesets == null) {
               rulesets = "";
           }
  +        
           rulesets = rulesets.trim();
           String ruleset = null;
           while (rulesets.length() > 0) {
  @@ -982,20 +986,39 @@
                   ruleset = rulesets.substring(0, comma).trim();
                   rulesets = rulesets.substring(comma + 1).trim();
               }
  +            
               if (log.isDebugEnabled()) {
                   log.debug("Configuring custom Digester Ruleset of type " + ruleset);
               }
  +            
               try {
                   RuleSet instance = (RuleSet) RequestUtils.applicationInstance(ruleset);
  -                configDigester.addRuleSet(instance);
  +                this.configDigester.addRuleSet(instance);
               } catch (Exception e) {
                   log.error("Exception configuring custom Digester RuleSet", e);
                   throw new ServletException(e);
               }
           }
  +    }
   
  -        // Return the completely configured Digester instance
  -        return (configDigester);
  +    /**
  +     * Check the status of the <code>validating</code> initialization parameter.

  +     * @return true if the module Digester should validate.
  +     */
  +    private boolean isValidating() {
  +        
  +        boolean validating = true;
  +        String value = getServletConfig().getInitParameter("validating");
  +        
  +        if ("false".equalsIgnoreCase(value)
  +            || "no".equalsIgnoreCase(value)
  +            || "n".equalsIgnoreCase(value)
  +            || "0".equalsIgnoreCase(value)) {
  +        
  +            validating = false;
  +        }
  +        
  +        return validating;
       }
   
       /**
  
  
  

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


Mime
View raw message