cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r523939 - in /incubator/cxf/trunk: integration/jbi/src/main/java/org/apache/cxf/jbi/transport/ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/transports/http/src/main/resour...
Date Fri, 30 Mar 2007 05:04:27 GMT
Author: jliu
Date: Thu Mar 29 22:04:25 2007
New Revision: 523939

URL: http://svn.apache.org/viewvc?view=rev&rev=523939
Log:
CXF-499: updated router interceptor to use local transport. The transport loaded by transportId
can be replaced by local transport when the publishing address is a local transport protocol,
eg: Endpoint.publish("local://SoapContext/version2/SoapPort", implementor2);

Modified:
    incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBITransportFactory.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
    incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-servlet.xml
    incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
    incubator/cxf/trunk/rt/transports/local/src/main/resources/META-INF/cxf/cxf-extension-local.xml
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/Server.java

Modified: incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBITransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBITransportFactory.java?view=diff&rev=523939&r1=523938&r2=523939
==============================================================================
--- incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBITransportFactory.java
(original)
+++ incubator/cxf/trunk/integration/jbi/src/main/java/org/apache/cxf/jbi/transport/JBITransportFactory.java
Thu Mar 29 22:04:25 2007
@@ -80,13 +80,13 @@
             return;
         }
         ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
