servicemix-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?view=rev&rev=465596
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/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
    incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
    incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java

Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java?view=diff&rev=465596&r1=465595&r2=465596
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
(original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
Thu Oct 19 05:12:08 2006
@@ -65,6 +65,67 @@
     protected HttpConfiguration configuration = new HttpConfiguration();
     protected HttpEndpoint[] endpoints;
     
+    protected String protocol;
+    protected String host;
+    protected int port = 80;
+    protected String path;
+    
+    /**
+     * @return the host
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * @param host the host to set
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    /**
+     * @return the path
+     */
+    public String getPath() {
+        return path;
+    }
+
+    /**
+     * @param path the path to set
+     */
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    /**
+     * @return the port
+     */
+    public int getPort() {
+        return port;
+    }
+
+    /**
+     * @param port the port to set
+     */
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    /**
+     * @return the protocol
+     */
+    public String getProtocol() {
+        return protocol;
+    }
+
+    /**
+     * @param protocol the protocol to set
+     */
+    public void setProtocol(String protocol) {
+        this.protocol = protocol;
+    }
+
     /**
      * @return the endpoints
      */
@@ -94,7 +155,7 @@
     public void setClient(HttpClient client) {
         this.client = client;
     }
-    
+
     /**
      * @return Returns the configuration.
      * @org.apache.xbean.Flat
@@ -181,11 +242,11 @@
         super.doStop();
         server.stop();
     }
-    
+
     protected QName getEPRServiceName() {
         return 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.

Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java?view=diff&rev=465596&r1=465595&r2=465596
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
(original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
Thu Oct 19 05:12:08 2006
@@ -58,7 +58,7 @@
     protected String authMethod;
     protected String soapAction;
     protected BasicAuthCredentials basicAuthentication;
-    
+
     /**
      * @return the soapAction
      */
@@ -117,22 +117,22 @@
         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"
@@ -142,6 +142,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
@@ -186,7 +192,7 @@
         }
         return portType;
     }
-    
+
     protected void overrideDefinition(Definition def) throws Exception {
         PortType portType = getTargetPortType(def);
         if (portType != null) {
@@ -210,8 +216,24 @@
             }
             HttpComponent comp = (HttpComponent) getServiceUnit().getComponent();
             if (comp.getConfiguration().isManaged()) {
-                // TODO: need to find the port of the web server
-                location = "http://localhost" + comp.getConfiguration().getMapping() + new
URI(location).getPath();
+                // Save the path
+                String path = new URI(location).getPath();
+                location = "http://localhost";
+                if (comp.getHost() != null) {
+                    if (comp.getProtocol() != null) {
+                        location = comp.getProtocol() + "://";
+                    } else {
+                        location = "http://";
+                    }
+                    location += comp.getHost();
+                    if (comp.getPort() != 80) {
+                        location += ":" + comp.getPort();
+                    }
+                    if (comp.getPath() != null) {
+                        location += comp.getPath();
+                    }
+                }
+                location += comp.getConfiguration().getMapping() + path;
             }
             if (portType.getQName().getNamespaceURI().equals(service.getNamespaceURI()))
{
                 if (isSoap()) {
@@ -254,7 +276,7 @@
             }
         }
     }
-    
+
     protected ExchangeProcessor createProviderProcessor() {
         return new ProviderProcessor(this);
     }

Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?view=diff&rev=465596&r1=465595&r2=465596
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
(original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
Thu Oct 19 05:12:08 2006
@@ -136,6 +136,17 @@
             if (path.lastIndexOf('/') >= 0) {
                 path = path.substring(path.lastIndexOf('/') + 1);
             }
+
+            // Set protocol, host, and port in the component
+            HttpComponent comp = (HttpComponent) endpoint.getServiceUnit().getComponent();
+            comp.setProtocol(request.getScheme());
+            comp.setHost(request.getServerName());
+            comp.setPort(request.getServerPort());
+            comp.setPath(request.getContextPath());
+
+            // Reload the wsdl
+            endpoint.reloadWsdl();
+
             Node node = (Node) endpoint.getWsdls().get(path);
             generateDocument(response, node);
             return;



Mime
View raw message