camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r561947 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/processor/ components/camel-spring/src/main/java/org/apache/camel/component/bean/ components/camel-spring/src/main/java...
Date Wed, 01 Aug 2007 20:55:25 GMT
Author: jstrachan
Date: Wed Aug  1 13:55:13 2007
New Revision: 561947

URL: http://svn.apache.org/viewvc?view=rev&rev=561947
Log:
unified the bean <-> camel binding code with the bean component; making both sets of code more flexible while reusing more code too. Added some improved exceptions together with more javadoc and test cases

Added:
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/AmbiguousMethodCallException.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanInfo.java   (contents, props changed)
      - copied, changed from r561075, activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/BeanInfo.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanProcessor.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/MethodInfo.java   (contents, props changed)
      - copied, changed from r561075, activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/MethodInfo.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/ParameterInfo.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/package.html
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/converter/package.html
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/package.html
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/package.html
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/processor/package.html
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/package.html
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/package.html
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/BeanRouteTest.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/ExampleBean.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanAsEndpointTest.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanInfoTest.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ExampleBean.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorAsEndpointTest.java
      - copied, changed from r561666, activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorAsEndpointTest.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorStub.java
      - copied, changed from r561666, activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorStub.java
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/bean/
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/bean/camelContext.xml
      - copied, changed from r561075, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/event/camelContext.xml
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/beanAsEndpoint.xml
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/processorAsEndpoint.xml
      - copied, changed from r561666, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpoint/processorAsEndpoint.xml
Removed:
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/BeanInfo.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/MethodInfo.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorAsEndpointTest.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorStub.java
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpoint/processorAsEndpoint.xml
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/bean/BeanComponent.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java?view=diff&rev=561947&r1=561946&r2=561947
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelTemplate.java Wed Aug  1 13:55:13 2007
@@ -274,6 +274,13 @@
     }
 
     protected Object extractResultBody(E result) {
-        return result != null ? result.getOut().getBody() : null;
+        Object answer = null;
+        if (result != null) {
+            answer = result.getOut().getBody();
+            if (answer == null) {
+                answer = result.getIn().getBody();
+            }
+        }
+        return answer;
     }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java?view=diff&rev=561947&r1=561946&r2=561947
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java Wed Aug  1 13:55:13 2007
@@ -156,7 +156,6 @@
 
     protected void doStop() throws Exception {
         ServiceHelper.stopServices(consumer, processor);
-        consumer = null;
         collection.clear();
     }
 

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/bean/BeanComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/bean/BeanComponent.java?view=diff&rev=561947&r1=561946&r2=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/bean/BeanComponent.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/bean/BeanComponent.java Wed Aug  1 13:55:13 2007
@@ -18,8 +18,17 @@
 package org.apache.camel.component.bean;
 
 import org.apache.camel.Endpoint;
+import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.ProcessorEndpoint;
+import org.apache.camel.spring.bind.BeanProcessor;
+import org.apache.camel.spring.util.MethodInvocationStrategy;
+import org.apache.camel.spring.util.DefaultMethodInvocationStrategy;
+import org.apache.camel.spring.SpringCamelContext;
 import static org.apache.camel.util.ObjectHelper.notNull;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
@@ -34,7 +43,9 @@
  * @version $Revision: 1.1 $
  */
 public class BeanComponent extends DefaultComponent implements ApplicationContextAware {
+    private static final Log log = LogFactory.getLog(BeanComponent.class);
     private ApplicationContext applicationContext;
+    private MethodInvocationStrategy invocationStrategy;
 
     public BeanComponent() {
     }
@@ -51,8 +62,37 @@
         this.applicationContext = applicationContext;
     }
 
+    public MethodInvocationStrategy getInvocationStrategy() {
+        if (invocationStrategy == null) {
+            invocationStrategy = createInvocationStrategy();
+        }
+        return invocationStrategy;
+    }
+
+    public void setInvocationStrategy(MethodInvocationStrategy invocationStrategy) {
+        this.invocationStrategy = invocationStrategy;
+    }
+
+    // Implementation methods
+    //-----------------------------------------------------------------------
+
     protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
         notNull(applicationContext, "applicationContext");
