From e560a5fdbce67605678020674037e029ba8e4e8e Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 3 Nov 2009 10:52:29 +0000 Subject: [PATCH] INT-868. Defined ControlBus interface and ControlBusMessageHandler to handle ControlBus messages --- .../integration/controlbus/ControlBus.java | 29 ++++++++++++ .../controlbus/ControlBusMessageHandler.java | 45 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 org.springframework.integration/src/main/java/org/springframework/integration/controlbus/ControlBus.java create mode 100644 org.springframework.integration/src/main/java/org/springframework/integration/controlbus/ControlBusMessageHandler.java diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/controlbus/ControlBus.java b/org.springframework.integration/src/main/java/org/springframework/integration/controlbus/ControlBus.java new file mode 100644 index 0000000000..ce448ead93 --- /dev/null +++ b/org.springframework.integration/src/main/java/org/springframework/integration/controlbus/ControlBus.java @@ -0,0 +1,29 @@ +/* + * 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.controlbus; + +import org.springframework.integration.channel.SubscribableChannel; + +/** + * Defines base interface for implementation of the Control Bus EIP pattern ({@linkplain http://www.eaipatterns.com/ControlBus.html}) + * Control Bus infrastructure is assembled with various components provided by the framework with the main entry point + * being {@link SubscribableChannel} making this interface more of a convenience wrapper over target {@link SubscribableChannel} + * + * @author Oleg Zhurakousky + * @since 2.0 + */ +public interface ControlBus extends SubscribableChannel { +} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/controlbus/ControlBusMessageHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/controlbus/ControlBusMessageHandler.java new file mode 100644 index 0000000000..e47bcc2a38 --- /dev/null +++ b/org.springframework.integration/src/main/java/org/springframework/integration/controlbus/ControlBusMessageHandler.java @@ -0,0 +1,45 @@ +/* + * 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.controlbus; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.integration.core.CommandMessage; +import org.springframework.integration.core.Message; +import org.springframework.integration.message.MessageDeliveryException; +import org.springframework.integration.message.MessageHandler; +import org.springframework.integration.message.MessageHandlingException; +import org.springframework.integration.message.MessageRejectedException; + +/** + * @author Oleg Zhurakousky + * @since 2.0 + */ +public class ControlBusMessageHandler implements MessageHandler { + private static final Log log = LogFactory.getLog(ControlBusMessageHandler.class); + /** + * + */ + public void handleMessage(Message message) + throws MessageRejectedException, MessageHandlingException, + MessageDeliveryException { + if (message instanceof CommandMessage){ + log.debug("Handling CommandMessage: " + message); + ((CommandMessage)message).execute(); + } + } + +}