hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1598055 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/impl/nio/ httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ httpcore/src/main/java/org/apache/http/impl/bootstrap/
Date Wed, 28 May 2014 15:52:01 GMT
Author: olegk
Date: Wed May 28 15:52:00 2014
New Revision: 1598055

URL: http://svn.apache.org/r1598055
Log:
 Bootstrap for embedded server based on non-blocking I/O

Added:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/Server.java
  (with props)
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ServerBootstrap.java
      - copied, changed from r1598053, httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ThreadFactoryImpl.java
  (with props)
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/package-info.java
  (with props)
Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/Server.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java?rev=1598055&r1=1598054&r2=1598055&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
Wed May 28 15:52:00 2014
@@ -54,11 +54,11 @@ public class DefaultHttpServerIODispatch
                     extends AbstractIODispatch<DefaultNHttpServerConnection> {
 
     private final NHttpServerEventHandler handler;
-    private final NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory;
+    private final NHttpConnectionFactory<? extends DefaultNHttpServerConnection> connFactory;
 
     public DefaultHttpServerIODispatch(
             final NHttpServerEventHandler handler,
-            final NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory)
{
+            final NHttpConnectionFactory<? extends DefaultNHttpServerConnection> connFactory)
{
         super();
         this.handler = Args.notNull(handler, "HTTP client handler");
         this.connFactory = Args.notNull(connFactory, "HTTP server connection factory");

Added: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/Server.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/Server.java?rev=1598055&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/Server.java
(added)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/Server.java
Wed May 28 15:52:00 2014
@@ -0,0 +1,160 @@
+/*
+ * ====================================================================
+ * 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.impl.nio.bootstrap;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.http.ExceptionLogger;
+import org.apache.http.impl.nio.DefaultHttpServerIODispatch;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
+import org.apache.http.impl.nio.reactor.DefaultListeningIOReactor;
+import org.apache.http.impl.nio.reactor.IOReactorConfig;
+import org.apache.http.nio.NHttpConnectionFactory;
+import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.IOReactorException;
+import org.apache.http.nio.reactor.IOReactorExceptionHandler;
+import org.apache.http.nio.reactor.ListenerEndpoint;
+
+/**
+ * @since 4.4
+ */
+public class Server {
+
+    enum Status { READY, ACTIVE, STOPPING }
+
+    private final int port;
+    private final InetAddress ifAddress;
+    private final IOReactorConfig ioReactorConfig;
+    private final HttpAsyncService httpService;
+    private final NHttpConnectionFactory<? extends DefaultNHttpServerConnection> connectionFactory;
+    private final ExceptionLogger exceptionLogger;
+    private final ExecutorService listenerExecutorService;
+    private final ThreadGroup dispatchThreads;
+    private final AtomicReference<Status> status;
+    private final DefaultListeningIOReactor ioReactor;
+
+    private volatile ListenerEndpoint endpoint;
+
+    Server(
+            final int port,
+            final InetAddress ifAddress,
+            final IOReactorConfig ioReactorConfig,
+            final HttpAsyncService httpService,
+            final NHttpConnectionFactory<? extends DefaultNHttpServerConnection> connectionFactory,
+            final ExceptionLogger exceptionLogger) {
+        this.port = port;
+        this.ifAddress = ifAddress;
+        this.ioReactorConfig = ioReactorConfig;
+        this.httpService = httpService;
+        this.connectionFactory = connectionFactory;
+        this.exceptionLogger = exceptionLogger;
+        this.listenerExecutorService = Executors.newSingleThreadExecutor(
+                new ThreadFactoryImpl("HTTP-listener-" + this.port));
+        this.dispatchThreads = new ThreadGroup("I/O-dispatchers");
+        try {
+            this.ioReactor = new DefaultListeningIOReactor(
+                    this.ioReactorConfig,
+                    new ThreadFactoryImpl("I/O-dispatch", this.dispatchThreads));
+        } catch (IOReactorException ex) {
+            throw new IllegalStateException(ex);
+        }
+        this.ioReactor.setExceptionHandler(new IOReactorExceptionHandler() {
+            @Override
+            public boolean handle(final IOException ex) {
+                exceptionLogger.log(ex);
+                return false;
+            }
+
+            @Override
+            public boolean handle(final RuntimeException ex) {
+                exceptionLogger.log(ex);
+                return false;
+            }
+        });
+        this.status = new AtomicReference<Status>(Status.READY);
+    }
+
+    public InetAddress getInetAddress() {
+        final ListenerEndpoint local = this.endpoint;
+        if (local != null) {
+            return ((InetSocketAddress) local.getAddress()).getAddress();
+        } else {
+            return null;
+        }
+    }
+
+    public int getLocalPort() {
+        final ListenerEndpoint local = this.endpoint;
+        if (local != null) {
+            return ((InetSocketAddress) local.getAddress()).getPort();
+        } else {
+            return -1;
+        }
+    }
+
+    public void start() throws IOException {
+        if (this.status.compareAndSet(Status.READY, Status.ACTIVE)) {
+            this.ioReactor.listen(new InetSocketAddress(this.ifAddress, this.port > 0
? this.port : 0));
+            final IOEventDispatch ioEventDispatch = new DefaultHttpServerIODispatch(
+                    this.httpService, this.connectionFactory);
+            this.listenerExecutorService.execute(new Runnable() {
+
+                @Override
+                public void run() {
+                    try {
+                        ioReactor.execute(ioEventDispatch);
+                    } catch (Exception ex) {
+                        exceptionLogger.log(ex);
+                    }
+                }
+
+            });
+        }
+    }
+
+    public void awaitTermination(final long timeout, final TimeUnit timeUnit) throws InterruptedException
{
+        this.listenerExecutorService.awaitTermination(timeout, timeUnit);
+    }
+
+    public void shutdown(final long gracePeriod, final TimeUnit timeUnit) {
+        if (this.status.compareAndSet(Status.ACTIVE, Status.STOPPING)) {
+            try {
+                this.ioReactor.shutdown(timeUnit.toMillis(gracePeriod));
+            } catch (IOException ex) {
+                this.exceptionLogger.log(ex);
+            }
+        }
+    }
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/Server.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/Server.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ServerBootstrap.java
(from r1598053, httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ServerBootstrap.java?p2=httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ServerBootstrap.java&p1=httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java&r1=1598053&r2=1598055&rev=1598055&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ServerBootstrap.java
Wed May 28 15:52:00 2014
@@ -24,39 +24,40 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.http.impl.bootstrap;
+package org.apache.http.impl.nio.bootstrap;
 
 import java.net.InetAddress;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.Map;
 
-import javax.net.ServerSocketFactory;
 import javax.net.ssl.SSLContext;
 
 import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.ExceptionLogger;
-import org.apache.http.HttpConnectionFactory;
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpServerConnection;
 import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.SocketConfig;
-import org.apache.http.impl.DefaultBHttpServerConnectionFactory;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.protocol.HttpExpectationVerifier;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
+import org.apache.http.impl.nio.DefaultNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.SSLNHttpServerConnectionFactory;
+import org.apache.http.impl.nio.reactor.IOReactorConfig;
+import org.apache.http.nio.NHttpConnectionFactory;
+import org.apache.http.nio.protocol.HttpAsyncExpectationVerifier;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper;
+import org.apache.http.nio.protocol.HttpAsyncService;
+import org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
+import org.apache.http.nio.reactor.ssl.SSLSetupHandler;
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.HttpProcessorBuilder;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.protocol.HttpRequestHandlerMapper;
-import org.apache.http.protocol.HttpService;
 import org.apache.http.protocol.ResponseConnControl;
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
-import org.apache.http.protocol.UriHttpRequestHandlerMapper;
 
 /**
  * @since 4.4
@@ -65,7 +66,7 @@ public class ServerBootstrap {
 
     private int listenerPort;
     private InetAddress localAddress;
-    private SocketConfig socketConfig;
+    private IOReactorConfig ioReactorConfig;
     private ConnectionConfig connectionConfig;
     private LinkedList<HttpRequestInterceptor> requestFirst;
     private LinkedList<HttpRequestInterceptor> requestLast;
@@ -75,11 +76,12 @@ public class ServerBootstrap {
     private HttpProcessor httpProcessor;
     private ConnectionReuseStrategy connStrategy;
     private HttpResponseFactory responseFactory;
-    private HttpRequestHandlerMapper handlerMapper;
-    private Map<String, HttpRequestHandler> handlerMap;
-    private HttpExpectationVerifier expectationVerifier;
+    private HttpAsyncRequestHandlerMapper handlerMapper;
+    private Map<String, HttpAsyncRequestHandler<?>> handlerMap;
+    private HttpAsyncExpectationVerifier expectationVerifier;
     private SSLContext sslContext;
-    private HttpConnectionFactory<? extends HttpServerConnection> connectionFactory;
+    private SSLSetupHandler sslSetupHandler;
+    private NHttpConnectionFactory<? extends DefaultNHttpServerConnection> connectionFactory;
     private ExceptionLogger exceptionLogger;
 
     private ServerBootstrap() {
@@ -106,10 +108,10 @@ public class ServerBootstrap {
     }
 
     /**
-     * Sets socket configuration.
+     * Sets I/O reactor configuration.
      */
-    public final ServerBootstrap setSocketConfig(final SocketConfig socketConfig) {
-        this.socketConfig = socketConfig;
+    public final ServerBootstrap setIOReactorConfig(final IOReactorConfig ioReactorConfig)
{
+        this.ioReactorConfig = ioReactorConfig;
         return this;
     }
 
@@ -117,7 +119,7 @@ public class ServerBootstrap {
      * Sets connection configuration.
      * <p/>
      * Please note this value can be overridden by the {@link #setConnectionFactory(
-     * org.apache.http.HttpConnectionFactory)} method.
+     *   org.apache.http.nio.NHttpConnectionFactory)} method.
      */
     public final ServerBootstrap setConnectionConfig(final ConnectionConfig connectionConfig)
{
         this.connectionConfig = connectionConfig;
@@ -125,7 +127,7 @@ public class ServerBootstrap {
     }
 
     /**
-     * Assigns {@link HttpProcessor} instance.
+     * Assigns {@link org.apache.http.protocol.HttpProcessor} instance.
      */
     public final ServerBootstrap setHttpProcessor(final HttpProcessor httpProcessor) {
         this.httpProcessor = httpProcessor;
@@ -212,7 +214,7 @@ public class ServerBootstrap {
     }
 
     /**
-     * Assigns {@link ConnectionReuseStrategy} instance.
+     * Assigns {@link org.apache.http.ConnectionReuseStrategy} instance.
      */
     public final ServerBootstrap setConnectionReuseStrategy(final ConnectionReuseStrategy
connStrategy) {
         this.connStrategy = connStrategy;
@@ -220,7 +222,7 @@ public class ServerBootstrap {
     }
 
     /**
-     * Assigns {@link HttpResponseFactory} instance.
+     * Assigns {@link org.apache.http.HttpResponseFactory} instance.
      */
     public final ServerBootstrap setResponseFactory(final HttpResponseFactory responseFactory)
{
         this.responseFactory = responseFactory;
@@ -228,53 +230,56 @@ public class ServerBootstrap {
     }
 
     /**
-     * Assigns {@link HttpRequestHandlerMapper} instance.
+     * Assigns {@link org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper} instance.
      */
-    public final ServerBootstrap setHandlerMapper(final HttpRequestHandlerMapper handlerMapper)
{
+    public final ServerBootstrap setHandlerMapper(final HttpAsyncRequestHandlerMapper handlerMapper)
{
         this.handlerMapper = handlerMapper;
         return this;
     }
 
     /**
-     * Registers the given {@link HttpRequestHandler} as a handler for URIs
-     * matching the given pattern.
+     * Registers the given {@link org.apache.http.nio.protocol.HttpAsyncRequestHandler}
+     * as a handler for URIs matching the given pattern.
      * <p/>
      * Please note this value can be overridden by the {@link #setHandlerMapper(
-     *   org.apache.http.protocol.HttpRequestHandlerMapper)} method.
+     *   org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper)} )} method.
      *
      * @param pattern the pattern to register the handler for.
      * @param handler the handler.
      */
-    public final ServerBootstrap registerHandler(final String pattern, final HttpRequestHandler
handler) {
+    public final ServerBootstrap registerHandler(final String pattern, final HttpAsyncRequestHandler<?>
handler) {
         if (pattern == null || handler == null) {
             return this;
         }
         if (handlerMap == null) {
-            handlerMap = new HashMap<String, HttpRequestHandler>();
+            handlerMap = new HashMap<String, HttpAsyncRequestHandler<?>>();
         }
         handlerMap.put(pattern, handler);
         return this;
     }
 
     /**
-     * Assigns {@link HttpExpectationVerifier} instance.
+     * Assigns {@link org.apache.http.nio.protocol.HttpAsyncExpectationVerifier} instance.
      */
-    public final ServerBootstrap setExpectationVerifier(final HttpExpectationVerifier expectationVerifier)
{
+    public final ServerBootstrap setExpectationVerifier(final HttpAsyncExpectationVerifier
expectationVerifier) {
         this.expectationVerifier = expectationVerifier;
         return this;
     }
 
     /**
-     * Assigns {@link HttpConnectionFactory} instance.
+     * Assigns {@link org.apache.http.nio.NHttpConnectionFactory} instance.
      */
     public final ServerBootstrap setConnectionFactory(
-            final HttpConnectionFactory<? extends HttpServerConnection> connectionFactory)
{
+            final NHttpConnectionFactory<? extends DefaultNHttpServerConnection> connectionFactory)
{
         this.connectionFactory = connectionFactory;
         return this;
     }
 
     /**
      * Assigns {@link javax.net.ssl.SSLContext} instance.
+     * <p/>
+     * Please note this value can be overridden by the {@link #setConnectionFactory(
+     *   org.apache.http.nio.NHttpConnectionFactory)} method.
      */
     public final ServerBootstrap setSslContext(final SSLContext sslContext) {
         this.sslContext = sslContext;
@@ -282,6 +287,17 @@ public class ServerBootstrap {
     }
 
     /**
+     * Assigns {@link org.apache.http.nio.reactor.ssl.SSLSetupHandler} instance.
+     * <p/>
+     * Please note this value can be overridden by the {@link #setConnectionFactory(
+     *   org.apache.http.nio.NHttpConnectionFactory)} method.
+     */
+    public ServerBootstrap setSslSetupHandler(final SSLSetupHandler sslSetupHandler) {
+        this.sslSetupHandler = sslSetupHandler;
+        return this;
+    }
+
+    /**
      * Assigns {@link org.apache.http.ExceptionLogger} instance.
      */
     public final ServerBootstrap setExceptionLogger(final ExceptionLogger exceptionLogger)
{
@@ -308,7 +324,7 @@ public class ServerBootstrap {
 
             String serverInfoCopy = this.serverInfo;
             if (serverInfoCopy == null) {
-                serverInfoCopy = "Apache-HttpCore/1.1";
+                serverInfoCopy = "Apache-HttpCore-NIO/1.1";
             }
 
             b.addAll(
@@ -329,11 +345,11 @@ public class ServerBootstrap {
             httpProcessorCopy = b.build();
         }
 
-        HttpRequestHandlerMapper handlerMapperCopy = this.handlerMapper;
+        HttpAsyncRequestHandlerMapper handlerMapperCopy = this.handlerMapper;
         if (handlerMapperCopy == null) {
-            final UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
+            final UriHttpAsyncRequestHandlerMapper reqistry = new UriHttpAsyncRequestHandlerMapper();
             if (handlerMap != null) {
-                for (Map.Entry<String, HttpRequestHandler> entry: handlerMap.entrySet())
{
+                for (Map.Entry<String, HttpAsyncRequestHandler<?>> entry: handlerMap.entrySet())
{
                     reqistry.register(entry.getKey(), entry.getValue());
                 }
             }
@@ -350,23 +366,13 @@ public class ServerBootstrap {
             responseFactoryCopy = DefaultHttpResponseFactory.INSTANCE;
         }
 
-        final HttpService httpService = new HttpService(
-                httpProcessorCopy, connStrategyCopy, responseFactoryCopy, handlerMapperCopy,
-                this.expectationVerifier);
-
-        final ServerSocketFactory serverSocketFactory;
-        if (this.sslContext != null) {
-            serverSocketFactory = this.sslContext.getServerSocketFactory();
-        } else {
-            serverSocketFactory = ServerSocketFactory.getDefault();
-        }
-
-        HttpConnectionFactory<? extends HttpServerConnection> connectionFactoryCopy
= this.connectionFactory;
+        NHttpConnectionFactory<? extends DefaultNHttpServerConnection> connectionFactoryCopy
= this.connectionFactory;
         if (connectionFactoryCopy == null) {
-            if (this.connectionConfig != null) {
-                connectionFactoryCopy = new DefaultBHttpServerConnectionFactory(this.connectionConfig);
+            if (this.sslContext != null) {
+                connectionFactoryCopy = new SSLNHttpServerConnectionFactory(
+                        this.sslContext, this.sslSetupHandler, this.connectionConfig);
             } else {
-                connectionFactoryCopy = DefaultBHttpServerConnectionFactory.INSTANCE;
+                connectionFactoryCopy = new DefaultNHttpServerConnectionFactory(this.connectionConfig);
             }
         }
 
@@ -375,14 +381,13 @@ public class ServerBootstrap {
             exceptionLoggerCopy = ExceptionLogger.NO_OP;
         }
 
-        return new Server(
-                this.listenerPort > 0 ? this.listenerPort : 0,
-                this.localAddress,
-                this.socketConfig != null ? this.socketConfig : SocketConfig.DEFAULT,
-                serverSocketFactory,
-                httpService,
-                connectionFactoryCopy,
-                exceptionLoggerCopy);
+        final HttpAsyncService httpService = new HttpAsyncService(
+                httpProcessorCopy, connStrategyCopy, responseFactoryCopy, handlerMapperCopy,
+                this.expectationVerifier, exceptionLoggerCopy);
+
+        return new Server(this.listenerPort, this.localAddress, this.ioReactorConfig,
+                httpService, connectionFactoryCopy, exceptionLoggerCopy);
+
     }
 
 }

Added: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ThreadFactoryImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ThreadFactoryImpl.java?rev=1598055&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ThreadFactoryImpl.java
(added)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ThreadFactoryImpl.java
Wed May 28 15:52:00 2014
@@ -0,0 +1,56 @@
+/*
+ * ====================================================================
+ * 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.impl.nio.bootstrap;
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * @since 4.4
+ */
+class ThreadFactoryImpl implements ThreadFactory {
+
+    private final String namePrefix;
+    private final ThreadGroup group;
+    private final AtomicLong count;
+
+    ThreadFactoryImpl(final String namePrefix, final ThreadGroup group) {
+        this.namePrefix = namePrefix;
+        this.group = group;
+        this.count = new AtomicLong();
+    }
+
+    ThreadFactoryImpl(final String namePrefix) {
+        this(namePrefix, null);
+    }
+
+    @Override
+    public Thread newThread(final Runnable target) {
+        return new Thread(this.group, target, this.namePrefix + "-"  + this.count.incrementAndGet());
+    }
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ThreadFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ThreadFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/ThreadFactoryImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/package-info.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/package-info.java?rev=1598055&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/package-info.java
(added)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/package-info.java
Wed May 28 15:52:00 2014
@@ -0,0 +1,31 @@
+/*
+ * ====================================================================
+ * 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/>.
+ *
+ */
+
+/**
+ * Embedded non-blocking server and server bootstrap.
+ */
+package org.apache.http.impl.nio.bootstrap;

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/bootstrap/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/Server.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/Server.java?rev=1598055&r1=1598054&r2=1598055&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/Server.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/Server.java
Wed May 28 15:52:00 2014
@@ -41,6 +41,7 @@ import org.apache.http.ExceptionLogger;
 import org.apache.http.HttpConnectionFactory;
 import org.apache.http.HttpServerConnection;
 import org.apache.http.config.SocketConfig;
+import org.apache.http.impl.DefaultBHttpServerConnection;
 import org.apache.http.protocol.HttpService;
 
 /**
@@ -55,7 +56,7 @@ public class Server {
     private final SocketConfig socketConfig;
     private final ServerSocketFactory serverSocketFactory;
     private final HttpService httpService;
-    private final HttpConnectionFactory<? extends HttpServerConnection> connectionFactory;
+    private final HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactory;
     private final ExceptionLogger exceptionLogger;
     private final ExecutorService listenerExecutorService;
     private final ThreadGroup workerThreads;
@@ -71,7 +72,7 @@ public class Server {
             final SocketConfig socketConfig,
             final ServerSocketFactory serverSocketFactory,
             final HttpService httpService,
-            final HttpConnectionFactory<? extends HttpServerConnection> connectionFactory,
+            final HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactory,
             final ExceptionLogger exceptionLogger) {
         this.port = port;
         this.ifAddress = ifAddress;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java?rev=1598055&r1=1598054&r2=1598055&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java
Wed May 28 15:52:00 2014
@@ -40,9 +40,9 @@ import org.apache.http.HttpConnectionFac
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpServerConnection;
 import org.apache.http.config.ConnectionConfig;
 import org.apache.http.config.SocketConfig;
+import org.apache.http.impl.DefaultBHttpServerConnection;
 import org.apache.http.impl.DefaultBHttpServerConnectionFactory;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
@@ -79,7 +79,7 @@ public class ServerBootstrap {
     private Map<String, HttpRequestHandler> handlerMap;
     private HttpExpectationVerifier expectationVerifier;
     private SSLContext sslContext;
-    private HttpConnectionFactory<? extends HttpServerConnection> connectionFactory;
+    private HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactory;
     private ExceptionLogger exceptionLogger;
 
     private ServerBootstrap() {
@@ -268,7 +268,7 @@ public class ServerBootstrap {
      * Assigns {@link HttpConnectionFactory} instance.
      */
     public final ServerBootstrap setConnectionFactory(
-            final HttpConnectionFactory<? extends HttpServerConnection> connectionFactory)
{
+            final HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactory)
{
         this.connectionFactory = connectionFactory;
         return this;
     }
@@ -361,7 +361,7 @@ public class ServerBootstrap {
             serverSocketFactory = ServerSocketFactory.getDefault();
         }
 
-        HttpConnectionFactory<? extends HttpServerConnection> connectionFactoryCopy
= this.connectionFactory;
+        HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactoryCopy
= this.connectionFactory;
         if (connectionFactoryCopy == null) {
             if (this.connectionConfig != null) {
                 connectionFactoryCopy = new DefaultBHttpServerConnectionFactory(this.connectionConfig);



Mime
View raw message