servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r465597 - in /incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http: HttpEndpoint.java HttpLifeCycle.java processors/ConsumerProcessor.java
Date Thu, 19 Oct 2006 12:12:09 GMT
Author: gnodet
Date: Thu Oct 19 05:12:09 2006
New Revision: 465597

URL: http://svn.apache.org/viewvc?view=rev&rev=465597
Log:
SM-604: Allow servicemix-http managed mode to dynamically determine the server, port, and
context path it is running on when generating jsr181 WSDLs
Patch provided by Jeff Puro, thx !

Modified:
    incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
    incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpLifeCycle.java
    incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java

Modified: incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java?view=diff&rev=465597&r1=465596&r2=465597
==============================================================================
--- incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
(original)
+++ incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
Thu Oct 19 05:12:09 2006
@@ -55,7 +55,7 @@
     protected String authMethod;
     protected String soapAction;
     protected BasicAuthCredentials basicAuthentication;
-    
+
     /**
      * @return the soapAction
      */
@@ -114,23 +114,23 @@
         this.locationURI = locationUri;
     }
 
-	/**
+    /**
      * Authentication parameters used for provider endpoints using BASIC 
      * authentication.
      * 
-	 * @return Returns the basicAuthentication.
-	 */
-	public BasicAuthCredentials getBasicAuthentication() {
-		return basicAuthentication;
-	}
-
-	/**
-	 * @param basicAuthentication The basicAuthentication to set.
-	 */
-	public void setBasicAuthentication(BasicAuthCredentials basicAuthCredentials) {
-		this.basicAuthentication = basicAuthCredentials;
-	}
-	
+     * @return Returns the basicAuthentication.
+     */
+    public BasicAuthCredentials getBasicAuthentication() {
+        return basicAuthentication;
+    }
+
+    /**
+     * @param basicAuthentication The basicAuthentication to set.
+     */
+    public void setBasicAuthentication(BasicAuthCredentials basicAuthCredentials) {
+        this.basicAuthentication = basicAuthCredentials;
+    }
+
     /**
      * @org.apache.xbean.Property alias="role"
      * @param role
@@ -139,6 +139,12 @@
         super.setRoleAsString(role);
     }
 
+    public void reloadWsdl() {
+        description = null;
+        definition = null;
+        loadWsdl();
+    }
+
     protected PortType getTargetPortType(Definition def) {
         PortType portType = null;
         // If the WSDL description only contain one PortType, use it
@@ -183,7 +189,7 @@
         }
         return portType;
     }
-    
+
     protected void overrideDefinition(Definition def) throws Exception {
         PortType portType = getTargetPortType(def);
         if (portType != null) {
@@ -207,8 +213,24 @@
             }
             HttpLifeCycle lf = (HttpLifeCycle) getServiceUnit().getComponent().getLifeCycle();
             if (lf.getConfiguration().isManaged()) {
-                // TODO: need to find the port of the web server
-                location = "http://localhost" + lf.getConfiguration().getMapping() + new
URI(location).getPath();
+                // Save the path
+                String path = new URI(location).getPath();
+                location = "http://localhost";
+                if (lf.getHost() != null) {
+                    if (lf.getProtocol() != null) {
+                        location = lf.getProtocol() + "://";
+                    } else {
+                        location = "http://";
+                    }
+                    location += lf.getHost();
+                    if (lf.getPort() != 80) {
+                        location += ":" + lf.getPort();
+                    }
+                    if (lf.getPath() != null) {
+                        location += lf.getPath();
+                    }
+                }
+                location += lf.getConfiguration().getMapping() + path;
             }
             if (portType.getQName().getNamespaceURI().equals(service.getNamespaceURI()))
{
                 if (isSoap()) {
@@ -251,7 +273,7 @@
             }
         }
     }
-    
+
     protected ExchangeProcessor createProviderProcessor() {
         return new ProviderProcessor(this);
     }
@@ -273,7 +295,5 @@
         ComponentLifeCycle lf = getServiceUnit().getComponent().getLifeCycle();
         return ((HttpLifeCycle) lf).getKeystoreManager();
     }
-
-
 
 }

Modified: incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpLifeCycle.java?view=diff&rev=465597&r1=465596&r2=465597
==============================================================================
--- incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpLifeCycle.java
(original)
+++ incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/HttpLifeCycle.java
Thu Oct 19 05:12:09 2006
@@ -43,7 +43,11 @@
     protected HttpClient client;
     protected MultiThreadedHttpConnectionManager connectionManager;
     protected HttpConfiguration configuration = new HttpConfiguration();
-    
+    protected String protocol;
+    protected String host;
+    protected int port = 80;
+    protected String path;
+
     public HttpLifeCycle(BaseComponent component) {
         super(component);
     }
@@ -63,7 +67,7 @@
     public void setClient(HttpClient client) {
         this.client = client;
     }
-    
+
     /**
      * @return Returns the configuration.
      */
@@ -148,11 +152,11 @@
         super.doStop();
         server.stop();
     }
-    
+
     protected QName getEPRServiceName() {
         return HttpResolvedEndpoint.EPR_SERVICE;
     }
-    
+
     protected Endpoint getResolvedEPR(ServiceEndpoint ep) throws Exception {
         // We receive an exchange for an EPR that has not been used yet.
         // Register a provider endpoint and restart processing.
@@ -209,6 +213,38 @@
      */
     public HttpProcessor getMainProcessor() {
         return server.getMainProcessor();
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public String getProtocol() {
+        return protocol;
+    }
+
+    public void setProtocol(String protocol) {
+        this.protocol = protocol;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
     }
 
 }

Modified: incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?view=diff&rev=465597&r1=465596&r2=465597
==============================================================================
--- incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
(original)
+++ incubator/servicemix/branches/servicemix-3.0/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
Thu Oct 19 05:12:09 2006
@@ -134,6 +134,17 @@
             if (path.lastIndexOf('/') >= 0) {
                 path = path.substring(path.lastIndexOf('/') + 1);
             }
+
+            // Set protocol, host, and port in the lifecycle object
+            HttpLifeCycle lf = (HttpLifeCycle) endpoint.getServiceUnit().getComponent().getLifeCycle();
+            lf.setProtocol(request.getProtocol());
+            lf.setHost(request.getServerName());
+            lf.setPort(request.getServerPort());
+            lf.setPath(request.getContextPath());
+
+            // Regenerate the wsdl
+            endpoint.reloadWsdl();
+
             Node node = (Node) endpoint.getWsdls().get(path);
             generateDocument(response, node);
             return;



Mime
View raw message