Skip to content

Commit

Permalink
Move adapter package
Browse files Browse the repository at this point in the history
Signed-off-by: Taeik Lim <[email protected]>
  • Loading branch information
acktsap committed Apr 12, 2024
1 parent 01a5aef commit c484c46
Show file tree
Hide file tree
Showing 102 changed files with 1,219 additions and 322 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,12 @@ package com.navercorp.spring.batch.plus.kotlin.item.adapter

import com.navercorp.spring.batch.plus.item.adapter.AdapterFactory
import com.navercorp.spring.batch.plus.item.adapter.ItemProcessorDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamFluxReaderDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamIterableReaderDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamIteratorReaderDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamReaderDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamSimpleReaderDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamWriterDelegate
import org.springframework.batch.item.ItemProcessor
import org.springframework.batch.item.ItemStreamReader
import org.springframework.batch.item.ItemStreamWriter

/**
* An extensions to invoke [AdapterFactory.itemStreamReader].
*/
fun <T : Any> ItemStreamFluxReaderDelegate<T>.asItemStreamReader(): ItemStreamReader<T> =
AdapterFactory.itemStreamReader(this)

/**
* An extensions to invoke [AdapterFactory.itemStreamReader].
*/
fun <T : Any> ItemStreamIterableReaderDelegate<T>.asItemStreamReader(): ItemStreamReader<T> =
AdapterFactory.itemStreamReader(this)

/**
* An extensions to invoke [AdapterFactory.itemStreamReader].
*/
fun <T : Any> ItemStreamIteratorReaderDelegate<T>.asItemStreamReader(): ItemStreamReader<T> =
AdapterFactory.itemStreamReader(this)

/**
* An extensions to invoke [AdapterFactory.itemStreamReader].
*/
fun <T : Any> ItemStreamSimpleReaderDelegate<T>.asItemStreamReader(): ItemStreamReader<T> =
AdapterFactory.itemStreamReader(this)

/**
* An extensions to invoke [AdapterFactory.itemStreamReader].
*/
Expand All @@ -67,11 +39,22 @@ fun <T : Any> ItemStreamReaderDelegate<T>.asItemStreamReader(): ItemStreamReader
/**
* An extensions to invoke [AdapterFactory.itemProcessor].
*/
@Deprecated(
message = "Uses com.navercorp.spring.batch.plus.step.adapter.ItemProcessorDelegate instead",
replaceWith = ReplaceWith(""),
)
fun <I : Any, O : Any> ItemProcessorDelegate<I, O>.asItemProcessor(): ItemProcessor<I, O> =
AdapterFactory.itemProcessor(this)

/**
* An extensions to invoke [AdapterFactory.itemStreamWriter].
*/
@Deprecated(
message = "Uses com.navercorp.spring.batch.plus.step.adapter.ItemStreamWriterDelegate instead",
replaceWith = ReplaceWith(
"AdapterFactory.itemStreamWriter(this)",
"com.navercorp.spring.batch.plus.step.adapter.AdapterFactory",
),
)
fun <T : Any> ItemStreamWriterDelegate<T>.asItemStreamWriter(): ItemStreamWriter<T> =
AdapterFactory.itemStreamWriter(this)
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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.kotlin.step.adapter

import com.navercorp.spring.batch.plus.step.adapter.AdapterFactory
import com.navercorp.spring.batch.plus.step.adapter.ItemProcessorDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamWriterDelegate
import org.springframework.batch.item.ItemProcessor
import org.springframework.batch.item.ItemStreamReader
import org.springframework.batch.item.ItemStreamWriter

/**
* An extensions to invoke [AdapterFactory.itemStreamReader].
*/
fun <T : Any> ItemStreamFluxReaderDelegate<T>.asItemStreamReader(): ItemStreamReader<T> =
AdapterFactory.itemStreamReader(this)

/**
* An extensions to invoke [AdapterFactory.itemStreamReader].
*/
fun <T : Any> ItemStreamIterableReaderDelegate<T>.asItemStreamReader(): ItemStreamReader<T> =
AdapterFactory.itemStreamReader(this)

