Skip to content

Commit

Permalink
Update sample to inject params by property
Browse files Browse the repository at this point in the history
- BatchDsl
- PlatformTransactionManager

Signed-off-by: Taeik Lim <[email protected]>
  • Loading branch information
acktsap committed Nov 5, 2023
1 parent 30d487a commit 1ebb30e
Show file tree
Hide file tree
Showing 138 changed files with 882 additions and 703 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@ import com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer
import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import org.springframework.batch.core.Job
import org.springframework.batch.repeat.RepeatStatus
import org.springframework.batch.support.transaction.ResourcelessTransactionManager
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.PlatformTransactionManager

@Configuration
open class TestJobConfig {
open class TestJobConfig(
private val batch: BatchDsl,
private val transactionManager: PlatformTransactionManager,
) {

@Bean
open fun testJob(
batch: BatchDsl,
): Job = batch {
open fun testJob(): Job = batch {
job("testJob") {
incrementer(ClearRunIdIncrementer.create())
step("testStep") {
tasklet(
{ _, _ -> RepeatStatus.FINISHED },
ResourcelessTransactionManager(),
transactionManager,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@ import com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer
import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import org.springframework.batch.core.Job
import org.springframework.batch.repeat.RepeatStatus
import org.springframework.batch.support.transaction.ResourcelessTransactionManager
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.PlatformTransactionManager

@Configuration
open class TestJobConfig {
open class TestJobConfig(
private val batch: BatchDsl,
private val transactionManager: PlatformTransactionManager,
) {

@Bean
open fun testJob(
batch: BatchDsl,
): Job = batch {
open fun testJob(): Job = batch {
job("testJob") {
incrementer(ClearRunIdIncrementer.create("testId"))
step("testStep") {
tasklet(
{ _, _ -> RepeatStatus.FINISHED },
ResourcelessTransactionManager(),
transactionManager,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

import com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer;

Expand All @@ -34,15 +34,16 @@ public class TestJobConfig {

@Bean
public Job testJob(
JobRepository jobRepository
JobRepository jobRepository,
PlatformTransactionManager transactionManager
) {
return new JobBuilder("testJob", jobRepository)
.incrementer(ClearRunIdIncrementer.create())
.start(
new StepBuilder("testStep", jobRepository)
.tasklet(
(contribution, chunkContext) -> RepeatStatus.FINISHED,
new ResourcelessTransactionManager()
transactionManager
)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

import com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer;

Expand All @@ -34,15 +34,16 @@ public class TestJobConfig {

@Bean
public Job testJob(
JobRepository jobRepository
JobRepository jobRepository,
PlatformTransactionManager transactionManager
) {
return new JobBuilder("testJob", jobRepository)
.incrementer(ClearRunIdIncrementer.create("testId"))
.start(
new StepBuilder("testStep", jobRepository)
.tasklet(
(contribution, chunkContext) -> RepeatStatus.FINISHED,
new ResourcelessTransactionManager()
transactionManager
)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,26 @@
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

@Configuration
public class TestJobConfig {

@Bean
public Job testJob(
JobRepository jobRepository
JobRepository jobRepository,
PlatformTransactionManager transactionManager
) {
return new JobBuilder("testJob", jobRepository)
.incrementer(new RunIdIncrementer())
.start(
new StepBuilder("testStep", jobRepository)
.tasklet(
testTasklet(null, null),
new ResourcelessTransactionManager()
transactionManager
)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

import com.navercorp.spring.batch.plus.job.ClearRunIdIncrementer;

Expand All @@ -38,15 +38,16 @@ public class TestJobConfig {

@Bean
public Job testJob(
JobRepository jobRepository
JobRepository jobRepository,
PlatformTransactionManager transactionManager
) {
return new JobBuilder("testJob", jobRepository)
.incrementer(ClearRunIdIncrementer.create()) // use ClearRunIdIncrementer
.start(
new StepBuilder("testStep", jobRepository)
.tasklet(
testTasklet(null, null),
new ResourcelessTransactionManager()
transactionManager
)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import org.springframework.batch.core.Job
import org.springframework.batch.core.repository.JobRepository
import org.springframework.batch.repeat.RepeatStatus
import org.springframework.batch.support.transaction.ResourcelessTransactionManager
import org.springframework.boot.autoconfigure.batch.BatchDataSource
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.PlatformTransactionManager
import javax.sql.DataSource

@Configuration
open class TestJobConfig {
open class TestJobConfig(
private val batch: BatchDsl,
private val transactionManager: PlatformTransactionManager,
) {

@Bean
open fun removeJob(
Expand All @@ -44,14 +47,12 @@ open class TestJobConfig {
}

@Bean
open fun testJob(
batch: BatchDsl,
): Job = batch {
open fun testJob(): Job = batch {
job("testJob") {
step("testStep") {
tasklet(
{ _, _ -> RepeatStatus.FINISHED },
ResourcelessTransactionManager(),
transactionManager,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import org.springframework.batch.core.Job
import org.springframework.batch.core.repository.JobRepository
import org.springframework.batch.repeat.RepeatStatus
import org.springframework.batch.support.transaction.ResourcelessTransactionManager
import org.springframework.boot.autoconfigure.batch.BatchDataSource
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.PlatformTransactionManager
import javax.sql.DataSource

@Configuration
open class TestJobConfig {
open class TestJobConfig(
private val batch: BatchDsl,
private val transactionManager: PlatformTransactionManager,
) {

@Bean
open fun removeJob(
Expand All @@ -43,14 +46,12 @@ open class TestJobConfig {
}

@Bean
open fun testJob(
batch: BatchDsl,
): Job = batch {
open fun testJob(): Job = batch {
job("testJob") {
step("testStep") {
tasklet(
{ _, _ -> RepeatStatus.FINISHED },
ResourcelessTransactionManager(),
transactionManager,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import org.springframework.batch.core.Job
import org.springframework.batch.core.repository.JobRepository
import org.springframework.batch.repeat.RepeatStatus
import org.springframework.batch.support.transaction.ResourcelessTransactionManager
import org.springframework.boot.autoconfigure.batch.BatchDataSource
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.PlatformTransactionManager
import java.time.format.DateTimeFormatter
import javax.sql.DataSource

@Configuration
open class TestJobConfig {
open class TestJobConfig(
private val batch: BatchDsl,
private val transactionManager: PlatformTransactionManager,
) {

@Bean
open fun removeJob(
Expand All @@ -45,14 +48,12 @@ open class TestJobConfig {
}

@Bean
open fun testJob(
batch: BatchDsl,
): Job = batch {
open fun testJob(): Job = batch {
job("testJob") {
step("testStep") {
tasklet(
{ _, _ -> RepeatStatus.FINISHED },
ResourcelessTransactionManager(),
transactionManager,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import org.springframework.batch.core.Job
import org.springframework.batch.core.repository.JobRepository
import org.springframework.batch.repeat.RepeatStatus
import org.springframework.batch.support.transaction.ResourcelessTransactionManager
import org.springframework.boot.autoconfigure.batch.BatchDataSource
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.PlatformTransactionManager
import javax.sql.DataSource

@Configuration
open class TestJobConfig {
open class TestJobConfig(
private val batch: BatchDsl,
private val transactionManager: PlatformTransactionManager,
) {

@Bean
open fun removeJob(
Expand All @@ -43,14 +46,12 @@ open class TestJobConfig {
}

@Bean
open fun testJob(
batch: BatchDsl,
): Job = batch {
open fun testJob(): Job = batch {
job("testJob") {
step("testStep") {
tasklet(
{ _, _ -> RepeatStatus.FINISHED },
ResourcelessTransactionManager(),
transactionManager,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ import com.navercorp.spring.batch.plus.kotlin.configuration.BatchDsl
import org.springframework.batch.core.Job
import org.springframework.batch.core.repository.JobRepository
import org.springframework.batch.repeat.RepeatStatus
import org.springframework.batch.support.transaction.ResourcelessTransactionManager
import org.springframework.boot.autoconfigure.batch.BatchDataSource
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.PlatformTransactionManager
import javax.sql.DataSource

@Configuration
open class TestJobConfig {
open class TestJobConfig(
private val batch: BatchDsl,
private val transactionManager: PlatformTransactionManager,
) {

@Bean
open fun removeJob(
Expand All @@ -44,14 +47,12 @@ open class TestJobConfig {
}

@Bean
open fun testJob(
batch: BatchDsl,
): Job = batch {
open fun testJob(): Job = batch {
job("testJob") {
step("testStep") {
tasklet(
{ _, _ -> RepeatStatus.FINISHED },
ResourcelessTransactionManager(),
transactionManager,
)
}
}
Expand Down
Loading

0 comments on commit 1ebb30e

Please sign in to comment.