Author: jsdelfino
Date: Wed Aug 15 16:09:54 2007
New Revision: 566392
URL: http://svn.apache.org/viewvc?view=rev&rev=566392
Log:
Fixed HTTP embedded hosts to support null URI schemes and URI paths that do not
start with a '/'.
Modified:
incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
Modified:
incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java?view=diff&rev=566392&r1=566391&r2=566392
==============================================================================
---
incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
(original)
+++
incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
Wed Aug 15 16:09:54 2007
@@ -136,7 +136,11 @@
public void addServletMapping(String uriStr, Servlet servlet) throws
ServletMappingException {
URI uri = URI.create(uriStr);
- // Get the URI port
+ // Get the URI scheme and port
+ String scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
int portNumber = uri.getPort();
if (portNumber == -1) {
portNumber = DEFAULT_PORT;
@@ -150,7 +154,7 @@
try {
Server server = new Server();
server.setThreadPool(new WorkSchedulerThreadPool());
- if ("https".equals(uri.getScheme())) {
+ if ("https".equals(scheme)) {
Connector httpConnector = new SelectChannelConnector();
httpConnector.setPort(portNumber);
SslSocketConnector sslConnector = new SslSocketConnector();
@@ -213,10 +217,13 @@
ServletMapping mapping = new ServletMapping();
mapping.setServletName(holder.getName());
String path = uri.getPath();
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
mapping.setPathSpec(path);
servletHandler.addServletMapping(mapping);
- URI addedURI = URI.create(uri.getScheme() + "://localhost:" +
portNumber + path);
+ URI addedURI = URI.create(scheme + "://localhost:" + portNumber +
path);
System.out.println("Added Servlet mapping: " + addedURI);
}
Modified:
incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java?view=diff&rev=566392&r1=566391&r2=566392
==============================================================================
---
incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
(original)
+++
incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
Wed Aug 15 16:09:54 2007
@@ -116,7 +116,11 @@
public void addServletMapping(String strURI, Servlet servlet) {
URI uri = URI.create(strURI);
- // Get the URI port
+ // Get the URI scheme and port
+ String scheme = uri.getScheme();
+ if (scheme == null) {
+ scheme = "http";
+ }
int portNumber = uri.getPort();
if (portNumber == -1) {
portNumber = DEFAULT_PORT;
@@ -165,32 +169,35 @@
}
// Register the servlet mapping
+ String path = uri.getPath();
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
ServletWrapper wrapper;
if (servlet instanceof DefaultResourceServlet) {
// Optimize the handling of resource requests, use the Tomcat
default servlet
// instead of our default resource servlet
- String servletPath = uri.getPath();
- if (servletPath.endsWith("*")) {
- servletPath = servletPath.substring(0, servletPath.length()-1);
+ if (path.endsWith("*")) {
+ path = path.substring(0, path.length()-1);
}
- if (servletPath.endsWith("/")) {
- servletPath = servletPath.substring(0, servletPath.length()-1);
+ if (path.endsWith("/")) {
+ path = path.substring(0, path.length()-1);
}
DefaultResourceServlet resourceServlet =
(DefaultResourceServlet)servlet;
- TomcatDefaultServlet defaultServlet = new
TomcatDefaultServlet(servletPath, resourceServlet.getDocumentRoot());
+ TomcatDefaultServlet defaultServlet = new
TomcatDefaultServlet(path, resourceServlet.getDocumentRoot());
wrapper = new ServletWrapper(defaultServlet);
} else {
wrapper = new ServletWrapper(servlet);
}
- String mapping = uri.getPath();
- Context context = port.getHost().map(mapping);
- wrapper.setName(mapping);
- wrapper.addMapping(mapping);
+ Context context = port.getHost().map(path);
+ wrapper.setName(path);
+ wrapper.addMapping(path);
context.addChild(wrapper);
- context.addServletMapping(mapping, mapping);
- port.getConnector().getMapper().addWrapper("localhost", "", mapping,
wrapper);
+ context.addServletMapping(path, path);
+ port.getConnector().getMapper().addWrapper("localhost", "", path,
wrapper);
// Initialize the servlet
try {
@@ -199,7 +206,7 @@
throw new ServletMappingException(e);
}
- URI addedURI = URI.create(uri.getScheme() + "://localhost:" +
portNumber + mapping);
+ URI addedURI = URI.create(scheme + "://localhost:" + portNumber +
path);
System.out.println("Added Servlet mapping: " + addedURI);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]