Add support to build StaxEventItemReader when no Resource is provided
Resolves #3736
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
4000d1d579
commit
c2625b1f87
@@ -21,6 +21,9 @@ import java.util.List;
|
||||
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.batch.item.xml.StaxEventItemReader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.oxm.Unmarshaller;
|
||||
@@ -34,10 +37,13 @@ import org.springframework.util.xml.StaxUtils;
|
||||
* @author Michael Minella
|
||||
* @author Glenn Renfro
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author Parikshit Dutta
|
||||
* @since 4.0
|
||||
*/
|
||||
public class StaxEventItemReaderBuilder<T> {
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private boolean strict = true;
|
||||
|
||||
private Resource resource;
|
||||
@@ -215,10 +221,13 @@ public class StaxEventItemReaderBuilder<T> {
|
||||
* @return a new instance of the {@link StaxEventItemReader}
|
||||
*/
|
||||
public StaxEventItemReader<T> build() {
|
||||
Assert.notNull(this.resource, "A resource is required.");
|
||||
|
||||
StaxEventItemReader<T> reader = new StaxEventItemReader<>();
|
||||
|
||||
if (this.resource == null) {
|
||||
logger.debug("The resource is null. This is only a valid scenario when " +
|
||||
"injecting resource later as in when using the MultiResourceItemReader");
|
||||
}
|
||||
|
||||
if (this.saveState) {
|
||||
Assert.state(StringUtils.hasText(this.name), "A name is required when saveState is set to true.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user