|
1 | 1 | /*
|
2 |
| - * Copyright 2016-2018 the original author or authors. |
| 2 | + * Copyright 2016-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
20 | 20 | import java.util.List;
|
21 | 21 | import java.util.Locale;
|
22 | 22 |
|
| 23 | +import org.apache.commons.logging.Log; |
| 24 | +import org.apache.commons.logging.LogFactory; |
| 25 | + |
23 | 26 | import org.springframework.batch.item.file.FlatFileFooterCallback;
|
24 | 27 | import org.springframework.batch.item.file.FlatFileHeaderCallback;
|
25 | 28 | import org.springframework.batch.item.file.FlatFileItemWriter;
|
|
44 | 47 | */
|
45 | 48 | public class FlatFileItemWriterBuilder<T> {
|
46 | 49 |
|
| 50 | + protected Log logger = LogFactory.getLog(getClass()); |
| 51 | + |
47 | 52 | private Resource resource;
|
48 | 53 |
|
49 | 54 | private boolean forceSync = false;
|
@@ -489,12 +494,16 @@ public FlatFileItemWriter<T> build() {
|
489 | 494 |
|
490 | 495 | Assert.isTrue(this.lineAggregator != null || this.delimitedBuilder != null || this.formattedBuilder != null,
|
491 | 496 | "A LineAggregator or a DelimitedBuilder or a FormattedBuilder is required");
|
492 |
| - Assert.notNull(this.resource, "A Resource is required"); |
493 | 497 |
|
494 | 498 | if(this.saveState) {
|
495 | 499 | Assert.hasText(this.name, "A name is required when saveState is true");
|
496 | 500 | }
|
497 | 501 |
|
| 502 | + if(this.resource == null) { |
| 503 | + logger.debug("The resource is null. This is only a valid scenario when " + |
| 504 | + "injecting it later as in when using the MultiResourceItemWriter"); |
| 505 | + } |
| 506 | + |
498 | 507 | FlatFileItemWriter<T> writer = new FlatFileItemWriter<>();
|
499 | 508 |
|
500 | 509 | writer.setName(this.name);
|
|
0 commit comments