-        if (null != cim) {
+        if (null != cim && null != activationNamespaces) {
             for (String ns : activationNamespaces) {
                 cim.registerConduitInitiator(ns, this);
             }
         }
         DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        if (null != dfm) {
+        if (null != dfm && null != activationNamespaces) {
             for (String ns : activationNamespaces) {
                 dfm.registerDestinationFactory(ns, this);
             }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java?view=diff&rev=523939&r1=523938&r2=523939
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java Thu
Mar 29 22:04:25 2007
@@ -54,9 +54,20 @@
         this.bus = bus;
 
         EndpointInfo ei = endpoint.getEndpointInfo();
+        
+        //Treat local transport as a special case, transports loaded by transportId can be
replaced
+        //by local transport when the publishing address is a local transport protocol. 
+        //Of course its not an ideal situation here to use a hard-coded prefix. To be refactored.
         if (destinationFactory == null) {
-            destinationFactory = bus.getExtension(DestinationFactoryManager.class)
-                .getDestinationFactory(ei.getTransportId());
+            if (ei.getAddress() != null && ei.getAddress().indexOf("local://") !=
-1) {
+                destinationFactory = bus.getExtension(DestinationFactoryManager.class)
+                    .getDestinationFactoryForUri(ei.getAddress());
+            }
+
+            if (destinationFactory == null) {
+                destinationFactory = bus.getExtension(DestinationFactoryManager.class)
+                    .getDestinationFactory(ei.getTransportId());
+            }
         }
             
         destination = destinationFactory.getDestination(ei);

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java?view=diff&rev=523939&r1=523938&r2=523939
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
Thu Mar 29 22:04:25 2007
@@ -90,13 +90,15 @@
             return;
         }
         ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
-        if (null != cim) {
+
+        //Note, activationNamespaces can be null
+        if (null != cim && null != activationNamespaces) {
             for (String ns : activationNamespaces) {
                 cim.registerConduitInitiator(ns, this);
             }
         }
         DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        if (null != dfm) {
+        if (null != dfm && null != activationNamespaces) {
             for (String ns : activationNamespaces) {
                 dfm.registerDestinationFactory(ns, this);
             }

Modified: incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-servlet.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-servlet.xml?view=diff&rev=523939&r1=523938&r2=523939
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-servlet.xml
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/resources/META-INF/cxf/cxf-servlet.xml
Thu Mar 29 22:04:25 2007
@@ -27,6 +27,7 @@
         <property name="bus" ref="cxf"/>
         <property name="transportIds">
             <set>
+                <value>http://cxf.apache.org/bindings/xformat</value>
                 <value>http://schemas.xmlsoap.org/soap/http</value>
                 <value>http://schemas.xmlsoap.org/wsdl/http/</value>
                 <value>http://schemas.xmlsoap.org/wsdl/soap/http</value>

Modified: incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java?view=diff&rev=523939&r1=523938&r2=523939
==============================================================================
--- incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
(original)
+++ incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
Thu Mar 29 22:04:25 2007
@@ -28,6 +28,9 @@
 import java.util.Set;
 import java.util.logging.Logger;
 
+import javax.annotation.Resource;
+
+import org.apache.cxf.Bus;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.AbstractTransportFactory;
 import org.apache.cxf.transport.Conduit;
@@ -52,15 +55,24 @@
     }
     
     private Map<String, Destination> destinations = new HashMap<String, Destination>();
-
-    
+    private Bus bus;
+     
     public LocalTransportFactory() {
         super();
         List<String> ids = new ArrayList<String>();
         ids.add(TRANSPORT_ID);
         setTransportIds(ids);
     }
+    
+    @Resource(name = "bus")
+    public void setBus(Bus b) {
+        bus = b;
+    }
 
+    public Bus getBus() {
+        return bus;
+    }
+    
     public Destination getDestination(EndpointInfo ei) throws IOException {
         return getDestination(ei, createReference(ei));
     }

Modified: incubator/cxf/trunk/rt/transports/local/src/main/resources/META-INF/cxf/cxf-extension-local.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/local/src/main/resources/META-INF/cxf/cxf-extension-local.xml?view=diff&rev=523939&r1=523938&r2=523939
==============================================================================
--- incubator/cxf/trunk/rt/transports/local/src/main/resources/META-INF/cxf/cxf-extension-local.xml
(original)
+++ incubator/cxf/trunk/rt/transports/local/src/main/resources/META-INF/cxf/cxf-extension-local.xml
Thu Mar 29 22:04:25 2007
@@ -24,6 +24,7 @@
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
     
     <bean class="org.apache.cxf.transport.local.LocalTransportFactory" lazy-init="true">
+        <property name="bus" ref="cxf"/>
         <property name="transportIds">
             <list>
                 <value>http://cxf.apache.org/transports/local</value>

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java?view=diff&rev=523939&r1=523938&r2=523939
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java
Thu Mar 29 22:04:25 2007
@@ -23,7 +23,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
-import java.util.logging.Logger;
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamConstants;
@@ -48,7 +47,6 @@
 
 
 public class MediatorInInterceptor extends AbstractPhaseInterceptor<SoapMessage> {
-    private static final Logger LOG = Logger.getLogger(MediatorInInterceptor.class.getName());
 
     public MediatorInInterceptor() {
         super();
@@ -57,25 +55,19 @@
     }
 
     public void handleMessage(SoapMessage message) {
-        if (isGET(message)) {
-            LOG.info("StaxInInterceptor skipped in HTTP GET method");
-            return;
-        }
-
         String schemaNamespace = "";
         InterceptorChain chain = message.getInterceptorChain();
 
+        //scan the incoming message for its schema namespace
         try {
-            //create a buffered stream so that we can roll back to original stream after
finishing scaning
+            //create a buffered stream so that we get back the original stream after scaning
             InputStream is = message.getContent(InputStream.class);
             BufferedInputStream pis = new BufferedInputStream(is);
             pis.mark(pis.available());
             message.setContent(InputStream.class, pis);
 
-            //TODO: need to process attachements
+            //TODO: process attachements
 
-            
-            //Scan the schema namespace, which is used to indicate the service version
             String encoding = (String)message.get(Message.ENCODING);
             XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(pis,
encoding);
             DepthXMLStreamReader xmlReader = new DepthXMLStreamReader(reader);
@@ -83,15 +75,14 @@
             if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
                 String ns = xmlReader.getNamespaceURI();
                 SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);
+                //advance just past header
                 StaxUtils.toNextTag(xmlReader, soapVersion.getBody());
-
-                // advance just past body.
+                //past body.
                 xmlReader.nextTag();
             }
 
             schemaNamespace = xmlReader.getName().getNamespaceURI();
 
-            //Roll back to the original inputStream
             pis.reset();
         } catch (IOException e) {
             e.printStackTrace();
@@ -99,27 +90,31 @@
             e.printStackTrace();
         }
 
+        //Look up for all available endpoints registered on the bus
         Bus bus = CXFBusFactory.getDefaultBus();
         ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
         List<Server> servers = serverRegistry.getServers();
 
+        //if the incoming message has a namespace contained "2007/03/21", we redirect the
message
+        //to the new version of service on endpoint "local://localhost:9027/SoapContext/version2/SoapPort"
         Server targetServer = null;
         for (Server server : servers) {
             targetServer = server;
             String address = server.getEndpoint().getEndpointInfo().getAddress();
             if (schemaNamespace.indexOf("2007/03/21") != -1) {
-                if (address.indexOf("SoapContext2") != -1) {
+                if (address.indexOf("version2") != -1) {
                     break;
                 }
-            } else if (address.indexOf("SoapContext1") != -1) {
+            } else if (address.indexOf("version1") != -1) {
                 break;
             }
         }
 
         //Redirect the request
-        MessageObserver ob = targetServer.getMessageObserver();
-        ob.onMessage(message);
+        MessageObserver mo = targetServer.getMessageObserver();
+        mo.onMessage(message);
 
+        //Now the response has been put in the message, abort the chain 
         chain.abort();
     }
 

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/Server.java?view=diff&rev=523939&r1=523938&r2=523939
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/Server.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/versioning/Server.java
Thu Mar 29 22:04:25 2007
@@ -29,12 +29,13 @@
 public class Server extends AbstractBusTestServerBase {
 
     protected void run() {
+        //implementor1 and implementor2 are published using local transport
         Object implementor1 = new GreeterImplMixedStyle();
-        String address1 = "http://localhost:9027/SoapContext1/SoapPort";
+        String address1 = "local://SoapContext/version1/SoapPort";
         Endpoint.publish(address1, implementor1);
 
         Object implementor2 = new GreeterImplMixedStyle();
-        String address2 = "http://localhost:9027/SoapContext2/SoapPort";
+        String address2 = "local://SoapContext/version2/SoapPort";
         Endpoint.publish(address2, implementor2);
         
         //A dummy service that acts as a routing mediator



Mime
View raw message