servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r515699 - in /incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi: messaging/ servicedesc/
Date Wed, 07 Mar 2007 19:09:10 GMT
Author: gnodet
Date: Wed Mar  7 11:09:09 2007
New Revision: 515699

URL: http://svn.apache.org/viewvc?view=rev&rev=515699
Log:
SM-871: Several small optimizations

Modified:
    incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
    incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java
    incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/AbstractServiceEndpoint.java
    incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/DynamicEndpoint.java
    incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java
    incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/ExternalEndpoint.java
    incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java
    incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/LinkedEndpoint.java

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?view=diff&rev=515699&r1=515698&r2=515699
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
(original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
Wed Mar  7 11:09:09 2007
@@ -450,7 +450,7 @@
         messageExchange.setProperty(JbiConstants.SEND_SYNC, Boolean.TRUE);
         // Call doSend
         MessageExchangeImpl me = (MessageExchangeImpl) messageExchange;
-        String exchangeKey = getKeyForExchange(me);
+        String exchangeKey = me.getKey();
         try {
             exchangesById.put(exchangeKey, me);
             // Synchronously send a message and wait for the response
@@ -545,7 +545,7 @@
         // Check if the delivery channel has been closed
         checkNotClosed();
         // Retrieve the original exchange sent
-        MessageExchangeImpl original = (MessageExchangeImpl) exchangesById.get(getKeyForExchange(me));
+        MessageExchangeImpl original = (MessageExchangeImpl) exchangesById.get(me.getKey());
         if (original != null && me != original) {
             original.copyFrom(me);
             me = original;
@@ -775,8 +775,5 @@
     public String toString() {
         return "DeliveryChannel{" + component.getName() + "}";
     }
-    
-    private String getKeyForExchange(MessageExchangeImpl me) {
-        return (me.getRole() == Role.CONSUMER ? "consumer:" : "provider:") + me.getExchangeId();
-    }
+
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java?view=diff&rev=515699&r1=515698&r2=515699
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java
(original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/MessageExchangeImpl.java
Wed Mar  7 11:09:09 2007
@@ -106,6 +106,7 @@
     protected MessageExchangeImpl mirror;
     protected transient boolean pushDeliver;
     protected transient Object txLock;
+    protected transient String key;
 
     /**
      * Constructor
@@ -302,8 +303,7 @@
         if (name == null) {
             throw new IllegalArgumentException("name should not be null");
         }
-        name = name.toLowerCase();
-        if (IN.equals(name)) {
+        if (IN.equalsIgnoreCase(name)) {
             if (!can(CAN_SET_IN_MSG)) {
                 throw new MessagingException("In not supported");
             }
@@ -312,7 +312,7 @@
             }
             ((NormalizedMessageImpl) message).exchange = this;
             packet.setIn((NormalizedMessageImpl) message);
-        } else if (OUT.equals(name)) {
+        } else if (OUT.equalsIgnoreCase(name)) {
             if (!can(CAN_SET_OUT_MSG)) {
                 throw new MessagingException("Out not supported");
             }
@@ -321,7 +321,7 @@
             }
             ((NormalizedMessageImpl) message).exchange = this;
             packet.setOut((NormalizedMessageImpl) message);
-        } else if (FAULT.equals(name)) {
+        } else if (FAULT.equalsIgnoreCase(name)) {
             if (!can(CAN_SET_FAULT_MSG)) {
                 throw new MessagingException("Fault not supported");
             }
@@ -742,4 +742,19 @@
         }
     }
 
+    /**
+     * Compute a unique key for this exchange proxy.
+     * It has to be different for the two sides of the exchange, so
+     * we include the role + the exchange id.
+     * Obviously, it works, because the role never change for
+     * a given proxy.
+     * 
+     * @return
+     */
+    public String getKey() {
+        if (key == null) {
+            key = (getRole() == Role.CONSUMER ? "consumer" : "provider") + ":" + getExchangeId();
+        }
+        return key;
+    }
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/AbstractServiceEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/AbstractServiceEndpoint.java?view=diff&rev=515699&r1=515698&r2=515699
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/AbstractServiceEndpoint.java
(original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/AbstractServiceEndpoint.java
Wed Mar  7 11:09:09 2007
@@ -25,6 +25,8 @@
 public abstract class AbstractServiceEndpoint implements ServiceEndpoint, Serializable {
 
     private ComponentNameSpace componentName;
+    private String key;
+    private String uniqueKey;
     
     public AbstractServiceEndpoint(ComponentNameSpace componentName) {
         this.componentName = componentName;
@@ -45,4 +47,19 @@
         this.componentName = componentName;
     }
 
+    public String getKey() {
+        if (key == null) {
+            key = EndpointSupport.getKey(getServiceName(), getEndpointName());
+        }
+        return key;
+    }
+
+    public String getUniqueKey() {
+        if (uniqueKey == null) {
+            uniqueKey = getClassifier() + ":" + getKey();
+        }
+        return uniqueKey;
+    }
+
+    protected abstract String getClassifier();
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/DynamicEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/DynamicEndpoint.java?view=diff&rev=515699&r1=515698&r2=515699
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/DynamicEndpoint.java
(original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/DynamicEndpoint.java
Wed Mar  7 11:09:09 2007
@@ -73,4 +73,8 @@
         return serviceName;
     }
 
+    protected String getClassifier() {
+        return "dynamic";
+    }
+
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java?view=diff&rev=515699&r1=515698&r2=515699
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java
(original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/EndpointSupport.java
Wed Mar  7 11:09:09 2007
@@ -34,21 +34,17 @@
     }
     
     public static String getKey(ServiceEndpoint endpoint) {
+        if (endpoint instanceof AbstractServiceEndpoint) {
+            return ((AbstractServiceEndpoint) endpoint).getKey();
+        }
         return getKey(endpoint.getServiceName(), endpoint.getEndpointName());
     }
     
     public static String getUniqueKey(ServiceEndpoint endpoint) {
-        if (endpoint instanceof InternalEndpoint) {
-            return "internal:" + getKey(endpoint);
-        } else if (endpoint instanceof ExternalEndpoint) {
-            return "external:" + getKey(endpoint);
-        } else if (endpoint instanceof DynamicEndpoint) {
-            return "dynamic:" + getKey(endpoint);
-        } else if (endpoint instanceof LinkedEndpoint) {
-            return "linked:" + getKey(endpoint);
-        } else {
-            return endpoint.getClass().getName() + ":" + getKey(endpoint);
+        if (endpoint instanceof AbstractServiceEndpoint) {
+            return ((AbstractServiceEndpoint) endpoint).getUniqueKey();
         }
+        return endpoint.getClass().getName() + ":" + getKey(endpoint);
     }
     
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/ExternalEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/ExternalEndpoint.java?view=diff&rev=515699&r1=515698&r2=515699
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/ExternalEndpoint.java
(original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/ExternalEndpoint.java
Wed Mar  7 11:09:09 2007
@@ -71,4 +71,8 @@
         return se.getServiceName();
     }
 
+    protected String getClassifier() {
+        return "external";
+    }
+
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java?view=diff&rev=515699&r1=515698&r2=515699
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java
(original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/InternalEndpoint.java
Wed Mar  7 11:09:09 2007
@@ -168,4 +168,9 @@
     public String toString() {
         return "ServiceEndpoint[service=" + serviceName + ",endpoint=" + endpointName + "]";
     }
+
+    protected String getClassifier() {
+        return "internal";
+    }
+
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/LinkedEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/LinkedEndpoint.java?view=diff&rev=515699&r1=515698&r2=515699
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/LinkedEndpoint.java
(original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/servicedesc/LinkedEndpoint.java
Wed Mar  7 11:09:09 2007
@@ -102,4 +102,8 @@
         return toService;
     }
 
+    protected String getClassifier() {
+        return "linked";
+    }
+
 }



Mime
View raw message