-        return new BeanEndpoint(uri, this, remaining);
+        Object bean = applicationContext.getBean(remaining);
+        BeanProcessor processor = new BeanProcessor(bean, getInvocationStrategy());
+        IntrospectionSupport.setProperties(processor, parameters);
+        return new ProcessorEndpoint(uri, this, processor);
+        //return new BeanEndpoint(uri, this, remaining);
+    }
+
+    protected MethodInvocationStrategy createInvocationStrategy() {
+        CamelContext context = getCamelContext();
+        if (context instanceof SpringCamelContext) {
+            SpringCamelContext springCamelContext = (SpringCamelContext) context;
+            return springCamelContext.getInvocationStrategy();
+        }
+        else {
+            log.warn("Not using a SpringCamelContext so using the default MethodInvocationStrategy");
+        return new DefaultMethodInvocationStrategy();}
     }
 }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java?view=diff&rev=561947&r1=561946&r2=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java Wed Aug  1 13:55:13 2007
@@ -17,22 +17,20 @@
  */
 package org.apache.camel.spring;
 
-import org.aopalliance.intercept.MethodInvocation;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.CamelTemplate;
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
 import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
 import org.apache.camel.MessageDriven;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.spring.util.BeanInfo;
 import org.apache.camel.spring.util.DefaultMethodInvocationStrategy;
 import org.apache.camel.spring.util.MethodInvocationStrategy;
 import org.apache.camel.spring.util.ReflectionUtils;
+import org.apache.camel.spring.bind.BeanProcessor;
 import org.apache.camel.util.ObjectHelper;
 import static org.apache.camel.util.ObjectHelper.isNotNullAndNonEmpty;
 import org.apache.commons.logging.Log;
@@ -61,11 +59,9 @@
 public class CamelBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware {
     private static final transient Log log = LogFactory.getLog(CamelBeanPostProcessor.class);
     @XmlTransient
-    private CamelContext camelContext;
+    private SpringCamelContext camelContext;
     @XmlTransient
     private ApplicationContext applicationContext;
-    @XmlTransient
-    private MethodInvocationStrategy invocationStrategy = new DefaultMethodInvocationStrategy();
     //private List<Consumer> consumers = new ArrayList<Consumer>();
 
     public CamelBeanPostProcessor() {
@@ -97,19 +93,11 @@
         this.applicationContext = applicationContext;
     }
 
-    public MethodInvocationStrategy getInvocationStrategy() {
-        return invocationStrategy;
-    }
-
-    public void setInvocationStrategy(MethodInvocationStrategy invocationStrategy) {
-        this.invocationStrategy = invocationStrategy;
-    }
-
-    public CamelContext getCamelContext() {
+    public SpringCamelContext getCamelContext() {
         return camelContext;
     }
 
-    public void setCamelContext(CamelContext camelContext) {
+    public void setCamelContext(SpringCamelContext camelContext) {
         this.camelContext = camelContext;
     }
 
@@ -219,33 +207,9 @@
      * Create a processor which invokes the given method when an incoming message exchange is received
      */
     protected Processor createConsumerProcessor(final Object pojo, final Method method, final Endpoint endpoint) {
-        final BeanInfo beanInfo = new BeanInfo(pojo.getClass(), invocationStrategy);
-
-        return new Processor() {
-            @Override
-            public String toString() {
-                return "Processor on " + endpoint;
-            }
-
-            public void process(Exchange exchange) throws Exception {
-                if (log.isDebugEnabled()) {
-                    log.debug(">>>> invoking method for: " + exchange);
-                }
-                MethodInvocation invocation = beanInfo.createInvocation(method, pojo, exchange);
-                if (invocation == null) {
-                    throw new IllegalStateException("No method invocation could be created");
-                }
-                try {
-                    invocation.proceed();
-                }
-                catch (Exception e) {
-                    throw e;
-                }
-                catch (Throwable throwable) {
-                    throw new Exception(throwable);
-                }
-            }
-        };
+        BeanProcessor answer = new BeanProcessor(pojo, getCamelContext().getInvocationStrategy());
+        answer.setMethod(method);
+        return answer;
     }
 
     protected void addConsumer(Consumer consumer) {
@@ -295,4 +259,5 @@
         }
         return endpoint;
     }
+
 }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?view=diff&rev=561947&r1=561946&r2=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java Wed Aug  1 13:55:13 2007
@@ -28,9 +28,12 @@
 import org.apache.camel.spi.ComponentResolver;
 import org.apache.camel.spi.Injector;
 import org.apache.camel.spi.Registry;
+import org.apache.camel.spring.bind.BeanProcessor;
+import org.apache.camel.spring.spi.ApplicationContextRegistry;
 import org.apache.camel.spring.spi.SpringComponentResolver;
 import org.apache.camel.spring.spi.SpringInjector;
-import org.apache.camel.spring.spi.ApplicationContextRegistry;
+import org.apache.camel.spring.util.DefaultMethodInvocationStrategy;
+import org.apache.camel.spring.util.MethodInvocationStrategy;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.BeansException;
@@ -56,6 +59,7 @@
     private static final transient Log log = LogFactory.getLog(SpringCamelContext.class);
     private ApplicationContext applicationContext;
     private EventEndpoint eventEndpoint;
+    private MethodInvocationStrategy invocationStrategy = new DefaultMethodInvocationStrategy();
 
     public SpringCamelContext() {
     }
@@ -97,6 +101,9 @@
         }
     }
 
