geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r702838 - in /geronimo/plugins/tuscany/trunk: geronimo-tuscany-http-jetty/src/main/java/org/apache/geronimo/tuscany/http/jetty/ geronimo-tuscany-http-tomcat/src/main/java/org/apache/geronimo/tuscany/http/tomcat/
Date Wed, 08 Oct 2008 12:31:33 GMT
Author: vamsic007
Date: Wed Oct  8 05:31:32 2008
New Revision: 702838

URL: http://svn.apache.org/viewvc?rev=702838&view=rev
Log:
GERONIMO-4343 Tuscany Geronimo plugin bring up
 o Applied GeronimoServletHost2.diff patch submitted to JIRA
 o Thanks Ant Elder for providing the patch.

Modified:
    geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-jetty/src/main/java/org/apache/geronimo/tuscany/http/jetty/GeronimoServletHost.java
    geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-tomcat/src/main/java/org/apache/geronimo/tuscany/http/tomcat/GeronimoServletHost.java

Modified: geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-jetty/src/main/java/org/apache/geronimo/tuscany/http/jetty/GeronimoServletHost.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-jetty/src/main/java/org/apache/geronimo/tuscany/http/jetty/GeronimoServletHost.java?rev=702838&r1=702837&r2=702838&view=diff
==============================================================================
--- geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-jetty/src/main/java/org/apache/geronimo/tuscany/http/jetty/GeronimoServletHost.java
(original)
+++ geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-jetty/src/main/java/org/apache/geronimo/tuscany/http/jetty/GeronimoServletHost.java
Wed Oct  8 05:31:32 2008
@@ -18,8 +18,11 @@
  */
 package org.apache.geronimo.tuscany.http.jetty;
 
+import java.net.InetAddress;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -54,6 +57,7 @@
 import org.apache.geronimo.transaction.GeronimoUserTransaction;
 import org.apache.tuscany.sca.host.http.DefaultResourceServlet;
 import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletMappingException;
 import org.mortbay.jetty.security.SecurityHandler;
 import org.mortbay.jetty.servlet.DefaultServlet;
 import org.mortbay.jetty.servlet.ServletHandler;
@@ -358,9 +362,44 @@
 		return 0;
 	}
 
-	public URL getURLMapping(String arg0) {
-		// TODO Auto-generated method stub
-		return null;
+	public URL getURLMapping(String suri) {
+        URI uri = URI.create(suri);
+
+        // Get the URI scheme and port
+        String scheme = uri.getScheme();
+        if (scheme == null) {
+            scheme = "http";
+        }
+        int portNumber = uri.getPort();
+        if (portNumber == -1) {
+            portNumber = 8080;
+        }
+
+        // Get the host
+        String host;
+        try {
+            host = InetAddress.getLocalHost().getHostName();
+        } catch (UnknownHostException e) {
+            host = "localhost";
+        }
+
+        // Construct the URL
+        String path = uri.getPath();
+        if (!path.startsWith("/")) {
+            path = '/' + path;
+        }
+
+//        if (contextPath != null && !path.startsWith(contextPath)) {
+//            path = contextPath + path;
+//        }
+
+        URL url;
+        try {
+            url = new URL(scheme, host, portNumber, path);
+        } catch (MalformedURLException e) {
+            throw new ServletMappingException(e);
+        }
+        return url;
 	}
 
 	public void setContextPath(String arg0) {

Modified: geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-tomcat/src/main/java/org/apache/geronimo/tuscany/http/tomcat/GeronimoServletHost.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-tomcat/src/main/java/org/apache/geronimo/tuscany/http/tomcat/GeronimoServletHost.java?rev=702838&r1=702837&r2=702838&view=diff
==============================================================================
--- geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-tomcat/src/main/java/org/apache/geronimo/tuscany/http/tomcat/GeronimoServletHost.java
(original)
+++ geronimo/plugins/tuscany/trunk/geronimo-tuscany-http-tomcat/src/main/java/org/apache/geronimo/tuscany/http/tomcat/GeronimoServletHost.java
Wed Oct  8 05:31:32 2008
@@ -19,8 +19,11 @@
 package org.apache.geronimo.tuscany.http.tomcat;
 
 import java.io.File;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.net.UnknownHostException;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.Servlet;
@@ -45,6 +48,7 @@
 import org.apache.geronimo.tomcat.TomcatWebContainer;
 import org.apache.tuscany.sca.host.http.DefaultResourceServlet;
 import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletMappingException;
 
 
 /**
@@ -135,7 +139,7 @@
         }
         
         context = (StandardContext)((StandardHost)host).map(contextPath);
-        if(context.getName().equals("")) {
+        if(context == null || context.getName().equals("")) {
             context = new StandardContext();
             context.setDocBase(docext + contextPath);
             context.setJ2EEApplication(JMX_APP_NAME); // FIXME: Different name
@@ -232,9 +236,44 @@
 		return 0;
 	}
 
-	public URL getURLMapping(String arg0) {
-		// TODO Auto-generated method stub
-		return null;
+	public URL getURLMapping(String suri) {
+        URI uri = URI.create(suri);
+
+        // Get the URI scheme and port
+        String scheme = uri.getScheme();
+        if (scheme == null) {
+            scheme = "http";
+        }
+        int portNumber = uri.getPort();
+        if (portNumber == -1) {
+            portNumber = 8080;
+        }
+
+        // Get the host
+        String host;
+        try {
+            host = InetAddress.getLocalHost().getHostName();
+        } catch (UnknownHostException e) {
+            host = "localhost";
+        }
+
+        // Construct the URL
+        String path = uri.getPath();
+        if (!path.startsWith("/")) {
+            path = '/' + path;
+        }
+
+//        if (contextPath != null && !path.startsWith(contextPath)) {
+//            path = contextPath + path;
+//        }
+
+        URL url;
+        try {
+            url = new URL(scheme, host, portNumber, path);
+        } catch (MalformedURLException e) {
+            throw new ServletMappingException(e);
+        }
+        return url;
 	}
 
 	public void setContextPath(String arg0) {



Mime
View raw message