diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java
index 9ed5547e13..4594cc6836 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java
@@ -124,9 +124,8 @@ public abstract class AbstractEndpoint extends IntegrationObjectSupport implemen
}
/**
- * Subclasses may override this method to invoke the callback before
- * or after the start behavior.
- * @param callback the Runnable to invoke
+ * Stop the component and invoke callback.
+ * @param callback the Runnable to invoke.
*/
protected void doStop(Runnable callback) {
doStop();
diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java
index b2820962e8..4128b99d4e 100644
--- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java
+++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.integration.file.config;
import java.io.File;
@@ -33,6 +34,7 @@ import org.springframework.util.StringUtils;
/**
* @author Gary Russell
+ * @author Artem Bilan
* @since 3.0
*
*/
@@ -61,6 +63,8 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
private volatile MessageChannel outputChannel;
+ private volatile MessageChannel errorChannel;
+
private volatile Boolean autoStartup;
private volatile Integer phase;
@@ -110,6 +114,10 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
this.outputChannel = outputChannel;
}
+ public void setErrorChannel(MessageChannel errorChannel) {
+ this.errorChannel = errorChannel;
+ }
+
public void setAutoStartup(boolean autoStartup) {
this.autoStartup = autoStartup;
}
@@ -139,10 +147,7 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
@Override
public boolean isRunning() {
- if (this.adapter != null) {
- return this.adapter.isRunning();
- }
- return false;
+ return this.adapter != null && this.adapter.isRunning();
}
@Override
@@ -155,10 +160,7 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
@Override
public boolean isAutoStartup() {
- if (this.adapter != null) {
- return this.adapter.isAutoStartup();
- }
- return false;
+ return this.adapter != null && this.adapter.isAutoStartup();
}
@Override
@@ -206,7 +208,8 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
if (this.fileDelay != null) {
adapter.setTailAttemptsDelay(this.fileDelay);
}
- adapter.setOutputChannel(outputChannel);
+ adapter.setOutputChannel(this.outputChannel);
+ adapter.setErrorChannel(this.errorChannel);
adapter.setBeanName(this.beanName);
if (this.autoStartup != null) {
adapter.setAutoStartup(this.autoStartup);
@@ -217,8 +220,8 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
if (this.applicationEventPublisher != null) {
adapter.setApplicationEventPublisher(this.applicationEventPublisher);
}
- if (this.getBeanFactory() != null) {
- adapter.setBeanFactory(this.getBeanFactory());
+ if (getBeanFactory() != null) {
+ adapter.setBeanFactory(getBeanFactory());
}
adapter.afterPropertiesSet();
this.adapter = adapter;
diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParser.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParser.java
index ca0913eab0..fb430ae0c1 100644
--- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParser.java
+++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.integration.file.config;
import org.w3c.dom.Element;
@@ -26,6 +27,7 @@ import org.springframework.util.StringUtils;
/**
* @author Gary Russell
+ * @author Artem Bilan
* @since 3.0
*
*/
@@ -46,6 +48,7 @@ public class FileTailInboundChannelAdapterParser extends AbstractChannelAdapterP
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "file-delay");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "end");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reopen");
+ IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "error-channel");
return builder.getBeanDefinition();
}
diff --git a/spring-integration-file/src/main/resources/org/springframework/integration/file/config/spring-integration-file-4.1.xsd b/spring-integration-file/src/main/resources/org/springframework/integration/file/config/spring-integration-file-4.1.xsd
index a2e0605d1a..4bc83d9e29 100644
--- a/spring-integration-file/src/main/resources/org/springframework/integration/file/config/spring-integration-file-4.1.xsd
+++ b/spring-integration-file/src/main/resources/org/springframework/integration/file/config/spring-integration-file-4.1.xsd
@@ -263,6 +263,18 @@ Only files matching this regular expression will be picked up by this adapter.
+
+
+
+ Message Channel to which error Messages should be sent.
+
+
+
+
+
+
+
+
diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParserTests-context.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParserTests-context.xml
index 7a26ed9948..83d5d9a3f5 100644
--- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParserTests-context.xml
+++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParserTests-context.xml
@@ -13,12 +13,15 @@
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+
+
+ phase="123"
+ error-channel="tailErrorChannel"/>
-
+
@@ -62,7 +65,7 @@
phase="123" />
-
+
diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParserTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParserTests.java
index 90fb8b250e..54b1692b5d 100644
--- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParserTests.java
+++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterParserTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.integration.file.config;
import static org.junit.Assert.assertEquals;
@@ -30,14 +31,15 @@ import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.file.tail.ApacheCommonsFileTailingMessageProducer;
import org.springframework.integration.file.tail.OSDelegatingFileTailingMessageProducer;
import org.springframework.integration.test.util.TestUtils;
+import org.springframework.messaging.MessageChannel;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Gary Russell
+ * @author Artem Bilan
* @since 3.0
- *
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@@ -64,6 +66,9 @@ public class FileTailInboundChannelAdapterParserTests {
@Autowired
private TaskScheduler taskScheduler;
+ @Autowired
+ private MessageChannel tailErrorChannel;
+
@Test
public void testDefault() {
String fileName = TestUtils.getPropertyValue(defaultAdapter, "file", File.class).getAbsolutePath();
@@ -73,6 +78,7 @@ public class FileTailInboundChannelAdapterParserTests {
assertSame(exec, TestUtils.getPropertyValue(defaultAdapter, "taskExecutor"));
assertFalse(TestUtils.getPropertyValue(defaultAdapter, "autoStartup", Boolean.class));
assertEquals(123, TestUtils.getPropertyValue(defaultAdapter, "phase"));
+ assertSame(this.tailErrorChannel, TestUtils.getPropertyValue(defaultAdapter, "errorChannel"));
}
@Test