[utilities COMMIT] in /java-support/trunk/src: main/java/net/shibboleth/utilities/java/support/net/HttpServletRequest...

noreply at shibboleth.net noreply at shibboleth.net
Fri Apr 26 17:58:04 EDT 2013


Author: putmanb
Date: Fri Apr 26 17:58:04 2013
New Revision: 389

URL: http://svn.shibboleth.net/view/utilities?rev=389&view=rev
Log:
Some Checkstyle fixes and unit tests.

Added:
    java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/net/HttpServletRequestResponseContextTest.java   (with props)
    java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/net/RequestResponseContextFilterTest.java   (with props)
    java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/net/ThreadLocalHttpServletRequestProxyTest.java   (with props)
    java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/net/ThreadLocalHttpServletResponseProxyTest.java   (with props)
Modified:
    java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/net/HttpServletRequestResponseContext.java
    java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/net/RequestResponseContextFilter.java

Modified: java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/net/HttpServletRequestResponseContext.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/net/HttpServletRequestResponseContext.java?rev=389&r1=388&r2=389&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/net/HttpServletRequestResponseContext.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/net/HttpServletRequestResponseContext.java Fri Apr 26 17:58:04 2013
@@ -1,4 +1,22 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development, 
+ * Inc. (UCAID) under one or more contributor license agreements.  See the 
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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 net.shibboleth.utilities.java.support.net;
+
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.servlet.Filter;
@@ -7,64 +25,65 @@
 
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
-
 /**
  * Class which holds and makes available the current HTTP servlet request and response via ThreadLocal storage.
  * 
  * <p>
- * See also {@link RequestResponseContextFilter}, which is a Java Servlet {@link Filter}-based way to populate
- * and clean up this context in a servlet container.
+ * See also {@link RequestResponseContextFilter}, which is a Java Servlet {@link Filter}-based way to populate and clean
+ * up this context in a servlet container.
  * </p>
  */
 public final class HttpServletRequestResponseContext {
-	
-	/** ThreadLocal storage for request. */
-	private static ThreadLocal<HttpServletRequest> currentRequest = new ThreadLocal<HttpServletRequest>();
-	
-	/** ThreadLocal storage for response. */
-	private static ThreadLocal<HttpServletResponse> currentResponse = new ThreadLocal<HttpServletResponse>();
 
-	/** Constructor. */
-	private HttpServletRequestResponseContext() {};
+    /** ThreadLocal storage for request. */
+    private static ThreadLocal<HttpServletRequest> currentRequest = new ThreadLocal<HttpServletRequest>();
 
-	/**
-	 * Load the thread-local storage with the current request and response.
-	 * 
-	 * @param request the current {@link HttpServletRequest}
-	 * @param response the current {@link HttpServletResponse}
-	 */
-	public static void loadCurrent(@Nonnull final HttpServletRequest request, @Nonnull final HttpServletResponse response) {
-	    Constraint.isNotNull(request, "HttpServletRequest may not be null");
-	    Constraint.isNotNull(response, "HttpServletResponse may not be null");
-	    
-		currentRequest.set(request);
-		currentResponse.set(response);
-	}
+    /** ThreadLocal storage for response. */
+    private static ThreadLocal<HttpServletResponse> currentResponse = new ThreadLocal<HttpServletResponse>();
 
-	/**
-	 *  Clear the current thread-local context instances.
-	 */
-	public static void clearCurrent() {
-		currentRequest.remove();
-		currentResponse.remove();
-	}
+    /** Constructor. */
+    private HttpServletRequestResponseContext() {
+    };
 
-	/**
-	 * Get the current {@link HttpServletRequest} being serviced by the current thread.
-	 * 
-	 * @return the current request 
-	 */
-	@Nullable public static HttpServletRequest getRequest() {
-		return currentRequest.get();
-	}
+    /**
+     * Load the thread-local storage with the current request and response.

[... 148 lines stripped ...]


More information about the commits mailing list