INT-1257 removed 'this' from IntegrationObjectSupports message-history writing method
This commit is contained in:
@@ -26,11 +26,9 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.context.NamedComponent;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageDeliveryException;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -159,7 +157,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
|
||||
* time or the sending thread is interrupted.
|
||||
*/
|
||||
public final boolean send(Message<?> message, long timeout) {
|
||||
this.writeMessageHistory(message, this);
|
||||
this.writeMessageHistory(message);
|
||||
Assert.notNull(message, "message must not be null");
|
||||
Assert.notNull(message.getPayload(), "message payload must not be null");
|
||||
message = this.convertPayloadIfNecessary(message);
|
||||
|
||||
@@ -105,10 +105,10 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
|
||||
}
|
||||
throw new BeanInitializationException("failed to initialize", e);
|
||||
}
|
||||
if (this.beanFactory != null){
|
||||
if (this.beanFactory.containsBean(MessageHistoryWriter.HISTORY_WRITER_BEAN_NAME)){
|
||||
if (this.beanFactory != null) {
|
||||
if (this.beanFactory.containsBean(MessageHistoryWriter.HISTORY_WRITER_BEAN_NAME)) {
|
||||
historyWriter = this.beanFactory.getBean(MessageHistoryWriter.HISTORY_WRITER_BEAN_NAME, MessageHistoryWriter.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,10 +166,11 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
|
||||
public String toString() {
|
||||
return (this.beanName != null) ? this.beanName : super.toString();
|
||||
}
|
||||
|
||||
protected void writeMessageHistory(Message<?> message, NamedComponent component){
|
||||
if (historyWriter != null){
|
||||
historyWriter.writeHistory(component, message);
|
||||
|
||||
protected void writeMessageHistory(Message<?> message) {
|
||||
if (historyWriter != null) {
|
||||
historyWriter.writeHistory(this, message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.integration.gateway;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.message.InboundMessageMapper;
|
||||
import org.springframework.integration.message.OutboundMessageMapper;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -81,7 +80,7 @@ public class SimpleMessagingGateway extends AbstractMessagingGateway {
|
||||
Message<?> message = null;
|
||||
try {
|
||||
message = this.inboundMapper.toMessage(object);
|
||||
this.writeMessageHistory(message, this);
|
||||
this.writeMessageHistory(message);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof RuntimeException) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -62,7 +61,7 @@ public abstract class AbstractMessageHandler extends IntegrationObjectSupport im
|
||||
public final void handleMessage(Message<?> message) {
|
||||
Assert.notNull(message, "Message must not be null");
|
||||
Assert.notNull(message.getPayload(), "Message payload must not be null");
|
||||
this.writeMessageHistory(message, this);
|
||||
this.writeMessageHistory(message);
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug(this + " received message: " + message);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.history;
|
||||
|
||||
import org.springframework.integration.context.NamedComponent;
|
||||
@@ -23,9 +24,13 @@ import org.springframework.integration.core.Message;
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MessageHistoryWriter {
|
||||
|
||||
public final static String HISTORY_WRITER_BEAN_NAME = "historyWriter";
|
||||
|
||||
public void writeHistory(NamedComponent component, Message<?> message){
|
||||
message.getHeaders().getHistory().addEvent(component);
|
||||
|
||||
public void writeHistory(NamedComponent component, Message<?> message) {
|
||||
if (message != null) {
|
||||
message.getHeaders().getHistory().addEvent(component);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user