hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r515218 - /jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/
Date Tue, 06 Mar 2007 17:19:57 GMT
Author: olegk
Date: Tue Mar  6 09:19:56 2007
New Revision: 515218

URL: http://svn.apache.org/viewvc?view=rev&rev=515218
Log:
Added logging decorators for NHttpClientHandler, NHttpServiceHandler and IOSession

Added:
    jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/
    jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingClientIOEventDispatch.java
  (with props)
    jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingIOSession.java
  (with props)
    jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpClientHandler.java
  (with props)
    jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpServiceHandler.java
  (with props)
    jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingServerIOEventDispatch.java
  (with props)

Added: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingClientIOEventDispatch.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingClientIOEventDispatch.java?view=auto&rev=515218
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingClientIOEventDispatch.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingClientIOEventDispatch.java
Tue Mar  6 09:19:56 2007
@@ -0,0 +1,95 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * 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.contrib.logging;
+
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.nio.NHttpClientHandler;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.params.HttpParams;
+
+public class LoggingClientIOEventDispatch implements IOEventDispatch {
+
+    private static final String NHTTP_CONN = "NHTTP_CONN";
+    
+    private final NHttpClientHandler handler;
+    private final HttpParams params;
+    
+    public LoggingClientIOEventDispatch(final NHttpClientHandler handler, final HttpParams
params) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP client handler may not be null");
+        }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        this.handler = new LoggingNHttpClientHandler(handler);
+        this.params = params;
+    }
+    
+    public void connected(final IOSession session) {
+        DefaultNHttpClientConnection conn = new DefaultNHttpClientConnection(
+                new LoggingIOSession(session), 
+                new DefaultHttpResponseFactory(),
+                this.params); 
+        session.setAttribute(NHTTP_CONN, conn);
+        
+        Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
+        this.handler.connected(conn, attachment);
+    }
+
+    public void disconnected(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        this.handler.closed(conn);
+    }
+
+    public void inputReady(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        conn.consumeInput(this.handler);
+    }
+
+    public void outputReady(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        conn.produceOutput(this.handler);
+    }
+
+    public void timeout(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        this.handler.timeout(conn);
+    }
+
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingClientIOEventDispatch.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingClientIOEventDispatch.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingIOSession.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingIOSession.java?view=auto&rev=515218
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingIOSession.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingIOSession.java
Tue Mar  6 09:19:56 2007
@@ -0,0 +1,196 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * 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.contrib.logging;
+
+import java.io.IOException;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.ByteChannel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.nio.reactor.SessionBufferStatus;
+
+/**
+ * Decorator class intended to transparently extend an {@link IOSession} 
+ * with basic event logging capabilities using Commons Logging. 
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public class LoggingIOSession implements IOSession {
+
+    private static int COUNT = 0;
+    
+    private final Log log;
+    private final IOSession session;
+    private final ByteChannel channel;
+    private final int id;
+    
+    public LoggingIOSession(final IOSession session) {
+        super();
+        if (session == null) {
+            throw new IllegalArgumentException("I/O session may not be null");
+        }
+        this.session = session;
+        this.channel = new LoggingByteChannel();
+        this.id = ++COUNT;
+        this.log = LogFactory.getLog(session.getClass());
+    }
+
+    public ByteChannel channel() {
+        return this.channel;
+    }
+
+    public SocketAddress getLocalAddress() {
+        return this.session.getLocalAddress();
+    }
+
+    public SocketAddress getRemoteAddress() {
+        return this.session.getRemoteAddress();
+    }
+
+    public int getEventMask() {
+        return this.session.getEventMask();
+    }
+
+    public void setEventMask(int ops) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Set event mask
" 
+                    + ops);
+        }
+        this.session.setEventMask(ops);
+    }
+
+    public void setEvent(int op) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Set event "

+                    + op);
+        }
+        this.session.setEvent(op);
+    }
+
+    public void clearEvent(int op) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Clear event
" 
+                    + op);
+        }
+        this.session.clearEvent(op);
+    }
+
+    public void close() {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Close");
+        }
+        this.session.close();
+    }
+
+    public boolean isClosed() {
+        return this.session.isClosed();
+    }
+
+    public int getSocketTimeout() {
+        return this.session.getSocketTimeout();
+    }
+
+    public void setSocketTimeout(int timeout) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Set timeout
" 
+                    + timeout);
+        }
+        this.session.setSocketTimeout(timeout);
+    }
+
+    public void setBufferStatus(final SessionBufferStatus status) {
+        this.session.setBufferStatus(status);
+    }
+
+    public boolean hasBufferedInput() {
+        return this.session.hasBufferedInput();
+    }
+
+    public boolean hasBufferedOutput() {
+        return this.session.hasBufferedOutput();
+    }
+
+    public Object getAttribute(final String name) {
+        return this.session.getAttribute(name);
+    }
+
+    public void setAttribute(final String name, final Object obj) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Set attribute
" 
+                    + name);
+        }
+        this.session.setAttribute(name, obj);
+    }
+
+    public Object removeAttribute(final String name) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("I/O session " + this.id + " " + this.session + ": Remove attribute
" 
+                    + name);
+        }
+        return this.session.removeAttribute(name);
+    }
+
+    class LoggingByteChannel implements ByteChannel {
+
+        public int read(final ByteBuffer dst) throws IOException {
+            int bytesRead = session.channel().read(dst);
+            if (log.isDebugEnabled()) {
+                log.debug("I/O session " + id + " " + session + ": " + bytesRead + " bytes
read");
+            }
+            return bytesRead;
+        }
+
+        public int write(final ByteBuffer src) throws IOException {
+            int byteWritten = session.channel().write(src);
+            if (log.isDebugEnabled()) {
+                log.debug("I/O session " + id + " " + session + ": " + byteWritten + " bytes
written");
+            }
+            return byteWritten;
+        }
+
+        public void close() throws IOException {
+            if (log.isDebugEnabled()) {
+                log.debug("I/O session " + id + " " + session + ": Channel close");
+            }
+            session.channel().close();
+        }
+
+        public boolean isOpen() {
+            return session.channel().isOpen();
+        }
+        
+    }    
+    
+}
\ No newline at end of file

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingIOSession.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingIOSession.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpClientHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpClientHandler.java?view=auto&rev=515218
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpClientHandler.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpClientHandler.java
Tue Mar  6 09:19:56 2007
@@ -0,0 +1,131 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * 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.contrib.logging;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpException;
+import org.apache.http.HttpResponse;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.NHttpClientConnection;
+import org.apache.http.nio.NHttpClientHandler;
+
+/**
+ * Decorator class intended to transparently extend an {@link NHttpClientHandler} 
+ * with basic event logging capabilities using Commons Logging. 
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public class LoggingNHttpClientHandler implements NHttpClientHandler {
+
+    private final Log log;
+    private final NHttpClientHandler handler;
+    
+    public LoggingNHttpClientHandler(final NHttpClientHandler handler) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP client handler may not be null");
+        }
+        this.handler = handler;
+        this.log = LogFactory.getLog(handler.getClass());
+    }
+    
+    public void connected(final NHttpClientConnection conn, final Object attachment) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Connected (" + attachment + ")");
+        }
+        this.handler.connected(conn, attachment);
+    }
+
+    public void closed(final NHttpClientConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Closed");
+        }
+        this.handler.closed(conn);
+    }
+
+    public void exception(final NHttpClientConnection conn, final IOException ex) {
+        this.log.error("HTTP connection " + conn + ": " + ex.getMessage(), ex);
+        this.handler.exception(conn, ex);
+    }
+
+    public void exception(final NHttpClientConnection conn, final HttpException ex) {
+        this.log.error("HTTP connection " + conn + ": " + ex.getMessage(), ex);
+        this.handler.exception(conn, ex);
+    }
+
+    public void requestReady(final NHttpClientConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Request ready");
+        }
+        this.handler.requestReady(conn);
+    }
+
+    public void outputReady(final NHttpClientConnection conn, final ContentEncoder encoder)
{
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Output ready");
+        }
+        this.handler.outputReady(conn, encoder);
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Content encoder " + encoder);
+        }
+    }
+
+    public void responseReceived(final NHttpClientConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            HttpResponse response = conn.getHttpResponse();
+            this.log.debug("HTTP connection " + conn + ": " + response.getStatusLine());
+        }
+        this.handler.responseReceived(conn);
+    }
+
+    public void inputReady(final NHttpClientConnection conn, final ContentDecoder decoder)
{
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Input ready");
+        }
+        this.handler.inputReady(conn, decoder);
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Content decoder " + decoder);
+        }
+    }
+
+    public void timeout(final NHttpClientConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Timeout");
+        }
+        this.handler.timeout(conn);
+    }
+
+}
\ No newline at end of file

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpClientHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpClientHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpServiceHandler.java?view=auto&rev=515218
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpServiceHandler.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpServiceHandler.java
Tue Mar  6 09:19:56 2007
@@ -0,0 +1,131 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * 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.contrib.logging;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.NHttpServerConnection;
+import org.apache.http.nio.NHttpServiceHandler;
+
+/**
+ * Decorator class intended to transparently extend an {@link NHttpServiceHandler} 
+ * with basic event logging capabilities using Commons Logging. 
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public class LoggingNHttpServiceHandler implements NHttpServiceHandler {
+
+    private final Log log;
+    private final NHttpServiceHandler handler;
+    
+    public LoggingNHttpServiceHandler(final NHttpServiceHandler handler) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP service handler may not be null");
+        }
+        this.handler = handler;
+        this.log = LogFactory.getLog(handler.getClass());
+    }
+    
+    public void connected(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Connected");
+        }
+        this.handler.connected(conn);
+    }
+
+    public void closed(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Closed");
+        }
+        this.handler.closed(conn);
+    }
+
+    public void exception(final NHttpServerConnection conn, final IOException ex) {
+        this.log.error("HTTP connection " + conn + ": " + ex.getMessage(), ex);
+        this.handler.exception(conn, ex);
+    }
+
+    public void exception(final NHttpServerConnection conn, final HttpException ex) {
+        this.log.error("HTTP connection " + conn + ": " + ex.getMessage(), ex);
+        this.handler.exception(conn, ex);
+    }
+
+    public void requestReceived(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            HttpRequest request = conn.getHttpRequest();
+            this.log.debug("HTTP connection " + conn + ": " + request.getRequestLine());
+        }
+        this.handler.requestReceived(conn);
+    }
+
+    public void outputReady(final NHttpServerConnection conn, final ContentEncoder encoder)
{
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Output ready");
+        }
+        this.handler.outputReady(conn, encoder);
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Content encoder " + encoder);
+        }
+    }
+
+    public void responseReady(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Response ready");
+        }
+        this.handler.responseReady(conn);
+    }
+
+    public void inputReady(final NHttpServerConnection conn, final ContentDecoder decoder)
{
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Input ready");
+        }
+        this.handler.inputReady(conn, decoder);
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Content decoder " + decoder);
+        }
+    }
+
+    public void timeout(final NHttpServerConnection conn) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("HTTP connection " + conn + ": Timeout");
+        }
+        this.handler.timeout(conn);
+    }
+
+}
\ No newline at end of file

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpServiceHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingNHttpServiceHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingServerIOEventDispatch.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingServerIOEventDispatch.java?view=auto&rev=515218
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingServerIOEventDispatch.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingServerIOEventDispatch.java
Tue Mar  6 09:19:56 2007
@@ -0,0 +1,93 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * 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.contrib.logging;
+
+import org.apache.http.impl.DefaultHttpRequestFactory;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
+import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.params.HttpParams;
+
+public class LoggingServerIOEventDispatch implements IOEventDispatch {
+
+    private static final String NHTTP_CONN = "NHTTP_CONN";
+    
+    private final NHttpServiceHandler handler;
+    private final HttpParams params;
+    
+    public LoggingServerIOEventDispatch(final NHttpServiceHandler handler, final HttpParams
params) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP service handler may not be null");
+        }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        this.handler = new LoggingNHttpServiceHandler(handler);
+        this.params = params;
+    }
+    
+    public void connected(final IOSession session) {
+        DefaultNHttpServerConnection conn = new DefaultNHttpServerConnection(
+                new LoggingIOSession(session), 
+                new DefaultHttpRequestFactory(),
+                this.params); 
+        session.setAttribute(NHTTP_CONN, conn);
+        this.handler.connected(conn);
+    }
+
+    public void disconnected(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        this.handler.closed(conn);
+    }
+
+    public void inputReady(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        conn.consumeInput(this.handler);
+    }
+
+    public void outputReady(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        conn.produceOutput(this.handler);
+    }
+
+    public void timeout(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        this.handler.timeout(conn);
+    }
+
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingServerIOEventDispatch.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/logging/LoggingServerIOEventDispatch.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message