abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eli...@apache.org
Subject svn commit: r415507 - in /incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server: ./ servlet/
Date Tue, 20 Jun 2006 05:30:23 GMT
Author: eliast
Date: Mon Jun 19 22:30:22 2006
New Revision: 415507

URL: http://svn.apache.org/viewvc?rev=415507&view=rev
Log:
- Making progress on Abdera server interfaces and scaffolding.
- Changed hasEntity to hasOutput in ResponseContext
- Make HandlerFactory pluggable
- Added getInputStream to RequestContext
- Added misc params/headers accessors to RequestContext
- Added getBaseUri to RequestContext

Modified:
    incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/AbderaServerException.java
    incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestContext.java
    incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestHandlerFactory.java
    incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/ResponseContext.java
    incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java
    incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java

Modified: incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/AbderaServerException.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/AbderaServerException.java?rev=415507&r1=415506&r2=415507&view=diff
==============================================================================
--- incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/AbderaServerException.java
(original)
+++ incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/AbderaServerException.java
Mon Jun 19 22:30:22 2006
@@ -67,7 +67,7 @@
     return null;
   }
 
-  public boolean hasEntity() {
+  public boolean hasOutput() {
     return false;
   }
 

Modified: incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestContext.java?rev=415507&r1=415506&r2=415507&view=diff
==============================================================================
--- incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestContext.java
(original)
+++ incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestContext.java
Mon Jun 19 22:30:22 2006
@@ -1,6 +1,9 @@
 package org.apache.abdera.server;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
+import java.util.List;
 
 public interface RequestContext {
 
@@ -8,10 +11,26 @@
     GET, POST, PUT, DELETE, OPTIONS, HEAD
   }
   
-  Method getMethod();
+  public Method getMethod();
   
-  URI getRequestUri();
+  public URI getRequestUri();
   
-  //TODO: finish
+  public URI getBaseUri();
+  
+  public URI getPathInfo();
+  
+  public String getParameter(String name);
+  
+  public List<String> getParameters(String name);
+
+  public List<String> getParameterNames();
+  
+  public String getHeader(String name);
+  
+  public List<String> getHeaders(String name);
+  
+  public List<String> getHeaderNames();
+  
+  public InputStream getInputStream() throws IOException;
   
 }

Modified: incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestHandlerFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestHandlerFactory.java?rev=415507&r1=415506&r2=415507&view=diff
==============================================================================
--- incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestHandlerFactory.java
(original)
+++ incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/RequestHandlerFactory.java
Mon Jun 19 22:30:22 2006
@@ -1,8 +1,13 @@
 package org.apache.abdera.server;
 
+import org.apache.abdera.util.ServiceUtil;
+
 public interface RequestHandlerFactory {
   
-  public static final RequestHandlerFactory INSTANCE = null;
+  public static final String HANDLER_FACTORY = "org.apache.abdera.server.RequestHandlerFactory";
+
+  public static final RequestHandlerFactory INSTANCE = (RequestHandlerFactory) 
+  	ServiceUtil.newInstance(HANDLER_FACTORY, "");
   
   RequestHandler newRequestHandler(
     RequestContext requestContext) 

Modified: incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/ResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/ResponseContext.java?rev=415507&r1=415506&r2=415507&view=diff
==============================================================================
--- incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/ResponseContext.java
(original)
+++ incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/ResponseContext.java
Mon Jun 19 22:30:22 2006
@@ -27,7 +27,7 @@
   
   CachePolicy getCachePolicy();
   
-  boolean hasEntity();
+  boolean hasOutput();
   
   void writeTo(OutputStream out) throws IOException;
   

Modified: incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java?rev=415507&r1=415506&r2=415507&view=diff
==============================================================================
--- incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java
(original)
+++ incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/AbderaServlet.java
Mon Jun 19 22:30:22 2006
@@ -65,7 +65,7 @@
       if (context.getLocation() != null)
         response.setHeader("Location", context.getLocation().toString());
       handleCachePolicy(response, context.getCachePolicy());
-      if (context.hasEntity())
+      if (context.hasOutput())
         context.writeTo(response.getOutputStream());
     } else {
       response.sendError(

Modified: incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java?rev=415507&r1=415506&r2=415507&view=diff
==============================================================================
--- incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java
(original)
+++ incubator/abdera/java/branches/snell_sandbox/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java
Mon Jun 19 22:30:22 2006
@@ -1,7 +1,13 @@
 package org.apache.abdera.server.servlet;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -19,7 +25,7 @@
   public Method getMethod() {
     return Method.valueOf(servletRequest.getMethod());
   }
-
+  
   public URI getRequestUri() {
     URI uri = null;
     try {
@@ -31,6 +37,58 @@
       uri = new URI(buf.toString());
     } catch (URISyntaxException e) {}
     return uri;
+  }
+  
+  public URI getBaseUri() {
+	// TODO: this should be done from properties
+	StringBuffer buffer = new StringBuffer("http://");
+	buffer.append(servletRequest.getServerName());
+	if (servletRequest.getLocalPort() != 80) {
+		buffer.append(":");
+		buffer.append(servletRequest.getLocalPort());
+	}
+	buffer.append(servletRequest.getServletPath());
+	try {
+		return new URI(buffer.toString());
+	} catch (URISyntaxException e) {
+		throw new RuntimeException(e);
+	}
+  }
+  
+  public String getHeader(String name) {
+	  return servletRequest.getHeader(name);
+  }
+
+  public List<String> getHeaders(String name) {
+	  return Collections.list(servletRequest.getHeaders(name));
+  }
+  
+  public List<String> getHeaderNames() {
+	  return Collections.list(servletRequest.getHeaderNames());
+  }
+  
+  public URI getPathInfo() {
+	try {
+		return new URI(servletRequest.getPathInfo());
+	} catch (URISyntaxException e) {
+		throw new RuntimeException(e);
+	}
+  }
+  
+  public String getParameter(String name) {
+	  return servletRequest.getParameter(name);
+  }
+  
+  public List<String> getParameters(String name) {
+	  return Arrays.asList(servletRequest.getParameterValues(name)); 
+  }
+  
+  public List<String> getParameterNames() {
+	  return Collections.list(servletRequest.getParameterNames());
+  }
+    
+  public InputStream getInputStream() throws IOException {
+	  return servletRequest.getInputStream();
   }
 
 }



Mime
View raw message