Hi, I'm very new to Camel. I'm just trying to get my object's method to be
called. I know that spring finds the bean so thats good.
bean:
package tutorial.simple.route;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.camel.Handler;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
public class MockSql {
private static final Logger log = Logger.getLogger("mockSql");
public MockSql(){
log.setLevel(Level.DEBUG);
log.debug("constructed mock sql");
}
@Handler
public ArrayList populate(){
ArrayList <HashMap> ary = new ArrayList<HashMap>();
HashMap<String, String> hm = new HashMap();
HashMap<String, String> hm2 = new HashMap();
hm.put("n1", "j1");
hm2.put("n2", "j2");
ary.add(hm);
ary.add(hm2);
log.debug("populated mock sql");
return ary;
}
}
route:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
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-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="mockSql" class="tutorial.simple.route.MockSql"/>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<log loggingLevel="DEBUG" message="logger" id="123"
customId="true"/>
<to uri="bean:mockSql?method=populate()"/>
</route>
</camelContext>
</beans>
output:
[pache.camel.spring.Main.main()] MainSupport INFO Apache
Camel 2.12.0.redhat-610379 starting
[pache.camel.spring.Main.main()] mockSql DEBUG
constructed mock sql
[pache.camel.spring.Main.main()] SpringCamelContext INFO Apache
Camel 2.12.0.redhat-610379 (CamelContext: camel) is starting
[pache.camel.spring.Main.main()] ManagedManagementStrategy INFO JMX is
enabled
[pache.camel.spring.Main.main()] DefaultTypeConverter INFO Loaded
176 type converters
[pache.camel.spring.Main.main()] SpringCamelContext INFO
AllowUseOriginalMessage is enabled. If access to the original message is not
needed, then its recommended to turn this option off as it may improve
performance.
[pache.camel.spring.Main.main()] SpringCamelContext INFO
StreamCaching is not in use. If using streams then its recommended to enable
stream caching. See more details at
http://camel.apache.org/stream-caching.html
[pache.camel.spring.Main.main()] SpringCamelContext INFO Route:
route1 started and consuming from: Endpoint[direct://start]
[pache.camel.spring.Main.main()] SpringCamelContext INFO Total
1 routes, of which 1 is started.
[pache.camel.spring.Main.main()] SpringCamelContext INFO Apache
Camel 2.12.0.redhat-610379 (CamelContext: camel) started in 0.324 seconds
as you can see, "populate" is never called.
--
View this message in context:
http://camel.465427.n5.nabble.com/Cant-call-bean-s-function-XML-tp5756601.html
Sent from the Camel - Users mailing list archive at Nabble.com.