/**
* An extensions to invoke [AdapterFactory.itemStreamReader].
*/
fun <T : Any> ItemStreamIteratorReaderDelegate<T>.asItemStreamReader(): ItemStreamReader<T> =
AdapterFactory.itemStreamReader(this)

/**
* An extensions to invoke [AdapterFactory.itemStreamReader].
*/
fun <T : Any> ItemStreamSimpleReaderDelegate<T>.asItemStreamReader(): ItemStreamReader<T> =
AdapterFactory.itemStreamReader(this)

/**
* An extensions to invoke [AdapterFactory.itemProcessor].
*/
fun <I : Any, O : Any> ItemProcessorDelegate<I, O>.asItemProcessor(): ItemProcessor<I, O> =
AdapterFactory.itemProcessor(this)

/**
* An extensions to invoke [AdapterFactory.itemStreamWriter].
*/
fun <T : Any> ItemStreamWriterDelegate<T>.asItemStreamWriter(): ItemStreamWriter<T> =
AdapterFactory.itemStreamWriter(this)
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ package com.navercorp.spring.batch.plus.kotlin.item.adapter

import com.navercorp.spring.batch.plus.item.adapter.ItemProcessorAdapter
import com.navercorp.spring.batch.plus.item.adapter.ItemProcessorDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamFluxReaderDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamIterableReaderDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamIteratorReaderDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamReaderProcessorWriter
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamSimpleReaderDelegate
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamWriterAdapter
import com.navercorp.spring.batch.plus.item.adapter.ItemStreamWriterDelegate
import com.navercorp.spring.batch.plus.item.adapter.StepScopeItemStreamReader
Expand All @@ -37,46 +33,6 @@ import reactor.core.publisher.Flux

internal class ItemDelegatesTest {

@Test
fun testAsItemStreamReaderOnItemStreamFluxReaderDelegate() {
// when
val delegate = mockk<ItemStreamFluxReaderDelegate<*>>()
val itemStreamReader = delegate.asItemStreamReader()

// then
assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java)
}

@Test
fun testAsItemStreamReaderOnItemStreamIterableReaderDelegate() {
// when
val delegate = mockk<ItemStreamIterableReaderDelegate<*>>()
val itemStreamReader = delegate.asItemStreamReader()

// then
assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java)
}

@Test
fun testAsItemStreamReaderOnItemStreamIteratorReaderDelegate() {
// when
val delegate = mockk<ItemStreamIteratorReaderDelegate<*>>()
val itemStreamReader = delegate.asItemStreamReader()

// then
assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java)
}

@Test
fun testAsItemStreamReaderOnItemStreamSimpleReaderDelegate() {
// when
val delegate = mockk<ItemStreamSimpleReaderDelegate<*>>()
val itemStreamReader = delegate.asItemStreamReader()

// then
assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java)
}

@Test
fun testAsItemProcessor() {
// when
Expand All @@ -97,7 +53,6 @@ internal class ItemDelegatesTest {
assertThat(itemStreamWriter).isInstanceOf(ItemStreamWriterAdapter::class.java)
}

// TODO: delete after ItemStreamReaderDelegate is removed
@Test
fun testExtensions() {
// when
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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.kotlin.step.adapter

import com.navercorp.spring.batch.plus.step.adapter.ItemProcessorAdapter
import com.navercorp.spring.batch.plus.step.adapter.ItemProcessorDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIteratorReaderDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamSimpleReaderDelegate
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamWriterAdapter
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamWriterDelegate
import com.navercorp.spring.batch.plus.step.adapter.StepScopeItemStreamReader
import io.mockk.mockk
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class ItemDelegatesTest {

@Test
fun testAsItemStreamReaderOnItemStreamFluxReaderDelegate() {
// when
val delegate = mockk<ItemStreamFluxReaderDelegate<*>>()
val itemStreamReader = delegate.asItemStreamReader()

// then
assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java)
}

@Test
fun testAsItemStreamReaderOnItemStreamIterableReaderDelegate() {
// when
val delegate = mockk<ItemStreamIterableReaderDelegate<*>>()
val itemStreamReader = delegate.asItemStreamReader()

// then
assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java)
}

@Test
fun testAsItemStreamReaderOnItemStreamIteratorReaderDelegate() {
// when
val delegate = mockk<ItemStreamIteratorReaderDelegate<*>>()
val itemStreamReader = delegate.asItemStreamReader()

// then
assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java)
}

