INT-868. Defined ControlBus interface and ControlBusMessageHandler to handle ControlBus messages

This commit is contained in:
Oleg Zhurakousky
2009-11-03 10:52:29 +00:00
parent d76109496c
commit e560a5fdbc
2 changed files with 74 additions and 0 deletions

View File

@@ -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 {
}

View File

@@ -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();
}
}
}