diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractMessageHandlingEndpoint.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractMessageHandlingEndpoint.java index 7de6944d21..ed101e8d7c 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractMessageHandlingEndpoint.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractMessageHandlingEndpoint.java @@ -18,7 +18,6 @@ package org.springframework.integration.endpoint; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; import org.springframework.integration.channel.ChannelRegistry; import org.springframework.integration.channel.ChannelRegistryAware; @@ -45,8 +44,6 @@ public abstract class AbstractMessageHandlingEndpoint extends AbstractMessageCon private volatile boolean requiresReply = false; - private final List interceptors = new CopyOnWriteArrayList(); - public void setOutputChannel(MessageChannel outputChannel) { this.outputChannel = outputChannel; @@ -68,25 +65,9 @@ public abstract class AbstractMessageHandlingEndpoint extends AbstractMessageCon this.requiresReply = requiresReply; } - public void addInterceptor(EndpointInterceptor interceptor) { - this.interceptors.add(interceptor); - } - - public void setInterceptors(List interceptors) { - this.interceptors.clear(); - for (EndpointInterceptor interceptor : interceptors) { - this.addInterceptor(interceptor); - } - } @Override protected void onMessageInternal(Message message) { - for (EndpointInterceptor interceptor : this.interceptors) { - message = interceptor.preHandle(message); - if (message == null) { - return; - } - } if (!this.supports(message)) { throw new MessageRejectedException(message, "unsupported message"); } @@ -136,15 +117,6 @@ public abstract class AbstractMessageHandlingEndpoint extends AbstractMessageCon } private boolean sendReplyMessage(Message replyMessage, MessageChannel replyChannel) { - for (int i = this.interceptors.size() - 1; i >= 0; i--) { - EndpointInterceptor interceptor = this.interceptors.get(i); - if (interceptor != null) { - replyMessage = interceptor.postHandle(replyMessage); - if (replyMessage == null) { - return false; - } - } - } return this.getChannelTemplate().send(replyMessage, replyChannel); } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/EndpointInterceptor.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/EndpointInterceptor.java deleted file mode 100644 index b015b8f24b..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/EndpointInterceptor.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.endpoint; - -import org.springframework.integration.message.Message; - -/** - * @author Mark Fisher - */ -public interface EndpointInterceptor { - - Message preHandle(Message requestMessage); - - Message postHandle(Message replyMessage); - -} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/interceptor/EndpointInterceptorAdapter.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/interceptor/EndpointInterceptorAdapter.java deleted file mode 100644 index 3e35974982..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/interceptor/EndpointInterceptorAdapter.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.endpoint.interceptor; - -import org.springframework.integration.endpoint.EndpointInterceptor; -import org.springframework.integration.message.Message; - -/** - * A convenience base class for implementing {@link EndpointInterceptor EndpointInterceptors}. - * - * @author Mark Fisher - */ -public class EndpointInterceptorAdapter implements EndpointInterceptor { - - public Message preHandle(Message requestMessage) { - return requestMessage; - } - - public Message postHandle(Message replyMessage) { - return replyMessage; - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/EndpointInterceptorTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/EndpointInterceptorTests.java deleted file mode 100644 index 5becb32976..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/EndpointInterceptorTests.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.Test; - -import org.springframework.beans.DirectFieldAccessor; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.integration.channel.MessageChannel; -import org.springframework.integration.endpoint.EndpointInterceptor; -import org.springframework.integration.endpoint.MessageEndpoint; -import org.springframework.integration.message.StringMessage; - -/** - * @author Mark Fisher - */ -public class EndpointInterceptorTests { - - @Test - public void testHandlerEndpointWithBeanInterceptors() { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( - "endpointInterceptorTests.xml", this.getClass()); - MessageEndpoint endpoint = (MessageEndpoint) context.getBean("endpointWithBeanInterceptors"); - testInterceptors(endpoint, context, true); - } - - @Test - public void testHandlerEndpointWithRefInterceptors() { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( - "endpointInterceptorTests.xml", this.getClass()); - MessageEndpoint endpoint = (MessageEndpoint) context.getBean("endpointWithRefInterceptors"); - testInterceptors(endpoint, context, false); - } - - - @SuppressWarnings("unchecked") - private static void testInterceptors(MessageEndpoint endpoint, ClassPathXmlApplicationContext context, boolean innerBeans) { - MessageChannel channel = null; - TestPreHandleInterceptor preInterceptor = null; - TestPostHandleInterceptor postInterceptor = null; - if (innerBeans) { - channel = (MessageChannel) context.getBean("inputChannelForBeans"); - DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint); - List interceptors = (List) accessor.getPropertyValue("interceptors"); - preInterceptor = (TestPreHandleInterceptor) interceptors.get(0); - postInterceptor = (TestPostHandleInterceptor) interceptors.get(1); - } - else { - channel = (MessageChannel) context.getBean("inputChannelForRefs"); - preInterceptor = (TestPreHandleInterceptor) context.getBean("preInterceptor"); - postInterceptor = (TestPostHandleInterceptor) context.getBean("postInterceptor"); - } - assertEquals(0, preInterceptor.getCount()); - assertEquals(0, postInterceptor.getCount()); - assertTrue(channel.send(new StringMessage("test"))); - assertEquals(1, preInterceptor.getCount()); - assertEquals(1, postInterceptor.getCount()); - context.stop(); - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/TestPostHandleInterceptor.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/TestPostHandleInterceptor.java deleted file mode 100644 index 7e75bf8ea9..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/TestPostHandleInterceptor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 java.util.concurrent.atomic.AtomicInteger; - -import org.springframework.integration.endpoint.interceptor.EndpointInterceptorAdapter; -import org.springframework.integration.message.Message; - -/** - * @author Mark Fisher - */ -public class TestPostHandleInterceptor extends EndpointInterceptorAdapter { - - private AtomicInteger counter = new AtomicInteger(); - - - public int getCount() { - return this.counter.get(); - } - - @Override - public Message postHandle(Message replyMessage) { - this.counter.incrementAndGet(); - return replyMessage; - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/TestPreHandleInterceptor.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/TestPreHandleInterceptor.java deleted file mode 100644 index 9f5916ac72..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/TestPreHandleInterceptor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 java.util.concurrent.atomic.AtomicInteger; - -import org.springframework.integration.endpoint.interceptor.EndpointInterceptorAdapter; -import org.springframework.integration.message.Message; - -/** - * @author Mark Fisher - */ -public class TestPreHandleInterceptor extends EndpointInterceptorAdapter { - - private AtomicInteger counter = new AtomicInteger(); - - - public int getCount() { - return this.counter.get(); - } - - @Override - public Message preHandle(Message message) { - this.counter.incrementAndGet(); - return message; - } - -}