From 1f05d3ec4c5a69fd9e30db69c31c2320bc21f544 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 16 May 2018 16:10:50 -0400 Subject: [PATCH] Polishing some Docs and JavaDocs * Mentioned `byte[]` support for the `UnmarshallingTransformer` * Fix `AbstractInboundFileSynchronizingMessageSource` JavaDocs to mention the current `FileSystemPersistentAcceptOnceFileListFilter` usage by default, not an `AcceptOnceFileListFilter` * Polishing `AbstractInboundFileSynchronizingMessageSource` code style a bit --- ...InboundFileSynchronizingMessageSource.java | 35 +++++++++---------- src/reference/asciidoc/xml.adoc | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java index ed9121fb94..afc4d44805 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -29,7 +29,6 @@ import org.springframework.integration.endpoint.AbstractFetchLimitingMessageSour import org.springframework.integration.file.DefaultDirectoryScanner; import org.springframework.integration.file.DirectoryScanner; import org.springframework.integration.file.FileReadingMessageSource; -import org.springframework.integration.file.filters.AcceptOnceFileListFilter; import org.springframework.integration.file.filters.CompositeFileListFilter; import org.springframework.integration.file.filters.FileListFilter; import org.springframework.integration.file.filters.FileSystemPersistentAcceptOnceFileListFilter; @@ -77,24 +76,25 @@ public abstract class AbstractInboundFileSynchronizingMessageSource */ private final LocalFileReadingMessageSource fileSource; - private volatile boolean running; - /** * Should the endpoint attempt to create the local directory? True by default. */ - private volatile boolean autoCreateLocalDirectory = true; + private boolean autoCreateLocalDirectory = true; /** * Directory to which things should be synchronized locally. */ - private volatile File localDirectory; + private File localDirectory; - private volatile FileListFilter localFileListFilter; + private FileListFilter localFileListFilter; /** * Whether the {@link DirectoryScanner} was explicitly set. */ - private volatile boolean scannerExplicitlySet = false; + private boolean scannerExplicitlySet = false; + + private volatile boolean running; + public AbstractInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer synchronizer) { this(synchronizer, null); @@ -127,10 +127,8 @@ public abstract class AbstractInboundFileSynchronizingMessageSource * after they have been synchronized. It will be combined with a filter that * will prevent accessing files that are in the process of being synchronized * (files having the {@link AbstractInboundFileSynchronizer#getTemporaryFileSuffix()}). - *

- * The default is an {@link AcceptOnceFileListFilter} which filters duplicate file - * names (processed during the current execution). - * + *

The default is an {@link FileSystemPersistentAcceptOnceFileListFilter} + * which filters duplicate file names (processed during the current execution). * @param localFileListFilter The local file list filter. */ public void setLocalFilter(FileListFilter localFileListFilter) { @@ -147,7 +145,8 @@ public abstract class AbstractInboundFileSynchronizingMessageSource public void setUseWatchService(boolean useWatchService) { this.fileSource.setUseWatchService(useWatchService); if (useWatchService) { - this.fileSource.setWatchEvents(FileReadingMessageSource.WatchEventType.CREATE, + this.fileSource.setWatchEvents( + FileReadingMessageSource.WatchEventType.CREATE, FileReadingMessageSource.WatchEventType.MODIFY, FileReadingMessageSource.WatchEventType.DELETE); } @@ -182,14 +181,15 @@ public abstract class AbstractInboundFileSynchronizingMessageSource } this.fileSource.setDirectory(this.localDirectory); if (this.localFileListFilter == null) { - this.localFileListFilter = new FileSystemPersistentAcceptOnceFileListFilter( - new SimpleMetadataStore(), getComponentName()); + this.localFileListFilter = + new FileSystemPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), getComponentName()); } FileListFilter filter = buildFilter(); if (this.scannerExplicitlySet) { Assert.state(!this.fileSource.isUseWatchService(), "'useWatchService' and 'scanner' are mutually exclusive."); - this.fileSource.getScanner().setFilter(filter); + this.fileSource.getScanner() + .setFilter(filter); } else if (!this.fileSource.isUseWatchService()) { DirectoryScanner directoryScanner = new DefaultDirectoryScanner(); @@ -209,8 +209,7 @@ public abstract class AbstractInboundFileSynchronizingMessageSource throw e; } catch (Exception e) { - throw new BeanInitializationException("Failure during initialization of MessageSource for: " - + this.getClass(), e); + throw new BeanInitializationException("Failure during initialization for: " + this, e); } } diff --git a/src/reference/asciidoc/xml.adoc b/src/reference/asciidoc/xml.adoc index d291863c56..411344e479 100644 --- a/src/reference/asciidoc/xml.adoc +++ b/src/reference/asciidoc/xml.adoc @@ -270,7 +270,7 @@ An http://docs.spring.io/spring-integration/api/org/springframework/integration/ Spring's Object/XML Mapping support provides several implementations supporting marshalling and unmarshalling using http://en.wikipedia.org/wiki/Java_Architecture_for_XML_Binding[JAXB], http://www.castor.org/[Castor] and http://jibx.sourceforge.net/[JiBX] amongst others. The unmarshaller requires an instance of `Source`. If the message payload is not an instance of `Source`, conversion will be attempted. -Currently `String`, `File` and `org.w3c.dom.Document` payloads are supported. +Currently `String`, `File`, `byte[]` and `org.w3c.dom.Document` payloads are supported. Custom conversion to a `Source` is also supported by injecting an implementation of a http://docs.spring.io/spring-integration/api/org/springframework/integration/xml/source/SourceFactory.html[SourceFactory]. NOTE: If a `SourceFactory` is not set explicitly, the property on the `UnmarshallingTransformer` will by default be set to a http://docs.spring.io/spring-integration/api/org/springframework/integration/xml/source/DomSourceFactory.html[DomSourceFactory].