activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r521252 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
Date Thu, 22 Mar 2007 13:13:01 GMT
Author: jstrachan
Date: Thu Mar 22 06:12:59 2007
New Revision: 521252

URL: http://svn.apache.org/viewvc?view=rev&rev=521252
Log:
minor refactor to make it easier to create lazy-initialisation body messages

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java?view=diff&rev=521252&r1=521251&r2=521252
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
Thu Mar 22 06:12:59 2007
@@ -34,6 +34,9 @@
     private Object body;
 
     public Object getBody() {
+        if (body == null) {
+            body = createBody();
+        }
         return body;
     }
 
@@ -83,4 +86,13 @@
      */
     public abstract Message newInstance();
 
+
+    /**
+     * A factory method to allow a provider to lazily create the message body for inbound
messages from other sources
+     *
+     * @return the value of the message body or null if there is no value available
+     */
+    protected Object createBody() {
+        return null;
+    }
 }

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java?view=diff&rev=521252&r1=521251&r2=521252
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
Thu Mar 22 06:12:59 2007
@@ -43,16 +43,6 @@
     }
 
     @Override
-    public Object getBody() {
-        Object answer = super.getBody();
-        if (answer == null && jmsMessage != null) {
-            answer = getExchange().getBinding().extractBodyFromJms(getExchange(), jmsMessage);
-            setBody(answer);
-        }
-        return answer;
-    }
-
-    @Override
     public JmsExchange getExchange() {
         return (JmsExchange) super.getExchange();
     }
@@ -130,6 +120,14 @@
     @Override
     public JmsMessage newInstance() {
         return new JmsMessage();
+    }
+
+    @Override
+    protected Object createBody() {
+        if (jmsMessage != null) {
+            return  getExchange().getBinding().extractBodyFromJms(getExchange(), jmsMessage);
+        }
+        return null;
     }
 }
 



Mime
View raw message