tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r894393 - in /tomcat/trunk/java/org/apache/catalina: Wrapper.java core/StandardWrapper.java deploy/ServletDef.java startup/WebRuleSet.java startup/WebXml.java
Date Tue, 29 Dec 2009 14:13:25 GMT
Author: markt
Date: Tue Dec 29 14:13:24 2009
New Revision: 894393

URL: http://svn.apache.org/viewvc?rev=894393&view=rev
Log:
Add support for the enabled attribute for servlets in web.xml

Modified:
    tomcat/trunk/java/org/apache/catalina/Wrapper.java
    tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
    tomcat/trunk/java/org/apache/catalina/deploy/ServletDef.java
    tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java
    tomcat/trunk/java/org/apache/catalina/startup/WebXml.java

Modified: tomcat/trunk/java/org/apache/catalina/Wrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Wrapper.java?rev=894393&r1=894392&r2=894393&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Wrapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Wrapper.java Tue Dec 29 14:13:24 2009
@@ -360,4 +360,15 @@
      * Set the async support for the associated servlet.
      */
     public void setAsyncSupported(boolean asyncSupport);
+    
+    /**
+     * Is the associated Servlet enabled? Defaults to <code>true</code>.
+     */
+    public boolean isEnabled();
+    
+    /**
+     * Sets the enabled attribute for the associated servlet.
+     */
+    public void setEnabled(boolean enabled);
+
 }

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java?rev=894393&r1=894392&r2=894393&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java Tue Dec 29 14:13:24 2009
@@ -267,6 +267,11 @@
     protected boolean asyncSupported = true;
 
     /**
+     * Enabled
+     */
+    protected boolean enabled = true;
+
+    /**
      * Static class array used when the SecurityManager is turned on and 
      * <code>Servlet.init</code> is invoked.
      */
@@ -586,13 +591,15 @@
      */
     public boolean isUnavailable() {
 
-        if (available == 0L)
-            return (false);
+        if (!isEnabled())
+            return true;
+        else if (available == 0L)
+            return false;
         else if (available <= System.currentTimeMillis()) {
             available = 0L;
-            return (false);
+            return false;
         } else
-            return (true);
+            return true;
 
     }
 
@@ -1516,6 +1523,14 @@
         this.asyncSupported = asyncSupported;
     }
 
+    public boolean isEnabled() {
+        return enabled;
+    }
+    
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+
     // -------------------------------------------------------- Package Methods
 
 

Modified: tomcat/trunk/java/org/apache/catalina/deploy/ServletDef.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/ServletDef.java?rev=894393&r1=894392&r2=894393&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/deploy/ServletDef.java (original)
+++ tomcat/trunk/java/org/apache/catalina/deploy/ServletDef.java Tue Dec 29 14:13:24 2009
@@ -234,4 +234,18 @@
     public void setAsyncSupported(String asyncSupported) {
         this.asyncSupported = Boolean.valueOf(asyncSupported);
     }
+
+    
+    /**
+     * Is this servlet enabled.
+     */
+    private Boolean enabled = null;
+    
+    public Boolean getEnabled() {
+        return this.enabled;
+    }
+    
+    public void setEnabled(String enabled) {
+        this.enabled = Boolean.valueOf(enabled);
+    }
 }

Modified: tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java?rev=894393&r1=894392&r2=894393&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java Tue Dec 29 14:13:24 2009
@@ -390,7 +390,9 @@
                                "setFileSizeThreshold", 0);
 
         digester.addCallMethod(fullPrefix + "/servlet/async-supported",
-                "setAsyncSupported", 0);
+                               "setAsyncSupported", 0);
+        digester.addCallMethod(fullPrefix + "/servlet/enabled",
+                               "setEnabled", 0);
 
         
         digester.addRule(fullPrefix + "/servlet-mapping",

Modified: tomcat/trunk/java/org/apache/catalina/startup/WebXml.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebXml.java?rev=894393&r1=894392&r2=894393&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/WebXml.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/WebXml.java Tue Dec 29 14:13:24 2009
@@ -583,7 +583,7 @@
             }
             appendElement(sb, INDENT4, "load-on-startup",
                     servletDef.getLoadOnStartup());
-            // TODO enabled
+            appendElement(sb, INDENT4, "enabled", servletDef.getEnabled());
             appendElement(sb, INDENT4, "async-supported",
                     servletDef.getAsyncSupported());
             sb.append("    <run-as>\n");
@@ -1108,6 +1108,9 @@
             if (servlet.getLoadOnStartup() != null) {
                 wrapper.setLoadOnStartup(servlet.getLoadOnStartup().intValue());
             }
+            if (servlet.getEnabled() != null) {
+                wrapper.setEnabled(servlet.getEnabled().booleanValue());
+            }
             wrapper.setName(servlet.getServletName());
             Map<String,String> params = servlet.getParameterMap(); 
             for (String param : params.keySet()) {
@@ -1604,6 +1607,15 @@
             }
         }
         
+        if (dest.getEnabled() == null) {
+            dest.setEnabled(src.getEnabled().toString());
+        } else if (src.getEnabled() != null) {
+            if (failOnConflict &&
+                    !src.getEnabled().equals(dest.getEnabled())) {
+                return false;
+            }
+        }
+        
         for (Map.Entry<String,String> srcEntry :
                 src.getParameterMap().entrySet()) {
             if (dest.getParameterMap().containsKey(srcEntry.getKey())) {



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


Mime
View raw message