+    // Properties
+    //-----------------------------------------------------------------------
+
     public ApplicationContext getApplicationContext() {
         return applicationContext;
     }
@@ -118,6 +125,17 @@
         this.eventEndpoint = eventEndpoint;
     }
 
+    public MethodInvocationStrategy getInvocationStrategy() {
+        return invocationStrategy;
+    }
+
+    public void setInvocationStrategy(MethodInvocationStrategy invocationStrategy) {
+        this.invocationStrategy = invocationStrategy;
+    }
+
+    // Implementation methods
+    //-----------------------------------------------------------------------
+
     @Override
     protected void doStart() throws Exception {
         super.doStart();
@@ -142,6 +160,10 @@
         return endpoint;
     }
 
+    protected Endpoint convertBeanToEndpoint(String uri, Object bean) {
+        Processor processor = new BeanProcessor(bean, getInvocationStrategy());
+        return new ProcessorEndpoint(uri, this, processor);
+    }
 
     @Override
     protected Registry createRegistry() {

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/AmbiguousMethodCallException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/AmbiguousMethodCallException.java?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/AmbiguousMethodCallException.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/AmbiguousMethodCallException.java Wed Aug  1 13:55:13 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.bind;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.CamelExchangeException;
+
+import java.util.List;
+
+/**
+ * An exception thrown if an attempted method invocation resulted in an ambiguous method
+ * such that multiple methods match the inbound message exchange
+ * 
+ * @version $Revision: $
+ */
+public class AmbiguousMethodCallException extends CamelExchangeException {
+    private final List<MethodInfo> methods;
+
+    public AmbiguousMethodCallException(Exchange exchange, List<MethodInfo> methods) {
+        super("Ambiguous method invocations possible: " + methods, exchange);
+        this.methods = methods;
+    }
+
+    /**
+     * The ambiguous methods for which a single method could not be chosen
+     */
+    public List<MethodInfo> getMethods() {
+        return methods;
+    }
+}

Copied: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanInfo.java (from r561075, activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/BeanInfo.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanInfo.java?view=diff&rev=561947&p1=activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/BeanInfo.java&r1=561075&p2=activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanInfo.java&r2=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/BeanInfo.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanInfo.java Wed Aug  1 13:55:13 2007
@@ -14,24 +14,30 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.util;
+package org.apache.camel.spring.bind;
 
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.camel.Body;
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Header;
+import org.apache.camel.Message;
 import org.apache.camel.Property;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.spring.util.MethodInvocationStrategy;
+import static org.apache.camel.util.ExchangeHelper.convertToType;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.util.Arrays;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
+import java.util.Arrays;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -45,45 +51,48 @@
     private Class type;
     private MethodInvocationStrategy strategy;
     private Map<String, MethodInfo> operations = new ConcurrentHashMap<String, MethodInfo>();
-    private MethodInfo defaultExpression;
+    private MethodInfo defaultMethod;
+    private List<MethodInfo> operationsWithBody = new ArrayList<MethodInfo>();
 
     public BeanInfo(Class type, MethodInvocationStrategy strategy) {
         this.type = type;
         this.strategy = strategy;
-    }
-
-    public Class getType() {
-        return type;
-    }
-
-    public void introspect() {
         introspect(getType());
         if (operations.size() == 1) {
             Collection<MethodInfo> methodInfos = operations.values();
             for (MethodInfo methodInfo : methodInfos) {
-                defaultExpression = methodInfo;
+                defaultMethod = methodInfo;
             }
         }
     }
+    public Class getType() {
+        return type;
+    }
 
-    public MethodInvocation createInvocation(Method method, Object pojo, Exchange messageExchange) throws RuntimeCamelException {
+    public MethodInvocation createInvocation(Method method, Object pojo, Exchange exchange) throws RuntimeCamelException {
         MethodInfo methodInfo = introspect(type, method);
-        return methodInfo.createMethodInvocation(pojo, messageExchange);
+        if (methodInfo != null) {
+        return methodInfo.createMethodInvocation(pojo, exchange);
+        }
+        return null;
     }
 
-    public MethodInvocation createInvocation(Object pojo, Exchange messageExchange) throws RuntimeCamelException {
+    public MethodInvocation createInvocation(Object pojo, Exchange exchange) throws RuntimeCamelException, AmbiguousMethodCallException {
         MethodInfo methodInfo = null;
 
         // TODO use some other mechanism?
-        String name = messageExchange.getIn().getHeader("org.apache.camel.MethodName", String.class);
+        String name = exchange.getIn().getHeader(BeanProcessor.METHOD_NAME, String.class);
         if (name != null) {
             methodInfo = operations.get(name);
         }
         if (methodInfo == null) {
-            methodInfo = defaultExpression;
+            methodInfo = chooseMethod(pojo, exchange);
+        }
+        if (methodInfo == null) {
+            methodInfo = defaultMethod;
         }
         if (methodInfo != null) {
-            return methodInfo.createMethodInvocation(pojo, messageExchange);
+            return methodInfo.createMethodInvocation(pojo, exchange);
         }
         return null;
     }
@@ -91,7 +100,9 @@
     protected void introspect(Class clazz) {
         Method[] methods = clazz.getDeclaredMethods();
         for (Method method : methods) {
-            introspect(clazz, method);
+            if (isValidMethod(clazz, method)) {
+                introspect(clazz, method);
+            }
         }
         Class superclass = clazz.getSuperclass();
         if (superclass != null && !superclass.equals(Object.class)) {
@@ -101,26 +112,36 @@
 
     protected MethodInfo introspect(Class clazz, Method method) {
         Class[] parameterTypes = method.getParameterTypes();
-        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
+        Annotation[][] parametersAnnotations = method.getParameterAnnotations();
         final Expression[] parameterExpressions = new Expression[parameterTypes.length];
+
+        List<ParameterInfo> parameters = new ArrayList<ParameterInfo>();
+        List<ParameterInfo> bodyParameters = new ArrayList<ParameterInfo>();
+
         for (int i = 0; i < parameterTypes.length; i++) {
             Class parameterType = parameterTypes[i];
+            Annotation[] parameterAnnotations = parametersAnnotations[i];
             Expression expression = createParameterUnmarshalExpression(clazz, method,
-                    parameterType, parameterAnnotations[i]);
+                    parameterType, parameterAnnotations);
             if (expression == null) {
-                if (log.isDebugEnabled()) {
-                    log.debug("No expression available for method: "
-                            + method.toString() + " parameter: " + i + " so ignoring method");
-                }
-                if (parameterTypes.length == 1) {
+                if (parameterTypes.length == 1 && bodyParameters.isEmpty()) {
                     // lets assume its the body
                     expression = ExpressionBuilder.bodyExpression(parameterType);
                 }
                 else {
+                    if (log.isDebugEnabled()) {
+                        log.debug("No expression available for method: "
+                                + method.toString() + " which already has a body so ignoring parameter: " + i + " so ignoring method");
+                    }
                     return null;
                 }
             }
-            parameterExpressions[i] = expression;
+
+            ParameterInfo parameterInfo = new ParameterInfo(i, parameterType, parameterAnnotations, expression);
+            parameters.add(parameterInfo);
+            if (isPossibleBodyParameter(parameterAnnotations)) {
+                bodyParameters.add(parameterInfo);
+            }
         }
 
         // now lets add the method to the repository
@@ -137,30 +158,75 @@
             }
         }
         */
-        Expression parametersExpression = createMethodParametersExpression(parameterExpressions);
-        MethodInfo methodInfo = new MethodInfo(clazz, method, parametersExpression);
+        MethodInfo methodInfo = new MethodInfo(clazz, method, parameters, bodyParameters);
         operations.put(opName, methodInfo);
+        if (methodInfo.hasBodyParameter()) {
+            operationsWithBody.add(methodInfo);
+        }
         return methodInfo;
     }
 
-    protected Expression createMethodParametersExpression(final Expression[] parameterExpressions) {
-        return new Expression<Exchange>() {
-            public Object evaluate(Exchange exchange) {
-                Object[] answer = new Object[parameterExpressions.length];
-                for (int i = 0; i < parameterExpressions.length; i++) {
-                    Expression parameterExpression = parameterExpressions[i];
-                    answer[i] = parameterExpression.evaluate(exchange);
+    /**
+     * Lets try choose one of the available methods to invoke if we can match
+     * the message body to the body parameter
+     *
+     * @param pojo the bean to invoke a method on
+     * @param exchange the message exchange
+     * @return the method to invoke or null if no definitive method could be matched
+     */
+    protected MethodInfo chooseMethod(Object pojo, Exchange exchange) throws AmbiguousMethodCallException {
+        if (operationsWithBody.size() == 1) {
+            return operationsWithBody.get(0);
+        }
+        else if (!operationsWithBody.isEmpty()) {
+            // lets see if we can find a method who's body param type matches
+            // the message body
+            Message in = exchange.getIn();
+            Object body = in.getBody();
+            if (body != null) {
+                Class bodyType = body.getClass();
+
+                List<MethodInfo> possibles = new ArrayList<MethodInfo>();
+                for (MethodInfo methodInfo : operationsWithBody) {
+                    if (methodInfo.bodyParameterMatches(bodyType)) {
+                        possibles.add(methodInfo);
+                    }
+                }
+                if (possibles.size() == 1) {
+                    return possibles.get(0);
+                }
+                else if (possibles.isEmpty()) {
+                    // lets try converting
+                    Object newBody = null;
+                    MethodInfo matched = null;
+                    for (MethodInfo methodInfo : operationsWithBody) {
+                        Object value = convertToType(exchange, methodInfo.getBodyParameterType(), body);
+                        if (value != null) {
+                            if (newBody != null) {
+                                throw new AmbiguousMethodCallException(exchange, Arrays.asList(matched, methodInfo));
+                            }
+                            else {
+                                newBody = value;
+                                matched = methodInfo;
+                            }
+                        }
+                    }
+                    if (matched != null) {
+                        in.setBody(newBody);
+                        return matched;
+                    }
+                }
+                else {
+                    throw new AmbiguousMethodCallException(exchange, possibles);
                 }
-                return answer;
-            }
-
-            @Override
-            public String toString() {
-                return "parametersExpression" + Arrays.asList(parameterExpressions);
             }
-        };
+            return null;
+        }
+        return null;
     }
 
+
+
     /**
      * Creates an expression for the given parameter type if the parameter can be mapped
      * automatically or null if the parameter cannot be mapped due to unsufficient
@@ -179,6 +245,18 @@
         return strategy.getDefaultParameterTypeExpression(parameterType);
     }
 
+
+    protected boolean isPossibleBodyParameter(Annotation[] annotations) {
+        if (annotations != null) {
+            for (Annotation annotation : annotations) {
+                if ((annotation instanceof Property) || (annotation instanceof Header)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
     protected Expression createParameterUnmarshalExpressionForAnnotation(Class clazz, Method method, Class parameterType, Annotation annotation) {
         if (annotation instanceof Property) {
             Property propertyAnnotation = (Property) annotation;
@@ -201,5 +279,9 @@
 */
         }
         return null;
+    }
+
+    protected boolean isValidMethod(Class clazz, Method method) {
+        return Modifier.isPublic(method.getModifiers());
     }
 }

Propchange: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanProcessor.java?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanProcessor.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/BeanProcessor.java Wed Aug  1 13:55:13 2007
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.bind;
+
+import static org.apache.camel.util.ObjectHelper.isNullOrBlank;
+import org.aopalliance.intercept.MethodInvocation;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.Message;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.spring.util.MethodInvocationStrategy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.lang.reflect.Method;
+
+/**
+ * A {@link Processor} which converts the inbound exchange to a method invocation on a POJO
+ *
+ * @version $Revision: $
+ */
+public class BeanProcessor implements Processor {
+    public static final String METHOD_NAME = "org.apache.camel.MethodName";
+    private static final Log log = LogFactory.getLog(BeanProcessor.class);
+
+    private final Object pojo;
+    private final BeanInfo beanInfo;
+    private Method method;
+    private String methodName;
+
+    public BeanProcessor(Object pojo, BeanInfo beanInfo) {
+        this.pojo = pojo;
+        this.beanInfo = beanInfo;
+    }
+
+    public BeanProcessor(Object pojo, MethodInvocationStrategy invocationStrategy) {
+        this(pojo, new BeanInfo(pojo.getClass(), invocationStrategy));
+    }
+
+    @Override
+    public String toString() {
+        String description = method != null ? " " + method : "";
+        return "BeanProcessor[" + pojo + description + "]";
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        if (log.isDebugEnabled()) {
+            log.debug(">>>> invoking method for: " + exchange);
+        }
+        MethodInvocation invocation;
+        if (method != null) {
+            invocation = beanInfo.createInvocation(method, pojo, exchange);
+        }
+        else {
+            // lets pass in the method name to use if its specified
+            if (ObjectHelper.isNotNullAndNonEmpty(methodName)) {
+                Message in = exchange.getIn();
+                if (isNullOrBlank(in.getHeader(METHOD_NAME, String.class))) {
+                    in.setHeader(METHOD_NAME, methodName);
+                }
+            }
+            invocation = beanInfo.createInvocation(pojo, exchange);
+        }
+        if (invocation == null) {
+            throw new IllegalStateException("No method invocation could be created");
+        }
+        try {
+            Object value = invocation.proceed();
+            if (value != null) {
+                exchange.getIn().setBody(value);
+            }
+        }
+        catch (Exception e) {
+            throw e;
+        }
+        catch (Throwable throwable) {
+            throw new Exception(throwable);
+        }
+    }
+
+    // Properties
+    //-----------------------------------------------------------------------
+
+    public Method getMethod() {
+        return method;
+    }
+
+    public void setMethod(Method method) {
+        this.method = method;
+    }
+
+    public String getMethodName() {
+        return methodName;
+    }
+
+    public void setMethodName(String methodName) {
+        this.methodName = methodName;
+    }
+}

Copied: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/MethodInfo.java (from r561075, activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/MethodInfo.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/MethodInfo.java?view=diff&rev=561947&p1=activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/MethodInfo.java&r1=561075&p2=activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/MethodInfo.java&r2=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/MethodInfo.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/MethodInfo.java Wed Aug  1 13:55:13 2007
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.util;
+package org.apache.camel.spring.bind;
 
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.camel.Exchange;
@@ -23,6 +23,7 @@
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.List;
 
 /**
  * @version $Revision: $
@@ -30,12 +31,20 @@
 public class MethodInfo {
     private Class type;
     private Method method;
+    private final List<ParameterInfo> parameters;
+    private final List<ParameterInfo> bodyParameters;
     private Expression parametersExpression;
 
-    public MethodInfo(Class type, Method method, Expression parametersExpression) {
+    public MethodInfo(Class type, Method method, List<ParameterInfo> parameters, List<ParameterInfo> bodyParameters) {
         this.type = type;
         this.method = method;
-        this.parametersExpression = parametersExpression;
+        this.parameters = parameters;
+        this.bodyParameters = bodyParameters;
+        this.parametersExpression = createParametersExpression();
+    }
+
+    public String toString() {
+        return method.toString();
     }
 
     public MethodInvocation createMethodInvocation(final Object pojo, final Exchange messageExchange) {
@@ -75,7 +84,49 @@
         return parametersExpression;
     }
 
+    public List<ParameterInfo> getBodyParameters() {
+        return bodyParameters;
+    }
+
+    public Class getBodyParameterType() {
+        ParameterInfo parameterInfo = bodyParameters.get(0);
+        return parameterInfo.getType();
+    }
+
+
+    public boolean bodyParameterMatches(Class bodyType) {
+        Class actualType = getBodyParameterType();
+        return actualType != null && bodyType.isAssignableFrom(actualType);
+    }
+
+    public List<ParameterInfo> getParameters() {
+        return parameters;
+    }
+
+    public boolean hasBodyParameter() {
+        return !bodyParameters.isEmpty();
+    }
+    
     protected Object invoke(Method mth, Object pojo, Object[] arguments, Exchange exchange) throws IllegalAccessException, InvocationTargetException {
         return mth.invoke(pojo, arguments);
+    }
+
+    protected Expression createParametersExpression() {
+        return new Expression<Exchange>() {
+            public Object evaluate(Exchange exchange) {
+                int size = parameters.size();
+                Object[] answer = new Object[size];
+                for (int i = 0; i < size; i++) {
+                    Expression parameterExpression = parameters.get(i).getExpression();
+                    answer[i] = parameterExpression.evaluate(exchange);
+                }
+                return answer;
+            }
+
+            @Override
+            public String toString() {
+                return "ParametersExpression: " + parameters;
+            }
+        };
     }
 }

Propchange: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/MethodInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/ParameterInfo.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/ParameterInfo.java?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/ParameterInfo.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/ParameterInfo.java Wed Aug  1 13:55:13 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.bind;
+
+import org.apache.camel.Expression;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * @version $Revision: $
+ */
+public class ParameterInfo {
+    private final int index;
+    private final Class type;
+    private final Annotation[] annotations;
+    private final Expression expression;
+
+    public ParameterInfo(int index, Class type, Annotation[] annotations, Expression expression) {
+        this.index = index;
+        this.type = type;
+        this.annotations = annotations;
+        this.expression = expression;
+    }
+
+    public Annotation[] getAnnotations() {
+        return annotations;
+    }
+
+    public Expression getExpression() {
+        return expression;
+    }
+
+    public int getIndex() {
+        return index;
+    }
+
+    public Class getType() {
+        return type;
+    }
+}

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/package.html?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/package.html (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/bind/package.html Wed Aug  1 13:55:13 2007
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Classes to help bind beans to Camel message exchanges
+
+</body>
+</html>

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/converter/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/converter/package.html?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/converter/package.html (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/converter/package.html Wed Aug  1 13:55:13 2007
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Spring based Type Converters
+
+</body>
+</html>

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/package.html?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/package.html (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/package.html Wed Aug  1 13:55:13 2007
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Spring 2.x custom XML handling to allow namespace based XML to be parsed from inside any Spring XML
+
+</body>
+</html>

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/package.html?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/package.html (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/package.html Wed Aug  1 13:55:13 2007
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+The classes for working with Camel and Spring along with the primary factory beans
+
+</body>
+</html>

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/processor/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/processor/package.html?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/processor/package.html (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/processor/package.html Wed Aug  1 13:55:13 2007
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Spring dependent Processors
+
+</body>
+</html>

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/package.html?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/package.html (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/package.html Wed Aug  1 13:55:13 2007
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Plugins to the CamleContext when running in Spring
+
+</body>
+</html>

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/package.html?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/package.html (added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/package.html Wed Aug  1 13:55:13 2007
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Utility classes
+
+</body>
+</html>

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/BeanRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/BeanRouteTest.java?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/BeanRouteTest.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/BeanRouteTest.java Wed Aug  1 13:55:13 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.bean;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: $
+ */
+public class BeanRouteTest extends SpringTestSupport {
+    protected Object body = "James";
+
+    public void testSayHello() throws Exception {
+        Object value = template.sendBody("bean:myBean?methodName=sayHello", body);
+
+        assertEquals("Returned value", "Hello James!", value);
+    }
+
+    public void testSayGoodbye() throws Exception {
+        Object value = template.sendBody("bean:myBean?methodName=sayGoodbye", body);
+
+        assertEquals("Returned value", "Bye James!", value);
+    }
+
+    public void TODO_testChooseMethodUsingBodyType() throws Exception {
+        Object value = template.sendBody("bean:myBean", 4);
+
+        assertEquals("Returned value", 8L, value);
+    }
+
+    public void testAmbiguousMethodCallFails() throws Exception {
+        try {
+            Object value = template.sendBody("bean:myBean", body);
+            fail("We should have failed to invoke an ambiguous method but instead got: " + value);
+        }
+        catch (Exception e) {
+            log.info("Caught expected failure: " + e, e);
+        }
+    }
+
+    protected int getExpectedRouteCount() {
+        // TODO why zero?
+        return 0;
+    }
+
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/bean/camelContext.xml");
+    }
+
+}
\ No newline at end of file

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/ExampleBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/ExampleBean.java?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/ExampleBean.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/bean/ExampleBean.java Wed Aug  1 13:55:13 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.bean;
+
+/**
+ * An example POJO with no annotations or interfaces to test out the POJO
+ * Camel binding
+ *
+ * @version $Revision: $
+ */
+public class ExampleBean {
+
+    public String sayHello(String name) {
+        return "Hello " + name + "!";
+    }
+
+    public String sayGoodbye(String name) {
+        return "Bye " + name + "!";       
+    }
+
+    public long timesTwo(int value) {
+        return value * 2;
+    }
+}
\ No newline at end of file

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanAsEndpointTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanAsEndpointTest.java?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanAsEndpointTest.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanAsEndpointTest.java Wed Aug  1 13:55:13 2007
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.bind;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision: $
+ */
+public class BeanAsEndpointTest extends SpringTestSupport {
+    protected Object body = "James";
+
+    public void testSendingToBean() throws Exception {
+        MockEndpoint mock = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
+        mock.expectedBodiesReceived("Hello James!");
+
+        template.sendBody("direct:start", body);
+
+        mock.assertIsSatisfied();
+    }
+
+    protected int getExpectedRouteCount() {
+        // TODO why zero?
+        return 0;
+    }
+
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/bind/beanAsEndpoint.xml");
+    }
+
+}
\ No newline at end of file

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanInfoTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanInfoTest.java?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanInfoTest.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/BeanInfoTest.java Wed Aug  1 13:55:13 2007
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.bind;
+
+import junit.framework.TestCase;
+import org.apache.camel.Exchange;
+import org.apache.camel.spring.util.DefaultMethodInvocationStrategy;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+import org.aopalliance.intercept.MethodInvocation;
+
+/**
+ * @version $Revision: $
+ */
+public class BeanInfoTest extends TestCase {
+    private static final Log log = LogFactory.getLog(BeanInfoTest.class);
+
+    protected Exchange exchange = new DefaultExchange(new DefaultCamelContext());
+    protected DefaultMethodInvocationStrategy strategy = new DefaultMethodInvocationStrategy();
+    protected ExampleBean bean = new ExampleBean();
+    protected BeanInfo info;
+
+    public void testFindsSingleMethodMatchingBody() throws Throwable {
+        MethodInvocation invocation = info.createInvocation(bean, exchange);
+        assertNotNull("Should have found a method invocation!", invocation);
+
+        Object value = invocation.proceed();
+
+        log.info("Value: " + value);
+    }
+
+    public void testBeanProcessor() throws Exception {
+        BeanProcessor processor = new BeanProcessor(bean, info);
+        processor.process(exchange);
+
+        log.info("Exchange is: " + exchange);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        exchange.getIn().setBody("James");
+        info = new BeanInfo(bean.getClass(), strategy);
+    }
+}

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ExampleBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ExampleBean.java?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ExampleBean.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ExampleBean.java Wed Aug  1 13:55:13 2007
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.bind;
+
+/**
+ * An example POJO with no annotations or interfaces to test out the POJO
+ * Camel binding
+ *
+ * @version $Revision: $
+ */
+public class ExampleBean {
+
+    public String sayHello(String name) {
+        return "Hello " + name + "!";
+    }
+}
\ No newline at end of file

Copied: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorAsEndpointTest.java (from r561666, activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorAsEndpointTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorAsEndpointTest.java?view=diff&rev=561947&p1=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorAsEndpointTest.java&r1=561666&p2=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorAsEndpointTest.java&r2=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorAsEndpointTest.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorAsEndpointTest.java Wed Aug  1 13:55:13 2007
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.endpoint;
+package org.apache.camel.spring.bind;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
@@ -55,7 +55,7 @@
     }
 
     protected ClassPathXmlApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/spring/endpoint/processorAsEndpoint.xml");
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/bind/processorAsEndpoint.xml");
     }
 
     protected int getExpectedRouteCount() {

Copied: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorStub.java (from r561666, activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorStub.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorStub.java?view=diff&rev=561947&p1=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorStub.java&r1=561666&p2=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorStub.java&r2=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/endpoint/ProcessorStub.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ProcessorStub.java Wed Aug  1 13:55:13 2007
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.endpoint;
+package org.apache.camel.spring.bind;
 
 import org.apache.camel.Processor;
 import org.apache.camel.Exchange;

Copied: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/bean/camelContext.xml (from r561075, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/event/camelContext.xml)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/bean/camelContext.xml?view=diff&rev=561947&p1=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/event/camelContext.xml&r1=561075&p2=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/bean/camelContext.xml&r2=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/event/camelContext.xml (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/bean/camelContext.xml Wed Aug  1 13:55:13 2007
@@ -23,12 +23,8 @@
     ">
 
   <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
-    <package>org.apache.camel.component.event</package>
-
-    <route>
-      <from uri="event:default"/>
-      <to uri="mock:result"/>
-    </route>
   </camelContext>
+  
+  <bean id="myBean" class="org.apache.camel.component.bean.ExampleBean"/>
 
 </beans>

Added: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/beanAsEndpoint.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/beanAsEndpoint.xml?view=auto&rev=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/beanAsEndpoint.xml (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/beanAsEndpoint.xml Wed Aug  1 13:55:13 2007
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+    <route>
+      <from uri="direct:start"/>
+      <to uri="myBean"/>
+      <to uri="mock:results"/>
+    </route>
+  </camelContext>
+
+  <bean id="myBean" class="org.apache.camel.spring.bind.ExampleBean"/>
+</beans>

Copied: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/processorAsEndpoint.xml (from r561666, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpoint/processorAsEndpoint.xml)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/processorAsEndpoint.xml?view=diff&rev=561947&p1=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpoint/processorAsEndpoint.xml&r1=561666&p2=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/processorAsEndpoint.xml&r2=561947
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/endpoint/processorAsEndpoint.xml (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/processorAsEndpoint.xml Wed Aug  1 13:55:13 2007
@@ -25,5 +25,5 @@
   <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
   </camelContext>
 
-  <bean id="myProcessor" class="org.apache.camel.spring.endpoint.ProcessorStub"/>
+  <bean id="myProcessor" class="org.apache.camel.spring.bind.ProcessorStub"/>
 </beans>



Mime
View raw message