camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r573195 - /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java
Date Thu, 06 Sep 2007 09:21:47 GMT
Author: jstrachan
Date: Thu Sep  6 02:21:46 2007
New Revision: 573195

URL: http://svn.apache.org/viewvc?rev=573195&view=rev
Log:
added helper methods to make it easier to create endpoints from beans from the BeanComponent
itself

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java?rev=573195&r1=573194&r2=573195&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanComponent.java
Thu Sep  6 02:21:46 2007
@@ -19,6 +19,7 @@
 import java.util.Map;
 
 import org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
 import org.apache.camel.impl.DefaultComponent;
 import org.apache.camel.impl.ProcessorEndpoint;
 import org.apache.camel.spi.Registry;
@@ -40,6 +41,22 @@
     public BeanComponent() {
     }
 
+    /**
+     * A helper method to create a new endpoint from a bean with a generated URI
+     */
+    public ProcessorEndpoint createEndpoint(Object bean) {
+        String uri = "bean:generated:" + bean;
+        return createEndpoint(bean, uri);
+    }
+
+    /**
+     * A helper method to create a new endpoint from a bean with a given URI
+     */
+    public ProcessorEndpoint createEndpoint(Object bean, String uri) {
+        BeanProcessor processor = new BeanProcessor(bean, getCamelContext(), getParameterMappingStrategy());
+        return createEndpoint(uri, processor);
+    }
+
     public ParameterMappingStrategy getParameterMappingStrategy() {
         if (parameterMappingStrategy == null) {
             parameterMappingStrategy = createParameterMappingStrategy();
@@ -58,7 +75,7 @@
         Object bean = getBean(remaining);
         BeanProcessor processor = new BeanProcessor(bean, getCamelContext(), getParameterMappingStrategy());
         setProperties(processor, parameters);
-        return new ProcessorEndpoint(uri, this, processor);
+        return createEndpoint(uri, processor);
     }
 
     public Object getBean(String remaining) throws NoBeanAvailableException {
@@ -70,6 +87,12 @@
         return bean;
     }
 
+    protected ProcessorEndpoint createEndpoint(String uri, BeanProcessor processor) {
+        ProcessorEndpoint answer = new ProcessorEndpoint(uri, this, processor);
+        answer.setExchangePattern(ExchangePattern.InOut);
+        return answer;
+    }
+               
     protected ParameterMappingStrategy createParameterMappingStrategy() {
         return BeanProcessor.createParameterMappingStrategy(getCamelContext());
     }



Mime
View raw message