INT-2738 Add Missing getComponentType() Methods

JIRA: https://jira.spring.io/browse/INT-2738

Add a `getComponentType()` method for all handlers,
message producers, and message sources that implement
`NamedComponent` (see `SPCA.getComponentType()`).

Add rome as an optional dependency - STS complained
because AtomFeedHttpMessageConverter has a dependency
on it.
This commit is contained in:
Gary Russell
2014-04-12 16:20:59 -04:00
committed by Artem Bilan
parent 3839eca5ca
commit a7489909d7
54 changed files with 384 additions and 146 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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.
@@ -20,6 +20,7 @@ import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.core.MessageSource;
@@ -27,10 +28,11 @@ import org.springframework.messaging.support.GenericMessage;
/**
* A pollable source for receiving bytes from an {@link InputStream}.
*
*
* @author Mark Fisher
* @author Artem Bilan
*/
public class ByteStreamReadingMessageSource implements MessageSource<byte[]> {
public class ByteStreamReadingMessageSource extends IntegrationObjectSupport implements MessageSource<byte[]> {
private BufferedInputStream stream;
@@ -67,6 +69,11 @@ public class ByteStreamReadingMessageSource implements MessageSource<byte[]> {
this.shouldTruncate = shouldTruncate;
}
@Override
public String getComponentType() {
return "stream:stdin-channel-adapter(byte)";
}
public Message<byte[]> receive() {
try {
byte[] bytes;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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.
@@ -23,14 +23,14 @@ import java.io.OutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
/**
* A {@link MessageHandler} that writes a byte array to an {@link OutputStream}.
*
*
* @author Mark Fisher
*/
public class ByteStreamWritingMessageHandler extends AbstractMessageHandler {
@@ -53,7 +53,12 @@ public class ByteStreamWritingMessageHandler extends AbstractMessageHandler {
}
}
@Override
public String getComponentType() {
return "stream:outbound-channel-adapter(byte)";
}
@Override
protected void handleMessageInternal(Message<?> message) {
Object payload = message.getPayload();
if (payload == null) {

View File

@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
/**
* A pollable source for {@link Reader Readers}.
*
*
* @author Mark Fisher
*/
public class CharacterStreamReadingMessageSource extends IntegrationObjectSupport implements MessageSource<String> {
@@ -61,7 +61,7 @@ public class CharacterStreamReadingMessageSource extends IntegrationObjectSuppor
public String getComponentType() {
return "stream:stdin-channel-adapter";
return "stream:stdin-channel-adapter(character)";
}
public Message<String> receive() {

View File

@@ -128,6 +128,11 @@ public class CharacterStreamWritingMessageHandler extends AbstractMessageHandler
this.shouldAppendNewLine = shouldAppendNewLine;
}
@Override
public String getComponentType() {
return "stream:outbound-channel-adapter(character)";
}
@Override
protected void handleMessageInternal(Message<?> message) {
Object payload = message.getPayload();