Author: gnodet
Date: Wed Mar  7 12:54:12 2007
New Revision: 515748

URL: http://svn.apache.org/viewvc?view=rev&rev=515748
Log:
SM-871: optimize wsdl-first example

Added:
    
incubator/servicemix/branches/servicemix-3.1/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/marshalers/SoapReaderTest.java
      - copied unchanged from r515740, 
incubator/servicemix/trunk/common/servicemix-soap/src/test/java/org/apache/servicemix/soap/marshalers/SoapReaderTest.java
Modified:
    
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
    
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java
    
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java
    
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java
    
incubator/servicemix/branches/servicemix-3.1/common/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java
    
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java

Modified: 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?view=diff&rev=515748&r1=515747&r2=515748
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
 Wed Mar  7 12:54:12 2007
@@ -473,9 +473,9 @@
     private void doProcess(Endpoint ep, ExchangeProcessor processor, 
MessageExchange exchange) throws Exception {
         ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
         try {
-            if (ep != null && 
ep.getServiceUnit().getConfigurationClassLoader() != null) {
-                ClassLoader classLoader = 
ep.getServiceUnit().getConfigurationClassLoader();
-                Thread.currentThread().setContextClassLoader(classLoader);
+            ClassLoader cl = (ep != null) ? 
ep.getServiceUnit().getConfigurationClassLoader() : null;
+            if (cl != null) {
+                Thread.currentThread().setContextClassLoader(cl);
             }
             // Read the correlation id from the exchange and set it in the 
correlation id property
             String correlationID = 
(String)exchange.getProperty(JbiConstants.CORRELATION_ID);

Modified: 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java?view=diff&rev=515748&r1=515747&r2=515748
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/Endpoint.java
 Wed Mar  7 12:54:12 2007
@@ -34,6 +34,7 @@
     protected Definition definition;
     protected ServiceUnit serviceUnit;
     protected Log logger;
+    private String key;
     
     public Endpoint() {
     }
@@ -56,6 +57,7 @@
      */
     public void setEndpoint(String endpoint) {
         this.endpoint = endpoint;
+        this.key = null;
     }
     /**
      * @return Returns the service.
@@ -68,6 +70,7 @@
      */
     public void setService(QName service) {
         this.service = service;
+        this.key = null;
     }
     /**
      * @return Returns the role.
@@ -143,6 +146,19 @@
 
     public void setDefinition(Definition definition) {
         this.definition = definition;
+    }
+    
+    String getKey() {
+        if (key == null) {
+            if (service == null) {
+                throw new IllegalArgumentException("Endpoint: " + this + " has 
no service name defined");
+            }
+            if (endpoint == null) {
+                throw new IllegalArgumentException("Endpoint: " + this + " has 
no endpoint name defined");
+            }
+            key = EndpointSupport.getKey(service, endpoint);
+        }
+        return key;
     }
 
 }

Modified: 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java?view=diff&rev=515748&r1=515747&r2=515748
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/EndpointSupport.java
 Wed Mar  7 12:54:12 2007
@@ -27,27 +27,11 @@
     }
     
     public static String getKey(ServiceEndpoint endpoint) {
-        QName serviceName = endpoint.getServiceName();
-        if (serviceName == null) {
-            throw new IllegalArgumentException("Endpoint: " + endpoint + " has 
no serviceName defined");
-        }
-        String endpointName = endpoint.getEndpointName();
-        if (endpointName == null) {
-            throw new IllegalArgumentException("Endpoint: " + endpoint + " has 
no endpointName defined");
-        }
-        return getKey(serviceName, endpointName);
+        return 
org.apache.servicemix.jbi.servicedesc.EndpointSupport.getKey(endpoint);
     }
     
     public static String getKey(Endpoint endpoint) {
-        QName serviceName = endpoint.getService();
-        if (serviceName == null) {
-            throw new IllegalArgumentException("Endpoint: " + endpoint + " has 
no service name defined");
-        }
-        String endpointName = endpoint.getEndpoint();
-        if (endpointName == null) {
-            throw new IllegalArgumentException("Endpoint: " + endpoint + " has 
no endpoint name defined");
-        }
-        return getKey(serviceName, endpointName);
+        return endpoint.getKey();
     }
     
 }

Modified: 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java?view=diff&rev=515748&r1=515747&r2=515748
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/XBeanServiceUnit.java
 Wed Mar  7 12:54:12 2007
@@ -28,6 +28,7 @@
 
     private Kernel kernel;
     private ServiceName configuration;
+    private ClassLoader classLoader;
 
     /**
      * @return Returns the kernel.
@@ -56,21 +57,22 @@
      */
     public void shutDown() throws JBIException {
         super.shutDown();
+        classLoader = null;
         if (kernel != null) {
             kernel.destroy();
         }
     }
     
     public ClassLoader getConfigurationClassLoader() {
-        ClassLoader cl = null;
-        if (kernel != null) {
+        if (classLoader == null && kernel != null && configuration != null) {
             try {
                 ServiceFactory sf = kernel.getServiceFactory(configuration);
-                cl = sf.getClassLoader();
+                classLoader = sf.getClassLoader();
             } catch (ServiceNotFoundException e) {
                 // This should never happen
             }
-        } 
+        }
+        ClassLoader cl = classLoader;
         if (cl == null) {
             cl = Thread.currentThread().getContextClassLoader();
         }

Modified: 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/common/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java?view=diff&rev=515748&r1=515747&r2=515748
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.1/common/servicemix-soap/src/main/java/org/apache/servicemix/soap/marshalers/SoapReader.java
 Wed Mar  7 12:54:12 2007
@@ -63,7 +63,7 @@
 
        public SoapMessage read(InputStream is, String contentType)
                        throws Exception {
-               if (contentType != null && 
contentType.toLowerCase().startsWith(SoapMarshaler.MULTIPART_CONTENT)) {
+               if (contentType != null && 
startsWithCaseInsensitive(contentType, SoapMarshaler.MULTIPART_CONTENT)) {
                        Session session = Session.getDefaultInstance(new 
Properties());
             is = new SequenceInputStream(new ByteArrayInputStream(new byte[] { 
13, 10 }), is);
                        MimeMessage mime = new MimeMessage(session, is);
@@ -73,6 +73,10 @@
                        return read(is);
                }
        }
+    
+    static boolean startsWithCaseInsensitive(String s1, String s2) {
+        return s1.regionMatches(true, 0, s2, 0, s2.length());
+    }
 
        public SoapMessage read(InputStream is) throws Exception {
                if (marshaler.isSoap()) {

Modified: 
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java?view=diff&rev=515748&r1=515747&r2=515748
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java
 Wed Mar  7 12:54:12 2007
@@ -753,7 +753,7 @@
      */
     public String getKey() {
         if (key == null) {
-            key = (getRole() == Role.CONSUMER ? "consumer" : "provider") + ":" 
+ getExchangeId();
+            key = (getRole() == Role.CONSUMER ? "consumer:" : "provider:") + 
getExchangeId();
         }
         return key;
     }


Reply via email to