camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-10021: Class component - Should allow to call static method on class without ctr
Date Sat, 04 Jun 2016 09:05:58 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.17.x a38f925b1 -> d71cd39ce
  refs/heads/master 2eae5f9ff -> 6eab973bd


CAMEL-10021: Class component - Should allow to call static method on class without ctr


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6eab973b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6eab973b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6eab973b

Branch: refs/heads/master
Commit: 6eab973bdf08e66c477540f4efa5bc5f425c4c43
Parents: 2eae5f9
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Jun 4 10:28:27 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Jun 4 10:28:27 2016 +0200

----------------------------------------------------------------------
 .../component/beanclass/ClassComponent.java     | 22 +++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6eab973b/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassComponent.java
b/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassComponent.java
index 5372c0f..64c6f03 100644
--- a/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/beanclass/ClassComponent.java
@@ -22,6 +22,7 @@ import org.apache.camel.Endpoint;
 import org.apache.camel.component.bean.BeanComponent;
 import org.apache.camel.component.bean.BeanHolder;
 import org.apache.camel.component.bean.ConstantBeanHolder;
+import org.apache.camel.component.bean.ConstantTypeBeanHolder;
 import org.apache.camel.util.IntrospectionSupport;
 
 /**
@@ -44,19 +45,30 @@ public class ClassComponent extends BeanComponent {
         // bean name is the FQN
         String name = endpoint.getBeanName();
         Class<?> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(name);
-        // create bean
-        Object bean = getCamelContext().getInjector().newInstance(clazz);
 
         // the bean.xxx options is for the bean
         Map<String, Object> options = IntrospectionSupport.extractProperties(parameters,
"bean.");
         endpoint.setParameters(options);
 
-        // now set additional properties on it
-        setProperties(bean, options);
+        BeanHolder holder;
+
+        // if there is options then we need to create a bean instance
+        if (!options.isEmpty()) {
+            // create bean
+            Object bean = getCamelContext().getInjector().newInstance(clazz);
+
+            // now set additional properties on it
+            setProperties(bean, options);
+
+            holder = new ConstantBeanHolder(bean, getCamelContext());
+        } else {
+            // otherwise refer to the type
+            holder = new ConstantTypeBeanHolder(clazz, getCamelContext());
+        }
+
         validateParameters(uri, options, null);
 
         // and register the bean as a holder on the endpoint
-        BeanHolder holder = new ConstantBeanHolder(bean, getCamelContext());
         endpoint.setBeanHolder(holder);
 
         return endpoint;


Mime
View raw message