-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interface for delegation to Iterator, Iterable, simple item
Signed-off-by: Taeik Lim <[email protected]>
- Loading branch information
Showing
9 changed files
with
385 additions
and
1 deletion.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
.../main/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamFluxReaderDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Spring Batch Plus | ||
* | ||
* Copyright 2022-present NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.spring.batch.plus.item.adapter; | ||
|
||
import org.springframework.batch.item.ExecutionContext; | ||
import org.springframework.batch.item.ItemStreamReader; | ||
import org.springframework.lang.NonNull; | ||
import reactor.core.publisher.Flux; | ||
|
||
/** | ||
* A delegate for {@link ItemStreamReader} which uses {@link Flux<T>}. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
public interface ItemStreamFluxReaderDelegate<T> { | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#open(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
*/ | ||
default void onOpenRead(@NonNull ExecutionContext executionContext) { | ||
} | ||
|
||
/** | ||
* Read items by reactor flux. Invoked in {@link ItemStreamReader#open(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
* @return a flux to read item | ||
*/ | ||
@NonNull | ||
Flux<? extends T> readFlux(@NonNull ExecutionContext executionContext); | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#update(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
*/ | ||
default void onUpdateRead(@NonNull ExecutionContext executionContext) { | ||
} | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#close()}. | ||
*/ | ||
default void onCloseRead() { | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ava/com/navercorp/spring/batch/plus/item/adapter/ItemStreamFluxReaderProcessorWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Spring Batch Plus | ||
* | ||
* Copyright 2022-present NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.spring.batch.plus.item.adapter; | ||
|
||
import org.springframework.batch.item.ItemProcessor; | ||
import org.springframework.batch.item.ItemStreamReader; | ||
import org.springframework.batch.item.ItemStreamWriter; | ||
|
||
/** | ||
* A simple adapter for stream reader, processor, writer. It can represent | ||
* {@link ItemStreamReader}, {@link ItemProcessor}, {@link ItemStreamWriter} in a single class. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
public interface ItemStreamFluxReaderProcessorWriter<I, O> | ||
extends ItemStreamFluxReaderDelegate<I>, ItemProcessorDelegate<I, O>, ItemStreamWriterDelegate<O> { | ||
} |
62 changes: 62 additions & 0 deletions
62
...n/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamIterableReaderDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Spring Batch Plus | ||
* | ||
* Copyright 2022-present NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.spring.batch.plus.item.adapter; | ||
|
||
import org.springframework.batch.item.ExecutionContext; | ||
import org.springframework.batch.item.ItemStreamReader; | ||
import org.springframework.lang.NonNull; | ||
|
||
/** | ||
* A delegate for {@link ItemStreamReader} which uses {@link Iterable<T>}. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
public interface ItemStreamIterableReaderDelegate<T> { | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#open(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
*/ | ||
default void onOpenRead(@NonNull ExecutionContext executionContext) { | ||
} | ||
|
||
/** | ||
* Read items by {@link Iterable<T>}. Invoked in {@link ItemStreamReader#open(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
* @return an iterable to read item | ||
*/ | ||
@NonNull | ||
Iterable<? extends T> readIterable(@NonNull ExecutionContext executionContext); | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#update(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
*/ | ||
default void onUpdateRead(@NonNull ExecutionContext executionContext) { | ||
} | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#close()}. | ||
*/ | ||
default void onCloseRead() { | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...com/navercorp/spring/batch/plus/item/adapter/ItemStreamIterableReaderProcessorWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Spring Batch Plus | ||
* | ||
* Copyright 2022-present NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.spring.batch.plus.item.adapter; | ||
|
||
import org.springframework.batch.item.ItemProcessor; | ||
import org.springframework.batch.item.ItemStreamReader; | ||
import org.springframework.batch.item.ItemStreamWriter; | ||
|
||
/** | ||
* A simple adapter for stream reader, processor, writer. It can represent | ||
* {@link ItemStreamReader}, {@link ItemProcessor}, {@link ItemStreamWriter} in a single class. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
public interface ItemStreamIterableReaderProcessorWriter<I, O> | ||
extends ItemStreamIterableReaderDelegate<I>, ItemProcessorDelegate<I, O>, ItemStreamWriterDelegate<O> { | ||
} |
64 changes: 64 additions & 0 deletions
64
...n/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamIteratorReaderDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Spring Batch Plus | ||
* | ||
* Copyright 2022-present NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.spring.batch.plus.item.adapter; | ||
|
||
import org.springframework.batch.item.ExecutionContext; | ||
import org.springframework.batch.item.ItemStreamReader; | ||
import org.springframework.lang.NonNull; | ||
|
||
import java.util.Iterator; | ||
|
||
/** | ||
* A delegate for {@link ItemStreamReader} which uses {@link Iterator<T>}. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
public interface ItemStreamIteratorReaderDelegate<T> { | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#open(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
*/ | ||
default void onOpenRead(@NonNull ExecutionContext executionContext) { | ||
} | ||
|
||
/** | ||
* Read items by {@link Iterator<T>}. Invoked in {@link ItemStreamReader#open(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
* @return an iterator to read item | ||
*/ | ||
@NonNull | ||
Iterator<? extends T> readIterator(@NonNull ExecutionContext executionContext); | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#update(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
*/ | ||
default void onUpdateRead(@NonNull ExecutionContext executionContext) { | ||
} | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#close()}. | ||
*/ | ||
default void onCloseRead() { | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...com/navercorp/spring/batch/plus/item/adapter/ItemStreamIteratorReaderProcessorWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Spring Batch Plus | ||
* | ||
* Copyright 2022-present NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.spring.batch.plus.item.adapter; | ||
|
||
import org.springframework.batch.item.ItemProcessor; | ||
import org.springframework.batch.item.ItemStreamReader; | ||
import org.springframework.batch.item.ItemStreamWriter; | ||
|
||
/** | ||
* A simple adapter for stream reader, processor, writer. It can represent | ||
* {@link ItemStreamReader}, {@link ItemProcessor}, {@link ItemStreamWriter} in a single class. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
public interface ItemStreamIteratorReaderProcessorWriter<I, O> | ||
extends ItemStreamIteratorReaderDelegate<I>, ItemProcessorDelegate<I, O>, ItemStreamWriterDelegate<O> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...ain/java/com/navercorp/spring/batch/plus/item/adapter/ItemStreamSimpleReaderDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Spring Batch Plus | ||
* | ||
* Copyright 2022-present NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.spring.batch.plus.item.adapter; | ||
|
||
import org.springframework.batch.item.ExecutionContext; | ||
import org.springframework.batch.item.ItemStreamReader; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.lang.Nullable; | ||
|
||
/** | ||
* A simple delegate for {@link ItemStreamReader}. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
public interface ItemStreamSimpleReaderDelegate<T> { | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#open(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
*/ | ||
default void onOpenRead(@NonNull ExecutionContext executionContext) { | ||
} | ||
|
||
/** | ||
* Read each item. Invoked in {@link ItemStreamReader#open(ExecutionContext)}. | ||
* | ||
* @return an item to read. null if it's end of data. | ||
* Return contract is same as {@link org.springframework.batch.item.ItemReader<T>} | ||
*/ | ||
@Nullable | ||
T read(); | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#update(ExecutionContext)}. | ||
* | ||
* @param executionContext an execution context | ||
*/ | ||
default void onUpdateRead(@NonNull ExecutionContext executionContext) { | ||
} | ||
|
||
/** | ||
* A delegate method for {@link ItemStreamReader#close()}. | ||
*/ | ||
default void onCloseRead() { | ||
} | ||
} |
Oops, something went wrong.