You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ro...@apache.org on 2006/04/11 18:47:25 UTC

svn commit: r393258 - in /jakarta/httpcomponents/httpasync/trunk/src: examples/org/apache/http/examples/NotifiedAsyncGet.java java/org/apache/http/async/HttpNotificationHandler.java java/org/apache/http/async/impl/NotificationResponseWrapper.java

Author: rolandw
Date: Tue Apr 11 09:47:22 2006
New Revision: 393258

URL: http://svn.apache.org/viewcvs?rev=393258&view=rev
Log:
bug 38943, take 3 missing pieces

Added:
    jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java   (with props)
    jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpNotificationHandler.java   (with props)
    jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/NotificationResponseWrapper.java   (with props)

Added: jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java?rev=393258&view=auto
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java (added)
+++ jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java Tue Apr 11 09:47:22 2006
@@ -0,0 +1,429 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.examples;
+
+
+import java.util.LinkedList;
+
+import org.apache.http.HttpClientConnection;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
+import org.apache.http.Scheme;
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpClientConnection;
+import org.apache.http.impl.DefaultHttpParams;
+import org.apache.http.impl.io.PlainSocketFactory;
+import org.apache.http.io.SocketFactory;
+import org.apache.http.message.HttpGet;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.async.HttpDispatcher;
+import org.apache.http.async.HttpHandle;
+import org.apache.http.async.HttpNotificationHandler;
+import org.apache.http.async.AsyncHttpProcessor;
+import org.apache.http.async.impl.SimpleHttpDispatcher;
+import org.apache.http.protocol.RequestConnControl;
+import org.apache.http.protocol.RequestContent;
+import org.apache.http.protocol.RequestTargetHost;
+import org.apache.http.protocol.RequestUserAgent;
+import org.apache.http.util.EntityUtils;
+
+
+
+/**
+ * Example for using asynchronous {@link HttpNotificationHandler notification}.
+ *
+ * @author <a href="mailto:http-async at dubioso.net">Roland Weber</a>
+ *
+ *
+ * <!-- empty lines above to avoid 'svn diff' context problems -->
+ * @version $Revision$ $Date$
+ * 
+ * @since 4.0
+ */
+public class NotifiedAsyncGet {
+
+    /** The name of a context attribute for passing a throwable. */
+    public final static String PROBLEM_ATTRIBUTE = "problem";
+
+
+    /** The dispatcher. */
+    private HttpDispatcher http_dispatcher;
+
+    /** The notification handler. */
+    private NotifHandlerImpl notification_handler;
+
+    /** The counter for processed handles. */
+    private int processed_counter;
+
+    /** The queue for passing handles. */
+    private final LinkedList handle_queue;
+
+    /**
+     * The internal monitor object.
+     * Used for synchronizing access to the {@link #handle_queue handle_queue}.
+     */
+    private final Object handle_queue_monitor =
+        new String(getClass()+".handle_queue_monitor");
+
+
+    /**
+     * Main entry point to this example.
+     *
+     * @param args        command line arguments
+     *
+     * @throws Exception        in case of a problem
+     */
+    public static void main(String[] args) throws Exception {
+
+        SocketFactory socketfactory = PlainSocketFactory.getSocketFactory();
+        Scheme.registerScheme("http", new Scheme("http", socketfactory, 80));
+
+        String[] targets = args;
+        if ((targets == null) || (targets.length < 1)) {
+            targets = new String[] {
+                "/",
+                "/servlets-examples/servlet/RequestInfoExample", 
+                "/somewhere%20in%20pampa"
+            };
+        }
+
+        NotifiedAsyncGet example = new NotifiedAsyncGet();
+
+        example.prepareExample();
+        example.executeExample(targets);
+        example.cleanupExample();
+
+    } // main
+
+
+    /**
+     * Default constructor for this example.
+     */
+    private NotifiedAsyncGet() {
+
+        handle_queue = new LinkedList();
+        processed_counter = 0;
+
+    } // constructor
+
+
+    /**
+     * Prepare this example.
+     *
+     * @throws Exception        in case of a problem
+     */
+    private void prepareExample()
+        throws Exception {
+
+        http_dispatcher = createDispatcher();
+        System.out.println("dispatcher " + http_dispatcher + "\n");
+
+        notification_handler = new NotifHandlerImpl();
+        System.out.println("notification handler " + notification_handler);
+        http_dispatcher.getDefaultContext().setAttribute
+            (HttpNotificationHandler.CTXT_NOTIFICATION_HANDLER,
+             notification_handler);
+
+    } // prepareExample
+
+
+    /**
+     * Execute a series of requests.
+     *
+     * @param targets   the URIs to request
+     *
+     * @throws Exception        in case of a problem
+     */
+    private void executeExample(String[] targets)
+        throws Exception {
+
+        if ((targets == null) || (targets.length < 1))
+            throw new IllegalArgumentException
+                ("targets must not be null nor empty");
+
+        HttpHost     host    = new HttpHost("localhost", 8080);
+        HttpHandle[] handles = new HttpHandle[targets.length];
+
+        for (int i = 0; i < targets.length; i++) {
+
+            HttpGet request = new HttpGet(targets[i]);
+            System.out.println(">> Request URI: " +
+                               request.getRequestLine().getUri());
+            handles[i] = http_dispatcher.sendRequest(request, host, null);
+            System.out.println(">> Handle: " + handles[i]);
+            System.out.println("==============");
+
+        } // for targets
+
+        // In this example, the array of handles is not needed at all since
+        // we'll get notifications for each handle. In a real application,
+        // you might want to track the handles. There probably is some
+        // application context for each request which needs tracking anyway.
+
+        // now pick up handles as the notifications come in
+
+        while (processed_counter < targets.length) {
+
+            HttpHandle handle = null;
+
+            synchronized (handle_queue_monitor) {
+
+                try {
+                    handle_queue_monitor.wait();
+                } catch (InterruptedException ix) {
+                    // ignore, we'll just repeat the loop if necessary
+                }
+
+                if (!handle_queue.isEmpty())
+                    handle = (HttpHandle) handle_queue.removeFirst();
+
+            } // synchronized
+
+            // If we got a handle, process it. Then check for more handles.
+            // Note that processing is *not* part of the synchronized block!
+            while (handle != null) {
+
+                processHandle(handle);
+                processed_counter++;
+                handle = null;
+
+                synchronized (handle_queue_monitor) {
+                    if (!handle_queue.isEmpty())
+                        handle = (HttpHandle) handle_queue.removeFirst();
+                }
+            } // while handle
+
+            System.out.println("== main thread: counter is " +
+                               processed_counter);
+
+        } // while processed counter
+
+        System.out.println("\ndispatcher " + http_dispatcher + "\n");
+
+    } // executeExample
+
+
+    /**
+     * Clean up this example.
+     *
+     * @throws Exception        in case of a problem
+     */
+    private void cleanupExample()
+        throws Exception {
+
+        // currently no cleanup necessary
+
+    } // cleanupExample
+
+
+    /**
+     * Instantiate a dispatcher.
+     *
+     * @return    the dispatcher
+     */
+    private final static HttpDispatcher createDispatcher() {
+
+        HttpParams params = new DefaultHttpParams(null);
+        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+        HttpProtocolParams.setContentCharset(params, "UTF-8");
+        HttpProtocolParams.setUserAgent(params, "Jakarta-HttpComponents/1.1");
+        HttpProtocolParams.setUseExpectContinue(params, false);
+
+        HttpClientConnection conn = new DefaultHttpClientConnection();
+
+        AsyncHttpProcessor proc = new AsyncHttpProcessor();
+        proc.setParams(params);
+        // Required request interceptors
+        proc.addInterceptor(new RequestContent());
+        proc.addInterceptor(new RequestTargetHost());
+        // Recommended request interceptors
+        proc.addInterceptor(new RequestConnControl());
+        proc.addInterceptor(new RequestUserAgent());
+        // not supported: proc.addInterceptor(new RequestExpectContinue());
+
+        ConnectionReuseStrategy crs = new DefaultConnectionReuseStrategy();
+
+        HttpDispatcher hdp = new SimpleHttpDispatcher(conn, proc, crs);
+
+        return hdp;
+
+    } // createDispatcher
+
+
+    /**
+     * Called by the main application thread, once for each notification.
+     * The notification handler passes the handles to the main application
+     * thread, which then calls this method.
+     *
+     * @param handle    the handle
+     *
+     * @throws Exception  in case of a problem
+     */
+    private void processHandle(HttpHandle handle)
+        throws Exception {
+
+        // check for an error first
+        try {
+            handle.checkError();
+        } catch (Exception x) {
+            System.out.print("!! Problem: ");
+            x.printStackTrace(System.out);
+            return; // no need to close the handle
+        }
+
+        // we know there is no error, so the response can not be null
+        HttpResponse response = handle.getResponse();
+
+        System.out.println
+            ("<< Response: " + response.getStatusLine());
+        System.out.println
+            (EntityUtils.toString(response.getEntity()));
+        /*
+        byte[] data = new byte[100];
+        int count = response.getEntity().getContent().read(data);
+        String s = new String(data, 0, count, "ISO-8859-1");
+        System.out.println(s);
+        */
+
+        // don't forget this, or the connection remains locked!
+        handle.close();
+
+    } // processHandle
+
+
+
+    /**
+     * The notification handler.
+     * This class is public only to give you easier access to the JavaDoc.
+     */
+    public final class NotifHandlerImpl
+        implements HttpNotificationHandler {
+
+        // default constructor
+
+
+        /**
+         * Queues a handle for the main application thread.
+         *
+         * @param handle    the handle to process in the application thread
+         *
+         */
+        private final void queueHandle(HttpHandle handle) {
+
+            if (handle == null)
+                throw new IllegalArgumentException("handle must not be null");
+
+            synchronized (handle_queue_monitor) {
+                handle_queue.add(handle);
+                handle_queue_monitor.notifyAll();
+            }
+
+        } // queueHandle
+
+
+        /**
+         * Called when a response is available.
+         * Accessing the response entity is a big no-no during notification.
+         * We must not call:
+         * <ul>
+         * <li>{@link HttpHandle#getResponse handle.getResponse}
+         *      </li>
+         * <li>{@link HttpHandle#awaitResponse handle.awaitResponse}
+         *      </li>
+         * <li>{@link HttpResponse#getEntity response.getEntity}
+         *      </li>
+         * <li>{@link HttpResponse#setEntity response.setEntity}
+         *      </li>
+         * <li>{@link HttpHandle#checkError handle.checkError}
+         *      (should not)</li>
+         * </ul>
+         * Of course we're not supposed to modify the <code>response</code>
+         * at all, though that is not a strict requirement. But if we have
+         * to pass additional information to the application thread, we can
+         * simply put it in the {@link HttpHandle#getContext context}.
+         *
+         * @param handle        the handle for which the response is available.
+         * @param nqrsp         (not quite) the available response
+         */
+        public void notifyResponse(HttpHandle handle, HttpResponse nqrsp) {
+
+            System.out.println("== handler: notification for " + handle);
+
+            // we could check for example the response status code to
+            // select between multiple routing targets for responses
+
+            queueHandle(handle);
+
+        } // notifyResponse
+
+
+        /**
+         * Called when a problem is detected.
+         * We must not call:
+         * <ul>
+         * <li>{@link HttpHandle#getResponse handle.getResponse}
+         *      </li>
+         * <li>{@link HttpHandle#awaitResponse handle.awaitResponse}
+         *      </li>
+         * </ul>
+         * We should not call {@link HttpHandle#checkError handle.checkError}.
+         * The exception we could get from there is already passed as argument.
+         *
+         * @param handle    the handle for which a problem has occurred
+         * @param problem   the exception or throwable indicating the problem,
+         *                  never <code>null</code>
+         * @param nonfatal  <code>true</code> if the problem is non-fatal, or
+         *                  <code>false</code> if request processing must be
+         *                  aborted due to the problem
+         *
+         * @return Will be ignored for fatal problems.
+         *      In case of a non-fatal problem,
+         *      <code>true</code> if processing should resume or
+         *      <code>false</code> if processing should be aborted.
+         */
+        public boolean notifyProblem(HttpHandle handle, Throwable problem,
+                                     boolean nonfatal) {
+
+            System.out.println("== handler: problem notification for " +
+                               handle);
+
+            queueHandle(handle);
+
+            return false;
+
+        } // notifyProblem
+
+    } // class NotifHandlerImpl
+
+
+} // class NotifiedAsyncGet

