Hello Ray!
I build a small example and it works. If you like, I can send you my example
Eclipse project.
{code:title=MyPredicate.java}
public class MyPredicate implements Predicate {
public boolean matches(Exchange exchange) {
return true;
}
}
{code}
{code:title=MyBean}
public class MyBean {
public void process(Exchange exchange) throws Exception {
System.out.println("received exchange: " + exchange);
}
}
{code}
{code:title=FilterSpringIntegrationTest}
public class FilterSpringIntegrationTest extends CamelSpringTestSupport {
@EndpointInject(uri = "direct:start")
private ProducerTemplate template;
@Test
public void testFilterPredicate() {
Object response = template.requestBody("Hello Camel");
System.out.println("received response: " + response);
}
@Override
protected AbstractXmlApplicationContext createApplicationContext() {
return new
ClassPathXmlApplicationContext("META-INF/spring/bundle-context.xml");
}
}
{code}
{code:title=bundle-context.xml}
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<camel:camelContext trace="true">
<camel:route>
<camel:from uri="direct:start" />
<camel:filter>
<camel:method ref="myPredicate" />
<camel:bean ref="myBean" method="process" />
</camel:filter>
</camel:route>
</camel:camelContext>
<bean id="myPredicate" class="org.apache.camel.cmueller.MyPredicate"/>
<bean id="myBean" class="org.apache.camel.cmueller.MyBean"/>
</beans>
{code}
{code:title=pom.xml}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.camel.cmueller</groupId>
<artifactId>filter-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
{code}
Cheers,
Christian