activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r520539 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/pojo/ camel-core/src...
Date Tue, 20 Mar 2007 19:52:39 GMT
Author: jstrachan
Date: Tue Mar 20 12:52:38 2007
New Revision: 520539

URL: http://svn.apache.org/viewvc?view=rev&rev=520539
Log:
some minor refactoring

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/pojo/PojoComponent.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Component.java Tue Mar
20 12:52:38 2007
@@ -24,9 +24,9 @@
 public interface Component<E>  {
 
     /**
-     * The CamelContainer is injected into the component when it is added to it
+     * The {@link CamelContext} is injected into the component when it is added to it
      */
-    void setContainer(CamelContext container);
+    void setContext(CamelContext context);
 
 	
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
Tue Mar 20 12:52:38 2007
@@ -144,4 +144,41 @@
             }
         };
     }
+
+    public static <E extends Exchange> Predicate<E> isNull(final Expression<E>
expression) {
+        notNull(expression, "expression");
+
+        return new Predicate<E>() {
+            public boolean evaluate(E exchange) {
+                Object value = expression.evaluate(exchange);
+                return value == null;
+            }
+        };
+    }
+
+    public static <E extends Exchange> Predicate<E> isNotNull(final Expression<E>
expression) {
+        notNull(expression, "expression");
+
+        return new Predicate<E>() {
+            public boolean evaluate(E exchange) {
+                Object value = expression.evaluate(exchange);
+                return value != null;
+            }
+        };
+    }
+
+    public static <E extends Exchange> Predicate<E> contains(final Expression<E>
left, final Expression<E> right) {
+        notNull(left, "left");
+        notNull(right, "right");
+
+        return new Predicate<E>() {
+            public boolean evaluate(E exchange) {
+                Object value1 = left.evaluate(exchange);
+                Object value2 = right.evaluate(exchange);
+                return ObjectHelper.contains(value1, value2);
+            }
+        };
+    }
+
+
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
Tue Mar 20 12:52:38 2007
@@ -66,6 +66,15 @@
         return PredicateBuilder.isInstanceOf(expression, type);
     }
 
+    public Predicate<E> isNull() {
+        return PredicateBuilder.isNull(expression);
+    }
+
+    public Predicate<E> isNotNull() {
+        return PredicateBuilder.isNotNull(expression);
+    }
+
+
     public Expression<E> getExpression() {
         return expression;
     }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Tue Mar 20 12:52:38 2007
@@ -54,6 +54,7 @@
             if( components.containsKey(componentName) ) {
             	throw new IllegalArgumentException("Component previously added: "+componentName);
             }
+            component.setContext(this);
             components.put(componentName, component);
         }
     }
@@ -93,7 +94,7 @@
                         throw new IllegalArgumentException("Factory failed to create the
" + componentName + " component, it returned null.");
                     }
                     components.put(componentName, component);
-                    component.setContainer(this);
+                    component.setContext(this);
                 }
                 catch (Exception e) {
                     throw new IllegalArgumentException("Factory failed to create the " +
componentName + " component", e);

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/pojo/PojoComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/pojo/PojoComponent.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/pojo/PojoComponent.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/pojo/PojoComponent.java
Tue Mar 20 12:52:38 2007
@@ -52,7 +52,7 @@
 	}
 	
 	
-	public void setContainer(CamelContext container) {
+	public void setContext(CamelContext container) {
 		this.container = container;
 	}
 	public CamelContext getContainer() {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
Tue Mar 20 12:52:38 2007
@@ -48,7 +48,7 @@
 
     public void onExchange(E exchange) {
         Object receipientList = expression.evaluate(exchange);
-        Iterator iter = ObjectHelper.createIterator(receipientList);
+        Iterator iter = ObjectHelper.iterator(receipientList);
         while (iter.hasNext()) {
             Object recipient = iter.next();
             Endpoint<E> endpoint = resolveEndpoint(exchange, recipient);

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
Tue Mar 20 12:52:38 2007
@@ -48,7 +48,7 @@
 
     public void onExchange(E exchange) {
         Object value = expression.evaluate(exchange);
-        Iterator iter = createIterator(value);
+        Iterator iter = iterator(value);
         while (iter.hasNext()) {
             Object part = iter.next();
             E newExchange = (E) exchange.copy();

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/queue/QueueComponent.java
Tue Mar 20 12:52:38 2007
@@ -35,7 +35,7 @@
     private HashMap<String, BlockingQueue<E>> registry = new HashMap<String,
BlockingQueue<E>>();
     private CamelContext container;
 
-    public void setContainer(CamelContext container) {
+    public void setContext(CamelContext container) {
         this.container = container;
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
Tue Mar 20 12:52:38 2007
@@ -20,7 +20,6 @@
 import java.util.Collection;
 import java.util.Arrays;
 import java.util.Collections;
-import java.lang.reflect.Array;
 
 /**
  * @version $Revision$
@@ -90,7 +89,7 @@
      * Creates an iterator over the value if the value is a collection, an Object[] or a
primitive type array; otherwise
      * to simplify the caller's code, we just create a singleton collection iterator over
a single value
      */
-    public static Iterator createIterator(Object value) {
+    public static Iterator iterator(Object value) {
         if (value == null) {
             return Collections.EMPTY_LIST.iterator();
         }
@@ -103,6 +102,25 @@
         }
         else {
             return Collections.singletonList(value).iterator();
+        }
+    }
+
+    /**
+     * Returns true if the collection contains the specified value
+     */
+    public static boolean contains(Object collectionOrArray, Object value) {
+        if (collectionOrArray instanceof Collection) {
+            Collection collection = (Collection) collectionOrArray;
+            return collection.contains(value);
+        }
+        else {
+            Iterator iter = iterator(value);
+            while (iter.hasNext()) {
+                if (equals(value, iter.next())) {
+                    return true;
+                }
+            }
+            return false;
         }
     }
 }

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java?view=diff&rev=520539&r1=520538&r2=520539
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java (original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java Tue
Mar 20 12:52:38 2007
@@ -140,7 +140,7 @@
         return container;
     }
 
-    public void setContainer(CamelContext container) {
+    public void setContext(CamelContext container) {
         this.container = container;
     }
 



Mime
View raw message