Author: markt
Date: Thu Apr 24 15:06:32 2014
New Revision: 1589763

URL: http://svn.apache.org/r1589763
Log:
Refactoring to reduce code duplication.

Added:
    tomcat/trunk/java/org/apache/tomcat/util/security/
    tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedGetTccl.java   
(with props)
    tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedSetTccl.java   
(with props)
Modified:
    tomcat/trunk/build.xml
    tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java
    tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java
    tomcat/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java

Modified: tomcat/trunk/build.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/build.xml?rev=1589763&r1=1589762&r2=1589763&view=diff
==============================================================================
--- tomcat/trunk/build.xml (original)
+++ tomcat/trunk/build.xml Thu Apr 24 15:06:32 2014
@@ -347,6 +347,7 @@
     <include name="org/apache/tomcat/util/codec/**" />
     <include name="org/apache/tomcat/util/file/**" />
     <include name="org/apache/tomcat/util/res/**" />
+    <include name="org/apache/tomcat/util/security/**" />
     <include name="org/apache/tomcat/util/threads/**" />
     <include name="org/apache/tomcat/util/*" />
     <exclude name="org/apache/tomcat/util/bcel" />
@@ -1966,6 +1967,7 @@ Apache Tomcat ${version} native binaries
           <exclude name="org/apache/tomcat/util/net" />
           <exclude name="org/apache/tomcat/util/res" />
           <exclude name="org/apache/tomcat/util/scan" />
+          <exclude name="org/apache/tomcat/util/security" />
           <exclude name="org/apache/tomcat/util/threads" />
           <exclude name="**/package.html" />
           <exclude name="**/LocalStrings_*" />

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1589763&r1=1589762&r2=1589763&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Thu Apr 24 
15:06:32 2014
@@ -129,6 +129,8 @@ import org.apache.tomcat.util.descriptor
 import org.apache.tomcat.util.descriptor.web.SecurityCollection;
 import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
 import org.apache.tomcat.util.scan.StandardJarScanner;
+import org.apache.tomcat.util.security.PrivilegedGetTccl;
+import org.apache.tomcat.util.security.PrivilegedSetTccl;
 
 /**
  * Standard implementation of the <b>Context</b> interface.  Each
@@ -5811,30 +5813,6 @@ public class StandardContext extends Con
     }
 
 
-    private static class PrivilegedSetTccl implements PrivilegedAction<Void> {
-
-        private ClassLoader cl;
-
-        PrivilegedSetTccl(ClassLoader cl) {
-            this.cl = cl;
-        }
-
-        @Override
-        public Void run() {
-            Thread.currentThread().setContextClassLoader(cl);
-            return null;
-        }
-    }
-
-
-    private static class PrivilegedGetTccl implements 
PrivilegedAction<ClassLoader> {
-        @Override
-        public ClassLoader run() {
-            return Thread.currentThread().getContextClassLoader();
-        }
-    }
-
-
     /**
      * Get naming context full name.
      */

Modified: tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java?rev=1589763&r1=1589762&r2=1589763&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java Thu 
Apr 24 15:06:32 2014
@@ -101,12 +101,6 @@ public final class SecurityClassLoad {
         loader.loadClass
             (basePackage +
              "ApplicationHttpRequest$AttributeNamesEnumerator");
-        loader.loadClass
-            (basePackage +
-             "StandardContext$PrivilegedGetTccl");
-        loader.loadClass
-            (basePackage +
-             "StandardContext$PrivilegedSetTccl");
     }
 
 
@@ -293,9 +287,9 @@ public final class SecurityClassLoad {
         loader.loadClass(basePackage +
                 "util.net.NioBlockingSelector$BlockPoller$3");
         loader.loadClass(basePackage + "util.net.SSLSupport$CipherData");
-        // threads
-        loader.loadClass
-            (basePackage + "util.threads.TaskThreadFactory$PrivilegedSetTccl");
+        // security
+        loader.loadClass(basePackage + "util.security.PrivilegedGetTccl");
+        loader.loadClass(basePackage + "util.security.PrivilegedSetTccl");
     }
 }
 

Modified: tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java?rev=1589763&r1=1589762&r2=1589763&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AsyncStateMachine.java Thu Apr 24 
15:06:32 2014
@@ -21,6 +21,8 @@ import java.security.PrivilegedAction;
 
 import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
 import org.apache.tomcat.util.res.StringManager;
+import org.apache.tomcat.util.security.PrivilegedGetTccl;
+import org.apache.tomcat.util.security.PrivilegedSetTccl;
 
 /**
  * Manages the state transitions for async requests.
@@ -362,29 +364,4 @@ public class AsyncStateMachine<S> {
         processor.getRequest().listener = null;
         processor.getRequest().getResponse().listener = null;
     }
-
-
-    private static class PrivilegedSetTccl implements PrivilegedAction<Void> {
-
-        private ClassLoader cl;
-
-        PrivilegedSetTccl(ClassLoader cl) {
-            this.cl = cl;
-        }
-
-        @Override
-        public Void run() {
-            Thread.currentThread().setContextClassLoader(cl);
-            return null;
-        }
-    }
-
-    private static class PrivilegedGetTccl
-            implements PrivilegedAction<ClassLoader> {
-
-        @Override
-        public ClassLoader run() {
-            return Thread.currentThread().getContextClassLoader();
-        }
-    }
 }

Added: tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedGetTccl.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedGetTccl.java?rev=1589763&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedGetTccl.java 
(added)
+++ tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedGetTccl.java 
Thu Apr 24 15:06:32 2014
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.security;
+
+import java.security.PrivilegedAction;
+
+public class PrivilegedGetTccl implements PrivilegedAction<ClassLoader> {
+    @Override
+    public ClassLoader run() {
+        return Thread.currentThread().getContextClassLoader();
+    }
+}
+
+

Propchange: 
tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedGetTccl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedSetTccl.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedSetTccl.java?rev=1589763&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedSetTccl.java 
(added)
+++ tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedSetTccl.java 
Thu Apr 24 15:06:32 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.security;
+
+import java.security.PrivilegedAction;
+
+public class PrivilegedSetTccl implements PrivilegedAction<Void> {
+
+    private ClassLoader cl;
+
+    public PrivilegedSetTccl(ClassLoader cl) {
+        this.cl = cl;
+    }
+
+    @Override
+    public Void run() {
+        Thread.currentThread().setContextClassLoader(cl);
+        return null;
+    }
+}
\ No newline at end of file

Propchange: 
tomcat/trunk/java/org/apache/tomcat/util/security/PrivilegedSetTccl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java?rev=1589763&r1=1589762&r2=1589763&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/threads/TaskThreadFactory.java Thu 
Apr 24 15:06:32 2014
@@ -22,6 +22,7 @@ import java.util.concurrent.ThreadFactor
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.tomcat.util.net.Constants;
+import org.apache.tomcat.util.security.PrivilegedSetTccl;
 /**
  * Simple task thread factory to use to create threads for an executor
  * implementation.
@@ -68,20 +69,4 @@ public class TaskThreadFactory implement
             }
         }
     }
-
-
-    private static class PrivilegedSetTccl implements PrivilegedAction<Void> {
-
-        private ClassLoader cl;
-
-        PrivilegedSetTccl(ClassLoader cl) {
-            this.cl = cl;
-        }
-
-        @Override
-        public Void run() {
-            Thread.currentThread().setContextClassLoader(cl);
-            return null;
-        }
-    }
 }



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

Reply via email to