You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/10/11 13:35:20 UTC
svn commit: r583780 - in /activemq/camel/trunk/camel-core/src:
main/java/org/apache/camel/component/bean/BeanProcessor.java
main/java/org/apache/camel/model/BeanRef.java
test/java/org/apache/camel/processor/BeanMethodHeartbeatTest.java
Author: jstrachan
Date: Thu Oct 11 04:35:18 2007
New Revision: 583780
URL: http://svn.apache.org/viewvc?rev=583780&view=rev
Log:
minor refactor to make configuring the bean endpoint easier; letting folks use "method=foo" rather than "methodName=foo"
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/BeanRef.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanMethodHeartbeatTest.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java?rev=583780&r1=583779&r2=583780&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/BeanProcessor.java Thu Oct 11 04:35:18 2007
@@ -44,8 +44,8 @@
private final Object pojo;
private final BeanInfo beanInfo;
- private Method method;
- private String methodName;
+ private Method methodObject;
+ private String method;
private final Processor processor;
public BeanProcessor(Object pojo, BeanInfo beanInfo) {
@@ -73,7 +73,7 @@
}
@Override
public String toString() {
- String description = method != null ? " " + method : "";
+ String description = methodObject != null ? " " + methodObject : "";
return "BeanProcessor[" + pojo + description + "]";
}
@@ -95,13 +95,13 @@
}
MethodInvocation invocation;
- if (method != null) {
- invocation = beanInfo.createInvocation(method, pojo, exchange);
+ if (methodObject != null) {
+ invocation = beanInfo.createInvocation(methodObject, pojo, exchange);
} else {
// lets pass in the method name to use if its specified
- if (ObjectHelper.isNotNullAndNonEmpty(methodName)) {
+ if (ObjectHelper.isNotNullAndNonEmpty(method)) {
if (isNullOrBlank(in.getHeader(METHOD_NAME, String.class))) {
- in.setHeader(METHOD_NAME, methodName);
+ in.setHeader(METHOD_NAME, method);
}
}
invocation = beanInfo.createInvocation(pojo, exchange);
@@ -134,20 +134,35 @@
// Properties
// -----------------------------------------------------------------------
- public Method getMethod() {
- return method;
+ public Method getMethodObject() {
+ return methodObject;
}
- public void setMethod(Method method) {
- this.method = method;
+ public void setMethodObject(Method methodObject) {
+ this.methodObject = methodObject;
+ }
+
+ public String getMethod() {
+ return method;
}
- public String getMethodName() {
- return methodName;
+ /**
+ * Sets the method name to use
+ */
+ public void setMethod(String method) {
+ this.method = method;
}
- public void setMethodName(String methodName) {
- this.methodName = methodName;
+ /**
+ * Kept around for backwards compatibility, please use {@link #setMethod(String)}
+ * in future instead.
+ *
+ * @deprecated
+ * @see #setMethod(String)
+ * @param method
+ */
+ public void setMethodName(String method) {
+ setMethod(method);
}
// Implementation methods
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/BeanRef.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/BeanRef.java?rev=583780&r1=583779&r2=583780&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/BeanRef.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/BeanRef.java Thu Oct 11 04:35:18 2007
@@ -102,7 +102,7 @@
}
BeanProcessor answer = new BeanProcessor(bean, routeContext.getCamelContext());
if (method != null) {
- answer.setMethodName(method);
+ answer.setMethod(method);
}
return answer;
}
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanMethodHeartbeatTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanMethodHeartbeatTest.java?rev=583780&r1=583779&r2=583780&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanMethodHeartbeatTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanMethodHeartbeatTest.java Thu Oct 11 04:35:18 2007
@@ -16,17 +16,18 @@
*/
package org.apache.camel.processor;
+import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
-import java.util.Map;
import java.util.List;
+import java.util.Map;
import javax.naming.Context;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
-import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
/**
* This test shows we can poll a bean for a method and send the POJO over some transport
@@ -43,7 +44,7 @@
resultEndpoint.assertIsSatisfied();
- List<Exchange> list = resultEndpoint.getReceivedExchanges();
+ List<Exchange> list = new ArrayList<Exchange>(resultEndpoint.getReceivedExchanges());
log.debug("Received: " + list);
Exchange exchange = list.get(0);
log.debug("In: " + exchange.getIn());
@@ -63,7 +64,7 @@
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from("bean:myService?methodName=status").to("mock:result");
+ from("bean:myService?method=status").to("mock:result");
}
};
}