You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2007/10/23 04:29:48 UTC

svn commit: r587364 [3/7] - in /mina/sandbox/asyncweb: ./ assembly/ assembly/src/ assembly/src/main/ assembly/src/main/descriptor/ core/ core/src/ core/src/main/ core/src/main/java/ core/src/main/java/org/ core/src/main/java/org/safehaus/ core/src/main...

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpRequest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpRequest.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpRequest.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpRequest.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,108 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a HTTP request made by a client.
+ * <code>HttpRequest</code>s may be responded to asyncronously at any
+ * time. <code>createHttpResponse</code> should be used to create a
+ * response to be populated - and when ready should be committed to the
+ * client using <code>commitResponse</code>
+ *   
+ * @author irvingd
+ * @author trustin
+ *
+ */
+public interface HttpRequest extends HttpMessage {
+  
+  /**
+   * Determines whether this request contains at least one parameter with
+   * the specified name
+   * 
+   * @param name  The parameter name
+   * @return      <code>true</code> if this request contains at least one parameter
+   *              with the specfied name
+   */
+  boolean containsParameter(String name);
+  
+  /**
+   * Returns the value of a request parameter as a String, 
+   * or null if the parameter does not exist.
+   * 
+   * If the request contained multiple parameters with the same name,
+   * this method returns the first parameter encountered in the request 
+   * with the specified name
+   * 
+   * @param name  The parameter name
+   * @return      The value
+   */
+  String getParameter(String name);
+  
+  /**
+   * Returns a read only {@link Map} of query parameters whose key is a {@link String} and
+   * whose value is a {@link List} of {@link String}s.
+   */
+  Map<String, List<String>> getParameters();
+ 
+  /**
+   * Returns the {@link HttpMethod} associated with this request.
+   */
+  HttpMethod getMethod();
+  
+  /**
+   * Returns the URI of the request.
+   */
+  URI getRequestUri();
+
+  /**
+   * Determines whether the HTTP connection should remain open
+   * after handling this request.
+   * If the request is a <code>HTTP/1.1</code> request, we keep
+   * the connection alive unless an explicit <code>"Connection: close"</code>
+   * header is sent.<br/>
+   * Otherwise, the connection is only kept alive if an explicit
+   * <code>"Connection: keep-alive"</code> header is sent
+   * 
+   * @return  <code>true</code> iff the connection should remain
+   *          open following the handling of this request
+   */
+  boolean isKeepAlive();
+  
+  /**
+   * Determines whether ths request requires a "100-continue" response.
+   * A client may set a continuation expectation when sending a request
+   * before continuing to send the body of a request (e.g. because it
+   * would be inefficient to send the whole body if the server will
+   * reject the request based on the headers alone)<br/>
+   * If this request requires a continuation response, it should be
+   * sent to the client if the server is prepared to handle the request<br/>
+   * 
+   * Note that if a continuation response is sent to the client, the server
+   * MUST ultimately also send a final status code.
+   * 
+   * @return <code>true</code> if this request requires a continuation
+   *         response to be sent
+   */
+  boolean requiresContinuationResponse();
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpRequest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponse.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponse.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponse.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponse.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,74 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a response to an <code>HttpRequest</code>.
+ * 
+ * @author irvingd
+ *
+ */
+public interface HttpResponse extends HttpMessage {
+
+  /**
+   * Returns the value of the HTTP header with the specified name.
+   * If more than one header with the given name is associated with
+   * this response, one is selected and returned.
+   * 
+   * @param name  The name of the desired header
+   * @return      The header value - or null if no header is found
+   *              with the specified name
+   */
+  String getHeader(String name);
+  
+  /**
+   * Returns <tt>true</tt> if the HTTP header with the specified name exists in this response.
+   */
+  boolean containsHeader(String name);
+  
+  /**
+   * Returns the {@link Map} of HTTP headers whose key is a {@link String} and whose value
+   * is a {@link List} of {@link String}s.
+   */
+  Map<String, List<String>> getHeaders();
+
+  /**
+   * Returns the Content-Type header of the response.
+   */ 
+  String getContentType();
+  
+  /**
+   * Returns the status of this response
+   */
+  HttpResponseStatus getStatus();
+  
+  /**
+   * Returns the reason phrase which is associated with the current status of this response.
+   */
+  String getStatusReasonPhrase();
+  
+  /**
+   * Returns the content of the response body.
+   */
+  Content getContent();
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponse.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponseStatus.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponseStatus.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponseStatus.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponseStatus.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,340 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common;
+
+import java.io.Serializable;
+
+
+public class HttpResponseStatus implements Serializable {
+
+  private static final long serialVersionUID = -5885201751942967031L;
+
+  private static final int MIN_ID = 100;
+  private static final int MAX_ID = 599;
+  
+  private static final HttpResponseStatus[] RESPONSE_TABLE = new HttpResponseStatus[MAX_ID + 1];
+  
+  // Informational status codes
+ 
+  public static final HttpResponseStatus CONTINUE 
+    = new HttpResponseStatus(100, "Continue", true, false);
+  
+  public static final HttpResponseStatus SWITCHING_PROTOCOLS
+    = new HttpResponseStatus(101, "Switching Protocols", true, false);
+  
+  // Successful status codes
+  
+  public static final HttpResponseStatus OK
+    = new HttpResponseStatus(200, "OK", true, false);
+  
+  public static final HttpResponseStatus CREATED
+    = new HttpResponseStatus(201, "Created", true, false);
+  
+  public static final HttpResponseStatus ACCEPTED
+    = new HttpResponseStatus(202, "Accepted", true, false);
+  
+  public static final HttpResponseStatus NON_AUTHORITATIVE
+    = new HttpResponseStatus(203, "Non-Authoritative Information", true, false);
+  
+  public static final HttpResponseStatus NO_CONTENT
+    = new HttpResponseStatus(204, "No Content", false, false);
+  
+  public static final HttpResponseStatus RESET_CONTENT
+    = new HttpResponseStatus(205, "Reset Content", false, false);
+  
+  public static final HttpResponseStatus PARTIAL_CONTENT
+    = new HttpResponseStatus(206, "Partial Content", true, false);
+  
+  // Redirection status codes
+  
+  public static final HttpResponseStatus MULTIPLE_CHOICES
+    = new HttpResponseStatus(300, "Multiple Choices", true, false);
+  
+  public static final HttpResponseStatus MOVED_PERMANENTLY
+    = new HttpResponseStatus(301, "Moved Permanently", true, false);
+  
+  public static final HttpResponseStatus FOUND
+    = new HttpResponseStatus(302, "Found", true, false);
+  
+  public static final HttpResponseStatus SEE_OTHER
+    = new HttpResponseStatus(303, "See Other", true, false);
+  
+  public static final HttpResponseStatus NOT_MODIFIED
+    = new HttpResponseStatus(304, "Not Modified", false, false);
+  
+  public static final HttpResponseStatus USE_PROXY
+    = new HttpResponseStatus(305, "Use Proxy", true, false);
+  
+  public static final HttpResponseStatus TEMPORARY_REDIRECT
+    = new HttpResponseStatus(307, "Temporary Redirect", true, false);
+  
+  
+  // Client error codes
+  
+  public static final HttpResponseStatus BAD_REQUEST
+    = new HttpResponseStatus(400, "Bad Request", true, true);
+  
+  public static final HttpResponseStatus UNAUTHORIZED
+    = new HttpResponseStatus(401, "Unauthorized", true, false);
+  
+  public static final HttpResponseStatus PAYMENT_REQUIRED
+    = new HttpResponseStatus(402, "Payment Required", true, false);
+  
+  public static final HttpResponseStatus FORBIDDEN
+    = new HttpResponseStatus(403, "Forbidden", true, false);
+  
+  public static final HttpResponseStatus NOT_FOUND
+    = new HttpResponseStatus(404, "Not Found", true, false);
+  
+  public static final HttpResponseStatus METHOD_NOT_ALLOWED
+    = new HttpResponseStatus(405, "Method Not Allowed", true, false);
+  
+  public static final HttpResponseStatus NOT_ACCEPTABLE
+    = new HttpResponseStatus(406, "Not Acceptable", true, false);
+  
+  public static final HttpResponseStatus PROXY_AUTHENTICATION_REQUIRED
+    = new HttpResponseStatus(407, "Proxy Authentication Required", true, false);
+  
+  public static final HttpResponseStatus REQUEST_TIMEOUT
+    = new HttpResponseStatus(408, "Request Time-out", true, true);
+  
+  public static final HttpResponseStatus CONFLICT
+    = new HttpResponseStatus(409, "Conflict", true, false);
+  
+  public static final HttpResponseStatus GONE
+    = new HttpResponseStatus(410, "Gone", true, false);
+  
+  public static final HttpResponseStatus LENGTH_REQUIRED
+    = new HttpResponseStatus(411, "Length Required", true, true);  
+  
+  public static final HttpResponseStatus PRECONDITION_FAILED
+    = new HttpResponseStatus(412, "Precondition Failed", true, false);  
+  
+  public static final HttpResponseStatus REQUEST_ENTITY_TOO_LARGE
+    = new HttpResponseStatus(413, "Request Entity Too Large", true, true);  
+  
+  public static final HttpResponseStatus REQUEST_URI_TOO_LONG
+    = new HttpResponseStatus(414, "Request-URI Too Large", true, true);
+  
+  public static final HttpResponseStatus UNSUPPORTED_MEDIA_TYPE
+    = new HttpResponseStatus(415, "Unsupported Media Type", true, false);
+  
+  public static final HttpResponseStatus REQUEST_RANGE_NOT_SATISFIABLE
+    = new HttpResponseStatus(416, "Requested range not satisfiable", true, false);
+  
+  public static final HttpResponseStatus EXPECTATION_FAILED
+    = new HttpResponseStatus(417, "Expectation Failed", true, false);
+  
+  
+  // Server error codes
+  
+  public static final HttpResponseStatus INTERNAL_SERVER_ERROR
+    = new HttpResponseStatus(500, "Internal Server Error", true, true);
+  
+  public static final HttpResponseStatus NOT_IMPLEMENTED
+    = new HttpResponseStatus(501, "Not Implemented", true, true);
+  
+  public static final HttpResponseStatus BAD_GATEWAY
+    = new HttpResponseStatus(502, "Bad Gateway", true, false);
+  
+  public static final HttpResponseStatus SERVICE_UNAVAILABLE
+    = new HttpResponseStatus(503, "Service Unavailable", true, true);
+  
+  public static final HttpResponseStatus GATEWAY_TIMEOUT
+    = new HttpResponseStatus(504, "Gateway Time-out", true, false);
+  
+  public static final HttpResponseStatus HTTP_VERSION_NOT_SUPPORTED
+    = new HttpResponseStatus(505, "HTTP Version not supported", true, false);
+  
+  
+  
+  private final int      code;
+  private final transient boolean  allowsMessageBody;
+  private final transient boolean  forcesConnectionClosure;
+  private final transient Category category;
+  private final transient String   description;
+  
+  /**
+   * @return  <code>true</code> iff a message body may be transmitted in
+   *          a response containing this response status
+   */
+  public boolean allowsMessageBody() {
+    return allowsMessageBody;  
+  }
+  
+  /** 
+   * @return  <code>true</code> iff a connection which would normally be
+   *          kept alive should be closed as a result of this response
+   */
+  public boolean forcesConnectionClosure() {
+    return forcesConnectionClosure;
+  }
+  
+  /**
+   * @return The response code of this status
+   */
+  public int getCode() {
+    return code;
+  }
+  
+  /**
+   * @return  The category of this status
+   */
+  public Category getCategory() {
+    return category;  
+  }
+  
+  /**
+   * @return A description of this status
+   */
+  public String getDescription() {
+    return description;
+  }
+  
+  /**
+   * A string description of this status
+   */
+  public String toString() {
+    return code + ": " + category + " - " + description;
+  }
+  
+  /**
+   * Returns the <code>ResponseStatus</code> with the specified
+   * status id.
+   * If no status exists with the specified id, a new status is created
+   * and registered based on the category applicable to the id:<br/>
+   * <table border="1">
+   *   <tr><td>100 - 199</td><td>Informational</td></tr>
+   *   <tr><td>200 - 299</td><td>Successful</td></tr>
+   *   <tr><td>300 - 399</td><td>Redirection</td></tr>
+   *   <tr><td>400 - 499</td><td>Client Error</td></tr>
+   *   <tr><td>500 - 599</td><td>Server Error</td></tr>
+   * <table>.
+   * 
+   * @param id  The id of the desired response status
+   * @return    The <code>ResponseStatus</code>
+   * @throws IllegalStateException  If the specified id is invalid
+   */
+  public static HttpResponseStatus forId(int id) {
+    if (id < MIN_ID || id > MAX_ID) {
+      throw new IllegalArgumentException("Illegal response id: " + id);
+    }
+    HttpResponseStatus status = RESPONSE_TABLE[id];
+    if (status == null) {
+      Category cat = categoryForId(id);
+      if (cat == null) {
+        throw new IllegalArgumentException("Illegal response id: " + id);
+      }
+      status = new HttpResponseStatus(id, cat.toString(), true, cat.isDefaultConnectionClosure());
+      RESPONSE_TABLE[id] = status;
+    } 
+    return status;
+  }
+  
+  /**
+   * Obtains the response category which covers the specified response 
+   * id
+   * 
+   * @param id  The id
+   * @return    The category - or <code>null</code> if no category covers
+   *            the specified response id
+   */
+  private static Category categoryForId(int id) {
+    int catId = id / 100;
+    switch (catId) {
+      case 1:
+        return Category.INFORMATIONAL;
+      case 2:
+        return Category.SUCCESSFUL;
+      case 3:
+        return Category.REDIRECTION;
+      case 4:
+        return Category.CLIENT_ERROR;
+      case 5:
+        return Category.SERVER_ERROR;
+      default:
+        return null;
+    }
+  }
+  
+  private HttpResponseStatus(int code, String description, 
+                         boolean allowsMessageBody, boolean forcesConnectionClosure) {
+    RESPONSE_TABLE[code] = this;
+    this.code = code;
+    this.category = categoryForId(code);
+    this.description = description;
+    this.allowsMessageBody = allowsMessageBody;
+    this.forcesConnectionClosure = forcesConnectionClosure;
+  }
+  
+  private Object readResolve() {
+    return forId(this.code);
+  }
+  
+  /**
+   * Category of response
+   * 
+   * @author irvingd
+   */
+  public static enum Category {
+      /**
+       * Indicates a provisional response
+       */
+      INFORMATIONAL,
+      
+      /**
+       * Indicates that the client's request was successfully received, 
+       * understood, and accepted
+       */
+      SUCCESSFUL,
+      
+      /**
+       * Indicates that further action needs to be taken by the user agent in order 
+       * to fulfill the request
+       */
+      REDIRECTION,
+      
+      /**
+       * Indicates that the client seems to have erred
+       */
+      CLIENT_ERROR,
+      
+      /**
+       * Indicate that the server is aware that it has erred or is incapable 
+       * of performing the request
+       */
+      SERVER_ERROR(true),
+      ;
+    
+    private boolean defaultConnectionClosure;
+    
+    private Category() {
+      this(false);
+    }
+    
+    private Category(boolean defaultConnectionClosure) {
+      this.defaultConnectionClosure = defaultConnectionClosure;
+    }
+    
+    public boolean isDefaultConnectionClosure() {
+      return defaultConnectionClosure;
+    }
+  }
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponseStatus.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpResponseStatus.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpVersion.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpVersion.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpVersion.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpVersion.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,86 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common;
+
+import java.io.InvalidObjectException;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
+
+/**
+ * Type safe enumeration representing HTTP protocol version
+ * 
+ * @author irvingd
+ *
+ */
+public class HttpVersion implements Serializable {
+
+  private static final long serialVersionUID = -7727691335746596528L;
+
+  /**
+   * HTTP 1/1
+   */
+  public static final HttpVersion HTTP_1_1 = new HttpVersion("HTTP/1.1");
+  
+  /**
+   * HTTP 1/0
+   */
+  public static final HttpVersion HTTP_1_0 = new HttpVersion("HTTP/1.0");
+  
+  private final String name;
+  
+  /**
+   * Returns the {@link HttpVersion} instance from the specified string.
+   * 
+   * @return       The version, or <code>null</code> if no version is
+   *               found
+   */
+  public static HttpVersion valueOf(String string) {
+    if (HTTP_1_1.toString().equalsIgnoreCase(string)) {
+      return HTTP_1_1;
+    }
+    
+    if (HTTP_1_0.toString().equalsIgnoreCase(string)) {
+      return HTTP_1_0;
+    }
+    
+    return null;
+  }
+  
+  /**
+   * @return A String representation of this version
+   */
+  public String toString() {
+    return name;
+  }
+    
+  private HttpVersion(String name) {
+    this.name = name;  
+  }
+  
+  private Object readResolve() throws ObjectStreamException {
+    HttpVersion answer = valueOf(this.name);
+    if (answer == null) {
+      throw new InvalidObjectException("Unknown HTTP version: " + this.name);
+    } else {
+      return answer;
+    }
+  }
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/HttpVersion.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableCookie.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableCookie.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableCookie.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableCookie.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,83 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common;
+
+/**
+ * A mutable {@link Cookie}.
+ * 
+ * @author trustin
+ * @version $Rev$, $Date$
+ */
+public interface MutableCookie extends Cookie {
+
+  /**
+   * Sets the value of this cookie
+   *
+   * @param value The cookie value
+   */
+  void setValue(String value);
+  
+  /**
+   * Sets the domain of this cookie.
+   */
+  void setDomain(String domain);
+  
+  /**
+   * Sets the path on the server to which the client returns this cookie.
+   * 
+   * @param path  The path
+   */
+  void setPath(String path);
+
+  /**
+   * Sets the version nubmer of this cookie
+   * 
+   * @param version  The version number
+   */
+  void setVersion(int version);
+
+  /**
+   * Sets whether this cookie should be marked as "secure".
+   * Secure cookies should be sent back by a client over a transport as least as
+   * secure as that upon which they were received
+   * 
+   * @param secure  <code>true</code> if this cookie should be marked as secure
+   */
+  void setSecure(boolean secure);
+
+  /**
+   * Sets the maximum age of the cookie in seconds.
+   * A positive value indicates that the cookie will expire after the specified number
+   * of seconds.
+   * <p>
+   * A value of zero indicates that the cookie should be deleted.
+   * <p>
+   * A negative value indicates that the cookie should be discarded at the end of the
+   * user session
+   * 
+   * @param expiry  The expiry time in seconds
+   */
+  void setMaxAge(int expiry);
+  
+  /**
+   * Sets the comment of this cookie.  Comments are not supported by version 0 cookies.
+   */
+  void setComment(String comment);
+}
\ No newline at end of file

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableCookie.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableCookie.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpMessage.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpMessage.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpMessage.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpMessage.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,113 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * A mutable {@link HttpMessage}.
+ * @author trustin
+ * @version $Rev$, $Date$
+ */
+public interface MutableHttpMessage extends HttpMessage {
+
+  /**
+   * Sets the version of the protocol associated with this request.
+   */
+  void setProtocolVersion(HttpVersion protocolVersion);
+  
+  /**
+   * Sets the <tt>Content-Type</tt> header of the response.
+   * 
+   * @param type The content type.
+   */
+  void setContentType(String type);
+  
+  /**
+   * Sets the <tt>Connection</tt> header of the response.
+   */
+  void setKeepAlive(boolean keepAlive);
+  
+  /**
+   * Adds an HTTP header to this response.
+   * Adding a header does not cause any existing headers with the
+   * same name to be overwritten
+   * 
+   * @param name   The header name
+   * @param value  The header value
+   */
+  void addHeader(String name, String value);
+  
+  /**
+   * Removes all HTTP headers with the specified name.
+   */
+  boolean removeHeader(String name);
+
+  /**
+   * Sets the value of an HTTP header.
+   * Any existing headers with the specified name are removed
+   * 
+   * @param name  The header name
+   * @param value The header value
+   */
+  void setHeader(String name, String value);
+
+  /**
+   * Sets the HTTP headers of this response.
+   */
+  void setHeaders(Map<String, List<String>> headers);
+  
+  /**
+   * Removes all HTTP headers from this response.
+   */
+  void clearHeaders();
+  
+  /**
+   * Adds the specified cookie.
+   */
+  void addCookie(Cookie cookie);
+  
+  /**
+   * Removed the specified cookie.
+   * 
+   * @return <tt>true</tt> if the specified cookie has been removed
+   */
+  boolean removeCookie(Cookie cookie);
+  
+  /**
+   * Sets the cookies of this message.
+   */
+  void setCookies(Collection<Cookie> cookies);
+  
+  /**
+   * Removed all cookies from this message.
+   */
+  void clearCookies();
+
+  /**
+   * Sets the content of the response body.
+   * 
+   * @param content <tt>null</tt> to clear the body content
+   */
+  void setContent(Content content);
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpMessage.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpRequest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpRequest.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpRequest.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpRequest.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,92 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A mutable {@link HttpRequest}.
+ * @author trustin
+ * @version $Rev$, $Date$
+ */
+public interface MutableHttpRequest extends MutableHttpMessage, HttpRequest {
+  
+  /**
+   * Sets the cookies of this message by parsing the specified <tt>headerValue</tt>.
+   */
+  void setCookies(String headerValue);
+
+  /**
+   * Adds a query parameter to this request.
+   * Adding a query parameter does not cause any existing parameters with the
+   * same name to be overwritten
+   * 
+   * @param name   The header name
+   * @param value  The header value
+   */
+  void addParameter(String name, String value);
+
+  /**
+   * Removes all query parameters with the specified name.
+   */
+  boolean removeParameter(String name);
+  
+  /**
+   * Sets the value of a query parameter.
+   * Any existing query parameters with the specified name are removed.
+   */
+  void setParameter(String name, String value);
+
+  /**
+   * Sets query parameters with the specified {@link Map} whose key is a {@link String} and
+   * whose value is a {@link List} of {@link String}s.
+   */
+  void setParameters(Map<String, List<String>> parameters);
+  
+  /**
+   * Sets query parameters from the specified <tt>queryString</tt> which is encoded with UTF-8
+   * encoding.
+   */
+  void setParameters(String queryString);
+  
+  /**
+   * Sets query parameters from the specified <tt>queryString</tt> which is encoded with the
+   * specified charset <tt>encoding</tt>.
+   */
+  void setParameters(String queryString, String encoding) throws UnsupportedEncodingException;
+  
+  /**
+   * Removes all query parameters from this request.
+   */
+  void clearParameters();
+  
+  /**
+   * Sets the {@link HttpMethod} associated with this request.
+   */
+  void setMethod(HttpMethod method);
+  
+  /**
+   * Sets the URI of the request.
+   */
+  void setRequestUri(URI requestUri);
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpRequest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpResponse.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpResponse.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpResponse.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpResponse.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,61 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common;
+
+/**
+ * A mutable {@link HttpResponse}
+ * @author trustin
+ * @version $Rev$, $Date$
+ */
+public interface MutableHttpResponse extends MutableHttpMessage, HttpResponse {
+
+  /**
+   * Adds the cookie of this message by parsing the specified <tt>headerValue</tt>.
+   */
+  void addCookie(String headerValue);
+  
+  /**
+   * Sets the status of this response
+   * 
+   * @param status  The response status
+   */
+  void setStatus(HttpResponseStatus status);
+
+  /**
+   * Sets the reason phrase which is associated with the current status of this response.
+   */
+  void setStatusReasonPhrase(String reasonPhrase);
+  
+  /**
+   * Normalizes this response to fix possible protocol violations.  The following is the
+   * normalization step:
+   * <ol>
+   * <li>Adds '<tt>Connection</tt>' header with an appropriate value determined from the specified
+   *     <tt>request</tt> and the status of this response.</li>
+   * <li>Adds '<tt>Data</tt>' header with current time.</li>
+   * <li>Remove body content if the {@link HttpMethod} of the specified <tt>request</tt> doesn't
+   *     allow body or the satus of this response doesn't allow body.</li>
+   * <li>Adds '<tt>Content-length</tt>' header if '<tt>Transfer-coding</tt>' header presents.</li>
+   * </ol>
+   * 
+   * @param request the request that pairs with this response
+   */
+  void normalize(HttpRequest request);
+}
\ No newline at end of file

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/MutableHttpResponse.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/ByteBufferContent.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/ByteBufferContent.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/ByteBufferContent.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/ByteBufferContent.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,52 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common.content;
+
+import org.apache.mina.common.ByteBuffer;
+import org.safehaus.asyncweb.common.Content;
+
+/**
+ * A {@link Content} which contains a byte array with offset and length parameter.
+ * 
+ * @author trustin
+ * @version $Rev$, $Date$
+ */
+public class ByteBufferContent implements Content {
+
+  private static final long serialVersionUID = -3456547908555235715L;
+  
+  private final ByteBuffer buffer;
+  
+  public ByteBufferContent(ByteBuffer buffer) {
+    if (buffer == null) {
+      throw new NullPointerException("buffer");
+    }
+    
+    this.buffer = buffer;
+  }
+  
+  public ByteBuffer getByteBuffer() {
+    return buffer.duplicate();
+  }
+  
+  public int size() {
+    return buffer.remaining();
+  }
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/ByteBufferContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/ByteBufferContent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/EmptyContent.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/EmptyContent.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/EmptyContent.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/EmptyContent.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,41 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.common.content;
+
+import org.safehaus.asyncweb.common.Content;
+
+/**
+ * An empty {@link Content} which contains no body.
+ * 
+ * @author trustin
+ * @version $Rev$, $Date$
+ */
+public class EmptyContent implements Content {
+
+  private static final long serialVersionUID = 2192619543978353683L;
+
+  /**
+   * A singleton instance.
+   */
+  public static final Content INSTANCE = new EmptyContent();
+  
+  private EmptyContent() {
+  }
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/EmptyContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/common/content/EmptyContent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/BasicServiceContainer.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/BasicServiceContainer.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/BasicServiceContainer.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/BasicServiceContainer.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,319 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.safehaus.asyncweb.service.context.BasicKeepAliveStrategy;
+import org.safehaus.asyncweb.service.context.CounterKeepAliveStrategy;
+import org.safehaus.asyncweb.service.context.KeepAliveStrategy;
+import org.safehaus.asyncweb.service.errorReporting.ErrorResponseFormatter;
+import org.safehaus.asyncweb.service.errorReporting.StandardResponseFormatter;
+import org.safehaus.asyncweb.service.session.DefaultSessionAccessor;
+import org.safehaus.asyncweb.service.session.HttpSessionAccessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Basic <code>ServiceContainer</code> implementation.
+ * 
+ * @author irvingd
+ * @author trustin
+ * 
+ * @version $Rev$, $Date$
+ */
+public class BasicServiceContainer implements ServiceContainer {
+
+  private static final Logger LOG = LoggerFactory.getLogger(BasicServiceContainer.class);
+  
+  /**
+   * The default number of keep-alive requests
+   */
+  private static final int DEFAULT_KEEP_ALIVE_REQUESTS = 75;
+  
+  /**
+   * Represents no limit on the number of keep-alive requests
+   */
+  private static final int INFINITE_KEEP_ALIVES = -1;
+  
+  private boolean isStarted;
+  private int maxKeepAlives = DEFAULT_KEEP_ALIVE_REQUESTS;
+  private KeepAliveStrategy keepAliveStrategy = new CounterKeepAliveStrategy(maxKeepAlives);
+  private HttpSessionAccessor sessionAccessor;
+  private ErrorResponseFormatter errorResponseFormatter = new StandardResponseFormatter();
+  private boolean sendServerHeader = true;
+
+  private List<HttpServiceFilter> filters   = new LinkedList<HttpServiceFilter>();
+  private List<Transport> transports = new LinkedList<Transport>();
+  
+  public boolean isSendServerHeader() {
+    return sendServerHeader;
+  }
+
+  public void setSendServerHeader(boolean sendServerHeader) {
+    this.sendServerHeader = sendServerHeader;
+  }
+
+  public ErrorResponseFormatter getErrorResponseFormatter() {
+    return errorResponseFormatter;
+  }
+
+  public void setErrorResponseFormatter(ErrorResponseFormatter errorResponseFormatter) {
+    if (errorResponseFormatter == null) {
+      throw new NullPointerException("errorResponseFormatter");
+    }
+    this.errorResponseFormatter = errorResponseFormatter;
+  }
+
+  public int getMaxKeepAlives() {
+    return maxKeepAlives;
+  }
+
+  /**
+   * Returns the employed {@link KeepAliveStrategy} of this container.
+   */
+  public KeepAliveStrategy getKeepAliveStrategy() {
+    return keepAliveStrategy;
+  }
+  
+  /**
+   * Sets the maximum number of keep-alive requests
+   * 
+   * @param maxKeepAlives  THe maximum number of keep alive requests
+   */
+  public void setMaxKeepAlives(int maxKeepAlives) {
+    if (maxKeepAlives < INFINITE_KEEP_ALIVES) {
+      throw new IllegalArgumentException("Invalid keep alives: " + maxKeepAlives);
+    }
+    this.maxKeepAlives = maxKeepAlives;  
+    if (maxKeepAlives == INFINITE_KEEP_ALIVES) {
+      LOG.info("Infinite keep-alives configured");
+    } else {
+      LOG.info("Max keep-alives configured: " + maxKeepAlives);
+    }
+    
+    keepAliveStrategy = maxKeepAlives == -1 ? new BasicKeepAliveStrategy() 
+                                            : new CounterKeepAliveStrategy(maxKeepAlives);  
+  }
+
+  /**
+   * Adds a <code>ServiceHandler</code> to this container
+   * 
+   * @param handler  The handler to add
+   * @throws IllegalStateException If this container has been started
+   */
+  public void addServiceFilter(HttpServiceFilter handler) {
+    if (isStarted) {
+      throw new IllegalStateException("Attempt to add filter to running container");
+    }
+    LOG.info("Adding service handler '" + handler + "'");
+    synchronized (filters) {
+      filters.add(handler);
+    }
+  }
+
+  /**
+   * Adds a <code>Transport</code> to this container
+   * 
+   * @param transport  The transport to add
+   * @throws IllegalStateException If this container has been started
+   */
+  public void addTransport(Transport transport) {
+    if (isStarted) {
+      throw new IllegalStateException("Attempt to add transport to running container");
+    }
+    LOG.info("Adding transport '" + transport + "'");
+    transport.setServiceContainer(this);
+    synchronized (transports) {
+      transports.add(transport);
+    }
+  }
+  
+  public List<HttpServiceFilter> getServiceFilters() {
+    return Collections.unmodifiableList(this.filters);
+  }
+  
+  /**
+   * Sets all <code>ServiceHandler</code>s employed by this container.
+   * Any existing handlers are removed
+   * 
+   * @param filters  A list of <code>ServiceHandler</code>s
+   * @throws IllegalStateException If this container has been started
+   */
+  public void setServiceFilters(List<HttpServiceFilter> filters) {
+    if (isStarted) {
+      throw new IllegalStateException("Attempt to add filter to running container");
+    }
+
+    synchronized (this.filters) {
+      this.filters.clear();
+
+      for (HttpServiceFilter filter: filters) {
+        addServiceFilter(filter);
+      }
+    }
+  }
+  
+  /**
+   * Sets all <code>Transport</code>s employed by this container.
+   * Any existing transport are removed
+   * 
+   * @param transports  A list of <code>Transport</code>s
+   * @throws IllegalStateException If this container has been started
+   */
+  public void setTransports(List<Transport> transports) {
+    if (isStarted) {
+      throw new IllegalStateException("Attempt to add transport to running container");
+    }
+
+    synchronized (this.transports) {
+      this.transports.clear();  
+    
+      for (Transport transport: transports) {
+        addTransport(transport);
+      }
+    }
+  }
+  
+  public HttpSessionAccessor getSessionAccessor() {
+    return this.sessionAccessor;
+  }
+
+  public void setSessionAccessor(HttpSessionAccessor sessionAccessor) {
+    if (sessionAccessor == null) {
+      throw new NullPointerException("sessionAccessor");
+    }
+    this.sessionAccessor = sessionAccessor;
+  }
+  
+  public void start() throws ContainerLifecycleException {
+    if (!isStarted) {
+      LOG.info("BasicServiceContainer starting");
+      startSessionAccessor();
+      startHandlers();
+      startTransports();
+      LOG.info("BasicServiceContainer started");
+      isStarted = true;
+    }
+  }
+  
+  public void stop() {
+    if (isStarted) {
+      isStarted = false;
+      LOG.info("BasicServiceContainer stopping");
+      stopHandlers();
+      stopTransports();
+      stopSessionAccessor();
+      LOG.info("BasicServiceContainer stopped");
+    }
+  }
+  
+  /**
+   * Starts our session accessor.
+   * If no session accessor has been configured, a default accessor is employed
+   */
+  private void startSessionAccessor() {
+    if (sessionAccessor == null) {
+      LOG.info("No SessionAccessor configured. Using default");
+      sessionAccessor = new DefaultSessionAccessor();
+    }
+    sessionAccessor.init();
+  }
+  
+  /**
+   * Starts all added handlers
+   */
+  private void startHandlers() {
+    LOG.info("Starting handlers");
+    synchronized (filters) {
+      for (Iterator iter=filters.iterator(); iter.hasNext(); ) {
+        HttpServiceFilter handler = (HttpServiceFilter) iter.next();
+        handler.start();
+      } 
+    }
+    LOG.info("Handlers started");
+  }
+  
+  private void stopHandlers() {
+    LOG.info("Stopping handlers");
+    synchronized (filters) {
+      for (Iterator iter=filters.iterator(); iter.hasNext(); ) {
+        HttpServiceFilter handler = (HttpServiceFilter) iter.next();
+        LOG.info("Stopping handler '" + handler + "'");
+        handler.stop();
+        LOG.info("Handler '" + handler + "' stopped");
+      }
+    }
+    LOG.info("Handlers stopped");
+  }
+  
+  private void stopSessionAccessor() {
+    LOG.info("Disposing session accessor");
+    sessionAccessor.dispose();
+    LOG.info("Session accessor disposed");
+  }
+  
+  /**
+   * Starts all added transports
+   * 
+   * @throws ContainerLifecycleException If we fail to start a transport
+   */
+  private void startTransports() throws ContainerLifecycleException {
+    LOG.info("Starting transports");
+    synchronized (transports) {
+      for (Iterator iter=transports.iterator(); iter.hasNext(); ) {
+        Transport transport = (Transport) iter.next();
+        LOG.info("Starting transport '" + transport + "'");
+        try {
+          transport.start();
+        } catch (TransportException e) {
+          LOG.info("Transport '" + transport + "' failed to start");
+          throw new ContainerLifecycleException("Failed to start transport ' " + 
+                                                transport + "'", e);
+        }
+      }
+    }
+    LOG.info("Transports started");
+  }
+  
+  private void stopTransports() {
+    LOG.info("Stopping transports");
+    boolean isError = false;
+    synchronized (transports) {
+      for (Iterator iter=transports.iterator(); iter.hasNext(); ) {
+        Transport transport = (Transport) iter.next();
+        LOG.info("Stopping transport '" + transport + "'");
+        try {
+          transport.stop();
+          LOG.info("Transport '" + transport + "' stopped");
+        } catch (TransportException e) {
+          LOG.warn("Failed to stop transport '" + transport + "'", e);
+          isError = true;
+        }
+      }
+    }
+    String errorString = isError ? " (One or more errors encountered)" : "";
+    LOG.info("Transports stopped" + errorString);
+  }
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/BasicServiceContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/BasicServiceContainer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ContainerLifecycleException.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ContainerLifecycleException.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ContainerLifecycleException.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ContainerLifecycleException.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,52 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+/**
+ * Exception thrown when a problem is encountered whilst transitioning
+ * a <code>ServiceContainer</code> through its lifecycle
+ * 
+ * @author irvingd
+ *
+ */
+public class ContainerLifecycleException extends Exception {
+
+  private static final long serialVersionUID = 3257564018624574256L;
+
+  /**
+   * Constructs with a description of the problem
+   * 
+   * @param desc  description of the problem
+   */
+  public ContainerLifecycleException(String desc) {
+    super (desc);
+  }
+  
+  /**
+   * Constructs with a description and a root cause
+   * 
+   * @param desc   description of the problem
+   * @param cause  the root cause
+   */
+  public ContainerLifecycleException(String desc, Throwable cause) {
+    super (desc, cause);
+  }
+  
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ContainerLifecycleException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ContainerLifecycleException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpService.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpService.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpService.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpService.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,37 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+
+/**
+ * An application-level HTTP request processor.
+ * 
+ * @author irvingd
+ *
+ */
+public interface HttpService {
+
+  public void handleRequest(HttpServiceContext context) throws Exception;
+  
+  public void start();
+  
+  public void stop();
+  
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceContext.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceContext.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceContext.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceContext.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,102 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+import java.net.InetSocketAddress;
+
+import org.safehaus.asyncweb.common.HttpRequest;
+import org.safehaus.asyncweb.common.HttpResponse;
+import org.safehaus.asyncweb.common.HttpResponseStatus;
+
+
+/**
+ * Provides conversational context between a HTTP client and a {@link HttpService}.
+ * 
+ * @author trustin
+ */
+public interface HttpServiceContext {
+  
+  /**
+   * Returns the socket address of the client (or last proxy).
+   */
+  InetSocketAddress getRemoteAddress();
+
+  /**
+   * Returns the request which is received from the client.
+   */
+  HttpRequest getRequest();
+  
+  /**
+   * Returns <tt>true</tt> if a response for the request is committed.
+   */
+  boolean isResponseCommitted();
+  
+  /**
+   * @return  The <code>Response</code> committed to this <code>Request</code>,
+   *          or <code>null</code> if no response has been comitted
+   */
+  HttpResponse getCommittedResponse();
+  
+  /**
+   * Writes the specified response back to the client.
+   * The response <i>must not</i> be modified after it has been
+   * submitted for comittment - irrespective of whether a commit
+   * is successful or not.
+   * <p>
+   * A request may have only one response committed to it. The return
+   * value of this method can be used to determine whether the
+   * supplied response will be used as the single response for this
+   * request.
+   * <p>
+   * Application code must not modify a response in any way after it
+   * has been committed to a request. The results of doing so are 
+   * undefined.
+   * 
+   * @param  response  The response to provide
+   * @return <code>true</code> if the response was accepted
+   */
+  boolean commitResponse(HttpResponse response);
+
+  /**
+   * Commits a default response with a specified {@link HttpResponseStatus}.
+   * 
+   * @return        <code>true</code> if the response was accepted
+   */
+  boolean commitResponse(HttpResponseStatus status);
+
+  /**
+   * Returns the {@link HttpSession} which is associated with the client.
+   * If no session is currently associated with the client, a new session is created.
+   * 
+   * @return  The session associated with the client
+   */
+  HttpSession getSession();
+  
+  /**
+   * Returns the <code>Session</code> associated with this request.
+   * 
+   * @param create  If <code>true</code>, a new session is created if no session is currently
+   *                associated with the client.
+   * @return        The {@link HttpSession}, or <code>null</code> if no session
+   *                is associated with the client and <code>create</code> is
+   *                <code>false</code>
+   */ 
+  HttpSession getSession(boolean create);
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceContext.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceFilter.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceFilter.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceFilter.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceFilter.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,67 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+
+public interface HttpServiceFilter {
+  
+  /**
+   * Notifies this handler of the incoming request for a specified request.
+   * 
+   * This handler should call <code>invokeNext</code> when it has completed
+   * its duties. This invocation may occur asyncronously - but <i>must</i>
+   * occur for each notification
+   * 
+   * @param next           The next filter in the filter chain
+   * @param context        The service context
+   */
+  void handleRequest(NextFilter next, HttpServiceContext context) throws Exception;
+
+  /**
+   * Notifies this handler of the committed response for a specified request.
+   * 
+   * This handler should call <code>invokeNext</code> when it has completed
+   * its duties. This invocation may occur asyncronously - but <i>must</i>
+   * occur for each notification
+   * 
+   * @param next           The next filter in the filter chain
+   * @param context        The service context
+   */
+  void handleResponse(NextFilter next, HttpServiceContext context) throws Exception;
+
+  void start();
+  
+  void stop();
+  
+  /**
+   * Encapsuates a location within a chain of tasks to be performed.
+   * 
+   * @author irvingd
+   * @author trustin
+   * @version $Rev$, $Date$
+   */
+  public interface NextFilter {
+
+    /**
+     * Causes the next task in the chain to be performed
+     */
+    void invoke();
+  }
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceFilter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceHandler.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceHandler.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceHandler.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceHandler.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,163 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.safehaus.asyncweb.common.DefaultHttpResponse;
+import org.safehaus.asyncweb.common.HttpRequest;
+import org.safehaus.asyncweb.common.HttpResponseStatus;
+import org.safehaus.asyncweb.common.MutableHttpResponse;
+import org.safehaus.asyncweb.service.resolver.ServiceResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A <code>ServiceHandler</code> which employs a <code>ServiceResolver</code>
+ * to map incoming requests to an <code>HttpService</code> which is
+ * then invoked.
+ * If an incoming request can not be mapped to an <code>HttpService</code>,
+ * a <code>404</code> response status is returned to the client
+ * 
+ * @author irvingd
+ *
+ */
+public class HttpServiceHandler implements HttpServiceFilter {
+
+  private static final Logger LOG = LoggerFactory.getLogger(HttpServiceHandler.class);
+  
+  private ServiceResolver resolver;
+  private Map<String, HttpService> serviceMap = new HashMap<String, HttpService>();
+  
+  /**
+   * Adds an <code>HttpService</code> against a service name.
+   * The service will be invoked this handlers associated 
+   * <code>ServiceResolver</code> resolves a request to the
+   * specified service name.<br/>
+   * 
+   * Any existing registration against the given name is overwritten.
+   * 
+   * @param name         The service name
+   * @param httpService  The service
+   */
+  public void addHttpService(String name, HttpService httpService) {
+    Object oldService = serviceMap.put(name, httpService);
+    if (oldService != null && LOG.isWarnEnabled()) {
+      LOG.warn("Duplicate mapping for '" + name + 
+               "'. Previous mapping removed");
+    }
+    LOG.info("New HttpService registered against key '" + name + "'");
+  }
+  
+  /**
+   * Associates this handler with the <code>ServiceResolver</code>
+   * it is to employ
+   * 
+   * @param resolver  The resolver to employ
+   */
+  public void setServiceResolver(ServiceResolver resolver) {
+    LOG.info("Associated with service resolver [ " + resolver + "]");
+    this.resolver = resolver;
+  }
+  
+  /**
+   * Attempts to resolve the specified request to an <code>HttpService</code>
+   * known to this handler by employing this handlers associated
+   * <code>ServiceResolver</code>.<br/>
+   * If an <code>HttpService</code> is located for the request, it is provided
+   * with the request. Otherwise, a <code>404</code> response is committed
+   * for the request
+   */
+  public void handleRequest(NextFilter next, HttpServiceContext context) throws Exception {
+    HttpService service = null;
+    HttpRequest request = context.getRequest();
+    String serviceName = resolver.resolveService(request);
+    if (serviceName != null) {
+      service = serviceMap.get(serviceName);
+    }
+    if (service == null) {
+      handleUnmappedRequest(context);
+    } else {
+      if (LOG.isInfoEnabled()) {
+        LOG.info("Mapped request [" + request.getRequestUri() + "] to " + 
+                 "service '" + serviceName + "'");
+      }
+      service.handleRequest(context);
+      next.invoke();
+    }
+  }
+  
+  /**
+   * Handles a response. This handler does not perform any
+   * action for responses - so the specified {@link NextFilter} is invoked immediately.
+   */
+  public void handleResponse(NextFilter next, HttpServiceContext context) {
+    next.invoke();
+  }
+  
+  /**
+   * Starts this handler.
+   */
+  public void start() {
+    LOG.info("HttpServiceHandler starting");
+    for (Iterator iter=serviceMap.entrySet().iterator(); iter.hasNext(); ) {
+      Map.Entry entry = (Map.Entry) iter.next();
+      String serviceName  = (String) entry.getKey();
+      HttpService service = (HttpService) entry.getValue();
+      LOG.info("Starting HttpService '" + serviceName + "'");
+      service.start();
+      LOG.info("HttpService '" + serviceName + "' started");
+    }
+  }
+  
+  /**
+   * Stops this handler
+   */
+  public void stop() {
+    LOG.info("HttpServiceHandler stopping");
+    for (Iterator iter=serviceMap.entrySet().iterator(); iter.hasNext(); ) {
+      Map.Entry entry = (Map.Entry) iter.next();
+      String serviceName  = (String) entry.getKey();
+      HttpService service = (HttpService) entry.getValue();
+      LOG.info("Stopping HttpService '" + serviceName + "'");
+      service.stop();
+      LOG.info("HttpService '" + serviceName + "' stopped");
+    }
+  }
+  
+  /**
+   * Handles an unmapped request by issuing a <code>404</code>
+   * response to the client
+   */
+  private void handleUnmappedRequest(HttpServiceContext context) {
+    HttpRequest request = context.getRequest();
+    if (LOG.isWarnEnabled()) {
+      LOG.warn("Failed to map '" + request.getRequestUri() + "' to " + 
+               "a resource");
+    }
+    MutableHttpResponse response = new DefaultHttpResponse();
+    response.setStatus(HttpResponseStatus.NOT_FOUND);
+    response.setStatusReasonPhrase(request.getRequestUri().toString());
+    context.commitResponse(response);
+  }
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpServiceHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpSession.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpSession.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpSession.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpSession.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,88 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+/**
+ * Provides a mechanism to store data across multiple requests from the same client.
+ * 
+ * @author irvingd
+ *
+ */
+public interface HttpSession {
+
+  /**
+   * @return  This sessions identifier
+   */
+  public String getId();
+  
+  /**
+   * Returns the value bound to this session with the specified key, if any.
+   * 
+   * @param key  The key for which the bound session value is required
+   * @return     The session value bound against the specified key, or <code>null</code>
+   *             if no such value exists
+   */
+  public Object getValue(String key);
+  
+  /**
+   * Binds a value against a specified key.
+   * Any value currently held for the given key is unbound.
+   * 
+   * @param key    The key against which the session value is to be bound
+   * @param value  The session value to bind
+   */
+  public void setValue(String key, Object value);
+  
+  /**
+   * Removes a session value from this session.
+   * If a value is currently bound against the specified key, it is unbound and
+   * returned. If no value is bound against the given key, this method returns
+   * <code>null</code>
+   * 
+   * @param  key  The key for which the existing binding - if any - is to be removed
+   * @return The removed value - or <code>null</code> if no value was bound against
+   *         the specified key
+   */
+  public Object removeValue(String key);
+  
+  /**
+   * Determines whether the client is aware of this session and has opted-in
+   * to using it.
+   * For newly created sessions, this method will always return <code>false</code>.
+   * 
+   * @return <code>true</code> if the client is aware of this session, and is using it
+   */
+  public boolean isAttached();
+  
+  /**
+   * Determines whether this session is valid for use.
+   * 
+   * @return  <code>true</code> if this session is neither destroyed nor timed out
+   */
+  public boolean isValid();
+  
+  /**
+   * Destroys this session, releasing any resources it may be consuming.
+   * Further client requests using the same session identifier will no longer
+   * be associated with this <code>Session</code>
+   */
+  public void destroy();
+  
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpSession.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/HttpSession.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ServiceContainer.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ServiceContainer.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ServiceContainer.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ServiceContainer.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,98 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+import java.util.List;
+
+import org.safehaus.asyncweb.service.context.KeepAliveStrategy;
+import org.safehaus.asyncweb.service.errorReporting.ErrorResponseFormatter;
+import org.safehaus.asyncweb.service.session.HttpSessionAccessor;
+
+
+public interface ServiceContainer {
+
+  /**
+   * Adds a {@link HttpServiceFilter} to this container.
+   * Requests dispatched to this container are run through filters
+   * in the order they are added
+   * 
+   * @param handler  The handler to add
+   * @throws IllegalStateException If this container has been started
+   */
+  void addServiceFilter(HttpServiceFilter handler);
+  
+  /**
+   * Adds a <code>Transport</code> to this container.
+   * The transport is provided with a <code></code>, and is started
+   * when this container starts
+   * 
+   * @param transport  The transport to add
+   * @throws IllegalStateException If this container has been started
+   */
+  void addTransport(Transport transport);
+  
+  /**
+   * Returns the read-only {@link List} of {@link HttpServiceFilter}s. 
+   */
+  List<HttpServiceFilter> getServiceFilters();
+  
+  /**
+   * Returns the employed {@link KeepAliveStrategy} of this container.
+   */
+  KeepAliveStrategy getKeepAliveStrategy();
+  
+  /**
+   * Returns the employes {@link HttpSessionAccessor} to be supplied to each request
+   * as it passes through the container.
+   * The accessor is shutdown when this container is stopped
+   */
+  HttpSessionAccessor getSessionAccessor();
+  
+  /**
+   * Sets the <code>SessionAccessor</code> to be supplied to each request
+   * as it passes through the container.
+   * The accessor is shutdown when this container is stopped
+   * 
+   * @param sessionAccessor  The accessor
+   */
+  void setSessionAccessor(HttpSessionAccessor accessor);
+  
+  ErrorResponseFormatter getErrorResponseFormatter();
+  
+  boolean isSendServerHeader();
+  
+  /**
+   * Starts this container.
+   * Requests may be dispatched to this container after it has been
+   * started.
+   * During start-up, this container starts all associated transports
+   * and service handlers.
+   * 
+   * @throws ContainerLifecycleException If a transport fails to start
+   */
+  void start() throws ContainerLifecycleException;
+  
+  /**
+   * Stops this container.
+   * During shut-down, this container stops all associated transports
+   * and service handlers.
+   */
+  void stop();
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ServiceContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/ServiceContainer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/Transport.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/Transport.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/Transport.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/Transport.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,58 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+
+/**
+ * A mechanism over which <code>Request</code>s are received.
+ * 
+ * @author irvingd
+ *
+ */
+public interface Transport {
+
+  /**
+   * Associates this <code>Transport</code> with its container.
+   * 
+   * @param container  The container to which incoming requests should
+   *                   be provided
+   */
+  public void setServiceContainer(ServiceContainer container);
+  
+  /**
+   * Starts this <code>Transport</code>.
+   * Once a <code>Transport</code> has been started, it may begin
+   * submitting <code>Request</code>s to its associated 
+   * <code>ServiceContainer</code>
+   * 
+   * @throws TransportException  If the transport can not be started
+   */
+  public void start() throws TransportException;
+  
+  /**
+   * Stops this <code>Transport</code>.
+   * No further requests should be sent to the transports associated
+   * <code>ServiceContainer</code>
+   * 
+   * @throws TransportException  If there were problems stopping the transport
+   */
+  public void stop() throws TransportException;
+  
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/Transport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/Transport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/TransportException.java
URL: http://svn.apache.org/viewvc/mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/TransportException.java?rev=587364&view=auto
==============================================================================
--- mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/TransportException.java (added)
+++ mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/TransportException.java Mon Oct 22 19:29:38 2007
@@ -0,0 +1,34 @@
+/*
+ *  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.
+ *
+ */
+package org.safehaus.asyncweb.service;
+
+public class TransportException extends Exception {
+
+  private static final long serialVersionUID = 3258132466186270517L;
+
+  public TransportException(String description) {
+    super(description);
+  }
+  
+  public TransportException(String description, Throwable cause) {
+    super(description, cause);
+  }
+  
+}

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/TransportException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: mina/sandbox/asyncweb/core/src/main/java/org/safehaus/asyncweb/service/TransportException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date