Propchange: jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpasync/trunk/src/examples/org/apache/http/examples/NotifiedAsyncGet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpNotificationHandler.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpNotificationHandler.java?rev=393258&view=auto
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpNotificationHandler.java (added)
+++ jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpNotificationHandler.java Tue Apr 11 09:47:22 2006
@@ -0,0 +1,160 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.async;
+
+
+import org.apache.http.HttpResponse;
+import org.apache.http.protocol.HttpContext;
+
+
+
+/**
+ * Callback interface for notifications about asynchronous requests.
+ * Callback methods are typically called by background threads of a
+ * {@link HttpDispatcher dispatcher}. To ensure correct operation of
+ * those background threads, notification handler implementations
+ * MUST conform to the following restrictions when processing
+ * notification callbacks:
+ * <ol>
+ * <li>Notifications MUST be processed quickly.
+ *     <br/>
+ *     A handler method is not allow to perform expensive computations
+ *     or long-lasting I/O operations. Most definitely, it is not allowed
+ *     to perform user interaction, like popping up dialogs for accepting
+ *     cookies or entering passwords.
+ *     </li>
+ * <li>A handler method MUST NOT access the response entity.
+ *     <br/>
+ *     This is to ensure that the notification is processed quickly.
+ *     </li>
+ * <li>A handler method MUST NOT close the handle.
+ *     <br/>
+ *     Closing a handle implies skipping (and therefore accessing)
+ *     the response entity in order to re-use the connection.
+ *     </li>
+ * </ol>
+ * Typically, a notification handler implementation will only pass the
+ * handles to an application thread by some application specific means,
+ * for example queues. The application thread then has full access to
+ * the response and entity.
+ * In order to simplify the application design, a notification handler
+ * can perform simple routing operations. The routing decision can be
+ * based on data in the {@link HttpHandle#getContext context}, on the
+ * status code, and on the headers of the response.
+ * For example, handles for which a {@link #notifyProblem problem} is
+ * indicated can be routed to a different queue than handles for which a
+ * {@link #notifyResponse response} with an error status code is received,
+ * while handles for responses with non-error status codes are routed
+ * to a third queue.
+ *
+ * @author <a href="mailto:http-async at dubioso.net">Roland Weber</a>
+ *
+ *
+ * <!-- empty lines above to avoid 'svn diff' context problems -->
+ * @version $Revision$ $Date$
+ * 
+ * @since 4.0
+ */
+public interface HttpNotificationHandler {
+
+    /**
+     * The context attribute name for a notification handler.
+     * Store your handler instance in the {@link HttpContext HttpContext}
+     * for the {@link HttpHandle#getContext request} or the
+     * {@link HttpDispatcher#getDefaultContext default} context
+     * for the dispatcher.
+     */
+    public final static String CTXT_NOTIFICATION_HANDLER =
+        HttpContext.RESERVED_PREFIX + "notification.handler";
+
+
+    /**
+     * Notification that a response is available.
+     * <br/>
+     * The response object passed as argument is not necessarily the
+     * same object that will be returned by
+     * {@link HttpHandle#getResponse handle.getResponse()}.
+     * The notification handler is <i>not</i> allowed to call that
+     * method, it must use the passed response object. The notification
+     * handler is <i>not</i> allowed to access the response entity.
+     * The passed response object is valid only during the notification,
+     * it MUST NOT be passed to a different thread or stored for later
+     * access.
+     *
+     * @param handle    the handle for which a response is now available
+     * @param nqrsp     not quite the response that the application will get.
+     *                  Application threads are allowed to call
+     *                  {@link HttpHandle#getResponse handle.getResponse()},
+     *                  which returns a postprocessed response.
+     *                  A notification handler is not allowed to call that
+     *                  method and has to use this argument instead. It may
+     *                  or may not be postprocessed. It does not give access
+     *                  to the response entity, if there is one. It does give
+     *                  access to the status line and headers.
+     */
+    public void notifyResponse(HttpHandle handle, HttpResponse nqrsp)
+        // no exceptions allowed
+        ;
+
+
+    /**                               
+     * Notification that a problem has occurred.
+     * Some problems are non-fatal, for example because the request can
+     * be retried. The <code>nonfatal</code> argument indicates this case
+     * to the handler method, and the return value instructs the dispatcher
+     * whether to continue request processing or whether to abort. If the
+     * problem is fatal, request processing is always aborted.
+     *
+     * @param handle    the handle for which a problem has occurred
+     * @param problem   the exception or throwable indicating the problem,
+     *                  never <code>null</code>
+     * @param nonfatal  <code>true</code> to indicate that request processing
+     *                  <i>can</i> proceed if requested, or
+     *                  <code>false</code> if request processing needs to be
+     *                  aborted due to the problem
+     *
+     * @return  <code>true</code> to indicate that request processing should
+     *          proceed in spite of the problem, or <code>false</code> if
+     *          request processing should be aborted.
+     *          The returned value will be ignored if the <code>nonfatal</code>
+     *          argument is false.
+     *          If the request processing proceeds, there will be another
+     *          notification for the same handle, either when a
+     *          {@link #notifyResponse response} is available or
+     *          when another problem is encountered. Otherwise, the handle
+     *          is closed and there will be no further notification.
+     */
+    public boolean notifyProblem(HttpHandle handle, Throwable problem,
+                                 boolean nonfatal)
+        // no exceptions allowed
+        ;
+
+
+} // interface HttpNotificationHandler

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpNotificationHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpNotificationHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/HttpNotificationHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/NotificationResponseWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/NotificationResponseWrapper.java?rev=393258&view=auto
==============================================================================
--- jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/NotificationResponseWrapper.java (added)
+++ jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/NotificationResponseWrapper.java Tue Apr 11 09:47:22 2006
@@ -0,0 +1,198 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.async.impl;
+
+
+import java.util.Iterator;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
+import org.apache.http.StatusLine;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.params.HttpParams;
+
+
+
+/**
+ * Response object wrapper for notification.
+ * A notification handler is not allowed to access the response entity,
+ * and this wrapper will not allow it to.
+ *
+ *
+ * @author <a href="mailto:http-async at dubioso.net">Roland Weber</a>
+ *
+ *
+ * <!-- empty lines above to avoid 'svn diff' context problems -->
+ * @version $Revision$ $Date$
+ * 
+ * @since 4.0
+ */
+public final class NotificationResponseWrapper
+    implements HttpResponse {
+
+
+    /** The response being wrapped. */
+    private final HttpResponse wrapped_response;
+
+
+    /**
+     * Creates a new response wrapper for notification.
+     *
+     * @param response  the response to wrap
+     */
+    public NotificationResponseWrapper(HttpResponse response) {
+
+        if (response == null)
+            throw new IllegalArgumentException("response must not be null");
+
+        wrapped_response = response;
+
+    } // constructor
+
+
+
+    /**
+     * Disabled operation.
+     * This method is disabled since notification handlers
+     * are not allowed to call it.
+     *
+     * @return  never
+     *
+     * @throws IllegalStateException    always
+     */
+    public HttpEntity getEntity()
+        throws IllegalStateException {
+
+        throw new IllegalStateException("notification thread abuse");
+    }
+
+
+    /**
+     * Disabled operation.
+     * This method is disabled since notification handlers
+     * are not allowed to call it.
+     *
+     * @return  never
+     *
+     * @throws IllegalStateException    always
+     */
+    public void setEntity(HttpEntity entity)
+        throws IllegalStateException {
+
+        throw new IllegalStateException("notification thread abuse");
+    }
+
+
+    // non-javadoc, see interface HttpResponse
+    public StatusLine getStatusLine() {
+        return wrapped_response.getStatusLine();
+    }
+
+    // non-javadoc, see interface HttpResponse
+    public void setStatusLine(StatusLine statusline) {
+        wrapped_response.setStatusLine(statusline);
+    }
+
+    // non-javadoc, see interface HttpResponse
+    public void setStatusCode(int code) {
+        wrapped_response.setStatusCode(code);
+    }
+
+
+
+    // non-javadoc, see interface HttpMessage
+    public HttpVersion getHttpVersion() {
+        return wrapped_response.getHttpVersion();
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public boolean containsHeader(String name) {
+        return wrapped_response.containsHeader(name);
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public Header[] getHeaders(String name) {
+        return wrapped_response.getHeaders(name);
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public Header getFirstHeader(String name) {
+        return wrapped_response.getFirstHeader(name);
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public Header getLastHeader(String name) {
+        return wrapped_response.getLastHeader(name);
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public Header[] getAllHeaders() {
+        return wrapped_response.getAllHeaders();
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public void addHeader(Header header) {
+        wrapped_response.addHeader(header);
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public void setHeader(Header header) {
+        wrapped_response.setHeader(header);
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public void removeHeader(Header header) {
+        wrapped_response.removeHeader(header);
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public void removeHeaders(String name) {
+        wrapped_response.removeHeaders(name);
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public Iterator headerIterator() {
+        return wrapped_response.headerIterator();
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public HttpParams getParams() {
+        return wrapped_response.getParams();
+    }
+
+    // non-javadoc, see interface HttpMessage
+    public void setParams(HttpParams params) {
+        wrapped_response.setParams(params);
+    }
+
+
+} // class NotificationResponseWrapper
+

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/NotificationResponseWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/NotificationResponseWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpasync/trunk/src/java/org/apache/http/async/impl/NotificationResponseWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain