hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1149330 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/nio/protocol/ httpcore/src/main/java/org/apache/http/protocol/ httpcore/src/test/java/org/apache/http/protocol/
Date Thu, 21 Jul 2011 19:27:47 GMT
Author: olegk
Date: Thu Jul 21 19:27:46 2011
New Revision: 1149330

URL: http://svn.apache.org/viewvc?rev=1149330&view=rev
Log:
HTTPCORE-265: Ability to get RequestHandlers
Contributed by William R. Speirs <bill.speirs at gmail.com>

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandlerRegistry.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandlerRegistry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandlerRegistry.java?rev=1149330&r1=1149329&r2=1149330&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandlerRegistry.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NHttpRequestHandlerRegistry.java
Thu Jul 21 19:27:46 2011
@@ -84,6 +84,16 @@ public class NHttpRequestHandlerRegistry
         matcher.setObjects(map);
     }
 
+    /**
+     * Get the handler map.
+     * @return The map of handlers and their associated URI patterns.
+     *
+     * @since 4.2
+     */
+    public Map<String, NHttpRequestHandler> getHandlers() {
+        return matcher.getObjects();
+    }
+
     public NHttpRequestHandler lookup(String requestURI) {
         return matcher.lookup(requestURI);
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java?rev=1149330&r1=1149329&r2=1149330&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpRequestHandlerRegistry.java
Thu Jul 21 19:27:46 2011
@@ -91,6 +91,16 @@ public class HttpRequestHandlerRegistry 
         matcher.setObjects(map);
     }
 
+    /**
+     * Get the handler map.
+     * @return The map of handlers and their associated URI patterns.
+     *
+     * @since 4.2
+     */
+    public Map<String, HttpRequestHandler> getHandlers() {
+        return matcher.getObjects();
+    }
+
     public HttpRequestHandler lookup(final String requestURI) {
         return matcher.lookup(requestURI);
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java?rev=1149330&r1=1149329&r2=1149330&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
Thu Jul 21 19:27:46 2011
@@ -110,6 +110,16 @@ public class UriPatternMatcher<T> {
     }
 
     /**
+     * Returns the objects map.
+     * @return The map of objects.
+     *
+     * @since 4.2
+     */
+    public synchronized Map<String, T> getObjects() {
+        return this.map;
+    }
+
+    /**
      * Looks up an object matching the given request URI.
      *
      * @param requestURI the request URI

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java?rev=1149330&r1=1149329&r2=1149330&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java
Thu Jul 21 19:27:46 2011
@@ -60,6 +60,9 @@ public class TestHttpRequestHandlerRegis
         registry.register("/h2", h2);
         registry.register("/h3", h3);
 
+        Map<String, HttpRequestHandler> handlers = registry.getHandlers();
+        Assert.assertEquals(3, handlers.size());
+
         HttpRequestHandler h;
 
         h = registry.lookup("/h1");
@@ -76,12 +79,18 @@ public class TestHttpRequestHandlerRegis
         h = registry.lookup("/h1");
         Assert.assertNull(h);
 
+        handlers = registry.getHandlers();
+        Assert.assertEquals(2, handlers.size());
+
         Map<String, HttpRequestHandler> map = new HashMap<String, HttpRequestHandler>();
         map.put("/a1", h1);
         map.put("/a2", h2);
         map.put("/a3", h3);
         registry.setHandlers(map);
 
+        handlers = registry.getHandlers();
+        Assert.assertEquals(3, handlers.size());
+
         h = registry.lookup("/h2");
         Assert.assertNull(h);
         h = registry.lookup("/h3");



Mime
View raw message