Search in sources :

Example 1 with OSDelegatingFileTailingMessageProducer

use of org.springframework.integration.file.tail.OSDelegatingFileTailingMessageProducer in project spring-integration by spring-projects.

the class FileTailInboundChannelAdapterFactoryBean method createInstance.

@Override
protected FileTailingMessageProducerSupport createInstance() throws Exception {
    FileTailingMessageProducerSupport adapter;
    if (this.delay == null && this.end == null && this.reopen == null) {
        adapter = new OSDelegatingFileTailingMessageProducer();
        ((OSDelegatingFileTailingMessageProducer) adapter).setEnableStatusReader(this.enableStatusReader);
        if (this.nativeOptions != null) {
            ((OSDelegatingFileTailingMessageProducer) adapter).setOptions(this.nativeOptions);
        }
    } else {
        Assert.isTrue(this.nativeOptions == null, "'native-options' is not allowed with 'delay', 'end', or 'reopen'");
        adapter = new ApacheCommonsFileTailingMessageProducer();
        if (this.delay != null) {
            ((ApacheCommonsFileTailingMessageProducer) adapter).setPollingDelay(this.delay);
        }
        if (this.end != null) {
            ((ApacheCommonsFileTailingMessageProducer) adapter).setEnd(this.end);
        }
        if (this.reopen != null) {
            ((ApacheCommonsFileTailingMessageProducer) adapter).setReopen(this.reopen);
        }
    }
    adapter.setFile(this.file);
    if (this.taskExecutor != null) {
        adapter.setTaskExecutor(this.taskExecutor);
    }
    if (this.taskScheduler != null) {
        adapter.setTaskScheduler(this.taskScheduler);
    }
    if (this.fileDelay != null) {
        adapter.setTailAttemptsDelay(this.fileDelay);
    }
    if (this.idleEventInterval != null) {
        adapter.setIdleEventInterval(this.idleEventInterval);
    }
    adapter.setOutputChannel(this.outputChannel);
    adapter.setErrorChannel(this.errorChannel);
    adapter.setBeanName(this.beanName);
    if (this.autoStartup != null) {
        adapter.setAutoStartup(this.autoStartup);
    }
    if (this.phase != null) {
        adapter.setPhase(this.phase);
    }
    if (this.applicationEventPublisher != null) {
        adapter.setApplicationEventPublisher(this.applicationEventPublisher);
    }
    if (getBeanFactory() != null) {
        adapter.setBeanFactory(getBeanFactory());
    }
    adapter.afterPropertiesSet();
    this.adapter = adapter;
    return adapter;
}
Also used : ApacheCommonsFileTailingMessageProducer(org.springframework.integration.file.tail.ApacheCommonsFileTailingMessageProducer) OSDelegatingFileTailingMessageProducer(org.springframework.integration.file.tail.OSDelegatingFileTailingMessageProducer) FileTailingMessageProducerSupport(org.springframework.integration.file.tail.FileTailingMessageProducerSupport)

Aggregations

ApacheCommonsFileTailingMessageProducer (org.springframework.integration.file.tail.ApacheCommonsFileTailingMessageProducer)1 FileTailingMessageProducerSupport (org.springframework.integration.file.tail.FileTailingMessageProducerSupport)1 OSDelegatingFileTailingMessageProducer (org.springframework.integration.file.tail.OSDelegatingFileTailingMessageProducer)1