diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/FilterParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/FilterParser.java
new file mode 100644
index 0000000000..e8659c2a04
--- /dev/null
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/FilterParser.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2002-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.config;
+
+import org.springframework.integration.endpoint.MessageEndpoint;
+import org.springframework.integration.filter.FilterEndpoint;
+import org.springframework.integration.filter.MethodInvokingSelector;
+
+/**
+ * Parser for the <filter/> element.
+ *
+ * @author Mark Fisher
+ */
+public class FilterParser extends AbstractEndpointParser {
+
+ @Override
+ protected Class extends MessageEndpoint> getEndpointClass() {
+ return FilterEndpoint.class;
+ }
+
+ @Override
+ protected Class> getMethodInvokingAdapterClass() {
+ return MethodInvokingSelector.class;
+ }
+
+}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/IntegrationNamespaceHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/IntegrationNamespaceHandler.java
index 30c46790ae..e3636c3110 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/IntegrationNamespaceHandler.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/IntegrationNamespaceHandler.java
@@ -36,6 +36,7 @@ public class IntegrationNamespaceHandler extends NamespaceHandlerSupport {
registerBeanDefinitionParser("publish-subscribe-channel", new PublishSubscribeChannelParser());
registerBeanDefinitionParser("service-activator", new ServiceActivatorParser());
registerBeanDefinitionParser("transformer", new TransformerParser());
+ registerBeanDefinitionParser("filter", new FilterParser());
registerBeanDefinitionParser("router", new RouterParser());
registerBeanDefinitionParser("splitter", new SplitterParser());
registerBeanDefinitionParser("aggregator", new AggregatorParser());
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-1.0.xsd b/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-1.0.xsd
index f1292d027e..1340f694ae 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-1.0.xsd
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-1.0.xsd
@@ -319,6 +319,14 @@
+
+
+
+ Defines a Filter.
+
+
+
+
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/filter/FilterContextTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/filter/FilterContextTests.java
new file mode 100644
index 0000000000..bb45e4f38d
--- /dev/null
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/filter/FilterContextTests.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2002-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.filter;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.integration.channel.MessageChannel;
+import org.springframework.integration.channel.PollableChannel;
+import org.springframework.integration.message.Message;
+import org.springframework.integration.message.StringMessage;
+
+/**
+ * @author Mark Fisher
+ */
+public class FilterContextTests {
+
+ @Test
+ public void methodInvokingFilterRejects() {
+ ApplicationContext context = new ClassPathXmlApplicationContext(
+ "filterContextTests.xml", this.getClass());
+ MessageChannel input = (MessageChannel) context.getBean("input");
+ PollableChannel output = (PollableChannel) context.getBean("output");
+ input.send(new StringMessage("foo"));
+ Message> reply = output.receive(0);
+ assertNull(reply);
+ }
+
+ @Test
+ public void methodInvokingFilterAccepts() {
+ ApplicationContext context = new ClassPathXmlApplicationContext(
+ "filterContextTests.xml", this.getClass());
+ MessageChannel input = (MessageChannel) context.getBean("input");
+ PollableChannel output = (PollableChannel) context.getBean("output");
+ input.send(new StringMessage("foobar"));
+ Message> reply = output.receive(0);
+ assertEquals("foobar", reply.getPayload());
+ }
+
+}
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/filter/TestBean.java b/org.springframework.integration/src/test/java/org/springframework/integration/filter/TestBean.java
new file mode 100644
index 0000000000..177b2d7ece
--- /dev/null
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/filter/TestBean.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2002-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.integration.filter;
+
+/**
+ * @author Mark Fisher
+ */
+public class TestBean {
+
+ public boolean acceptStringWithMoreThanThreeChars(String s) {
+ return s.length() > 3;
+ }
+
+}
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/filter/filterContextTests.xml b/org.springframework.integration/src/test/java/org/springframework/integration/filter/filterContextTests.xml
new file mode 100644
index 0000000000..a6b82bde53
--- /dev/null
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/filter/filterContextTests.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+