// Path: src/main/java/com/biasedbit/hotpotato/client/host/DefaultHostContext.java
// public class DefaultHostContext extends AbstractHostContext {
// 
//     // constructors ---------------------------------------------------------------------------------------------------
// 
//     public DefaultHostContext(String host, int port, int maxConnections) {
//         super(host, port, maxConnections);
//     }
// }
// 
// Path: src/main/java/com/biasedbit/hotpotato/client/host/HostContext.java
// public interface HostContext {
// 
//     public enum DrainQueueResult {
//         QUEUE_EMPTY,
//         DRAINED,
//         NOT_DRAINED,
//         OPEN_CONNECTION,
//     }
// 
//     String getHost();
// 
//     int getPort();
// 
//     ConnectionPool getConnectionPool();
// 
//     Queue<HttpRequestContext> getQueue();
// 
//     /**
//      * Used to restore requests to the head of the queue.
//      *
//      * An example of the usage of this method is when a pipelining HTTP connection disconnects unexpectedly while some
//      * of the requests were still waiting for a response. Instead of simply failing those requests, they can be retried
//      * in a different connection, provided that their execution order is maintained (i.e. they go back to the head of
//      * the queue and not the tail).
//      *
//      * @param requests Collection of requests to add to the queue head.
//      */
//     void restoreRequestsToQueue(Collection<HttpRequestContext> requests);
// 
//     /**
//      * Adds a request to the end of the queue.
//      *
//      * @param request Request to add.
//      */
//     void addToQueue(HttpRequestContext request);
// 
//     /**
//      * Drains one (or more) elements of the queue into one (or more) connections in the connection pool.
//      *
//      * This is the method used to move queue elements into connections and thus advance the request dispatching process.
//      *
//      * @return The result of the drain operation.
//      */
//     DrainQueueResult drainQueue();
// 
//     /**
//      * Retrieves the first element of the queue (head).
//      *
//      * @return The first element of the queue.
//      */
//     HttpRequestContext pollQueue();
// 
//     /**
//      * Fails all queued requests with the given cause.
//      *
//      * @param cause Cause to fail all queued requests.
//      */
//     void failAllRequests(Throwable cause);
// }


import com.biasedbit.hotpotato.client.host.DefaultHostContext;
import com.biasedbit.hotpotato.client.host.HostContext;
/*
 * Copyright 2010 Bruno de Carvalho
 *
 * 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.
 */

package com.biasedbit.hotpotato.client.host.factory;


/**
 * @author <a href="http://bruno.biasedbit.com/">Bruno de Carvalho</a>
 */
public class DefaultHostContextFactory implements HostContextFactory {

    // HostContextFactory ---------------------------------------------------------------------------------------------

    @Override
    public HostContext createHostContext(String host, int port, int maxConnections) {
// Path: src/main/java/com/biasedbit/hotpotato/client/host/DefaultHostContext.java
// public class DefaultHostContext extends AbstractHostContext {
// 
//     // constructors ---------------------------------------------------------------------------------------------------
// 
//     public DefaultHostContext(String host, int port, int maxConnections) {
//         super(host, port, maxConnections);
//     }
// }
// 
// Path: src/main/java/com/biasedbit/hotpotato/client/host/HostContext.java
// public interface HostContext {
// 
//     public enum DrainQueueResult {
//         QUEUE_EMPTY,
//         DRAINED,
//         NOT_DRAINED,
//         OPEN_CONNECTION,
//     }
// 
//     String getHost();
// 
//     int getPort();
// 
//     ConnectionPool getConnectionPool();
// 
//     Queue<HttpRequestContext> getQueue();
// 
//     /**
//      * Used to restore requests to the head of the queue.
//      *
//      * An example of the usage of this method is when a pipelining HTTP connection disconnects unexpectedly while some
//      * of the requests were still waiting for a response. Instead of simply failing those requests, they can be retried
//      * in a different connection, provided that their execution order is maintained (i.e. they go back to the head of
//      * the queue and not the tail).
//      *
//      * @param requests Collection of requests to add to the queue head.
//      */
//     void restoreRequestsToQueue(Collection<HttpRequestContext> requests);
// 
//     /**
//      * Adds a request to the end of the queue.
//      *
//      * @param request Request to add.
//      */
//     void addToQueue(HttpRequestContext request);
// 
//     /**
//      * Drains one (or more) elements of the queue into one (or more) connections in the connection pool.
//      *
//      * This is the method used to move queue elements into connections and thus advance the request dispatching process.
//      *
//      * @return The result of the drain operation.
//      */
//     DrainQueueResult drainQueue();
// 
//     /**
//      * Retrieves the first element of the queue (head).
//      *
//      * @return The first element of the queue.
//      */
//     HttpRequestContext pollQueue();
// 
//     /**
//      * Fails all queued requests with the given cause.
//      *
//      * @param cause Cause to fail all queued requests.
//      */
//     void failAllRequests(Throwable cause);
// }


// Path: src/main/java/com/biasedbit/hotpotato/client/host/factory/DefaultHostContextFactory.java
import com.biasedbit.hotpotato.client.host.DefaultHostContext;
import com.biasedbit.hotpotato.client.host.HostContext;

/*
 * Copyright 2010 Bruno de Carvalho
 *
 * 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.
 */

package com.biasedbit.hotpotato.client.host.factory;


/**
 * @author <a href="http://bruno.biasedbit.com/">Bruno de Carvalho</a>
 */
public class DefaultHostContextFactory implements HostContextFactory {

    // HostContextFactory ---------------------------------------------------------------------------------------------

    @Override
    public HostContext createHostContext(String host, int port, int maxConnections) {
        return new DefaultHostContext(host, port, maxConnections);