@Test
fun testAsItemStreamReaderOnItemStreamSimpleReaderDelegate() {
// when
val delegate = mockk<ItemStreamSimpleReaderDelegate<*>>()
val itemStreamReader = delegate.asItemStreamReader()

// then
assertThat(itemStreamReader).isInstanceOf(StepScopeItemStreamReader::class.java)
}

@Test
fun testAsItemProcessor() {
// when
val delegate = mockk<ItemProcessorDelegate<*, *>>()
val itemProcessor = delegate.asItemProcessor()

// then
assertThat(itemProcessor).isInstanceOf(ItemProcessorAdapter::class.java)
}

@Test
fun testAsItemStreamWriter() {
// when
val delegate = mockk<ItemStreamWriterDelegate<*>>()
val itemStreamWriter = delegate.asItemStreamWriter()

// then
assertThat(itemStreamWriter).isInstanceOf(ItemStreamWriterAdapter::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package com.navercorp.spring.batch.plus.sample.flux.callback

import com.navercorp.spring.batch.plus.item.adapter.ItemStreamFluxReaderProcessorWriter
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderProcessorWriter
import org.springframework.batch.core.configuration.annotation.StepScope
import org.springframework.batch.item.Chunk
import org.springframework.batch.item.ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package com.navercorp.spring.batch.plus.sample.flux.callback

import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemProcessor
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemStreamReader
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemStreamWriter
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter
import org.springframework.batch.core.Job
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package com.navercorp.spring.batch.plus.sample.flux.readerprocessorwriter

import com.navercorp.spring.batch.plus.item.adapter.ItemStreamFluxReaderProcessorWriter
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderProcessorWriter
import org.springframework.batch.core.configuration.annotation.StepScope
import org.springframework.batch.item.Chunk
import org.springframework.batch.item.ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package com.navercorp.spring.batch.plus.sample.flux.readerprocessorwriter

import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemProcessor
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemStreamReader
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemStreamWriter
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter
import org.springframework.batch.core.Job
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package com.navercorp.spring.batch.plus.sample.flux.readerwriter

import com.navercorp.spring.batch.plus.item.adapter.ItemStreamFluxReaderWriter
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamFluxReaderWriter
import org.springframework.batch.core.configuration.annotation.StepScope
import org.springframework.batch.item.Chunk
import org.springframework.batch.item.ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package com.navercorp.spring.batch.plus.sample.flux.readerwriter

import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemStreamReader
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemStreamWriter
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter
import org.springframework.batch.core.Job
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package com.navercorp.spring.batch.plus.sample.iterable.callback

import com.navercorp.spring.batch.plus.item.adapter.ItemStreamIterableReaderProcessorWriter
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderProcessorWriter
import org.springframework.batch.core.configuration.annotation.StepScope
import org.springframework.batch.item.Chunk
import org.springframework.batch.item.ExecutionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package com.navercorp.spring.batch.plus.sample.iterable.callback

import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemProcessor
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemStreamReader
import com.navercorp.spring.batch.plus.kotlin.item.adapter.asItemStreamWriter
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemProcessor
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamReader
import com.navercorp.spring.batch.plus.kotlin.step.adapter.asItemStreamWriter
import org.springframework.batch.core.Job
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package com.navercorp.spring.batch.plus.sample.iterable.readerprocessorwriter

import com.navercorp.spring.batch.plus.item.adapter.ItemStreamIterableReaderProcessorWriter
import com.navercorp.spring.batch.plus.step.adapter.ItemStreamIterableReaderProcessorWriter
import org.springframework.batch.core.configuration.annotation.StepScope
import org.springframework.batch.item.Chunk
import org.springframework.batch.item.ExecutionContext
Expand Down
Loading

0 comments on commit c484c46

Please sign in to comment.