I have a spring batch application configured as per below link.
https://spring.io/guides/gs/batch-processing/
Now I have to configure step in such a way that it has to take FlatFileItemReader if user input is file and JdbcPagingItemReader if the input is SQL. I would pass the inputs(file/sql) as JobParameters.
From my understanding, everything in the above example by spring are singleton beans which are loaded into ApplicationContext when the application is started. As step can be configured only once with one Reader. How would I configure it to take different Reader's based on user input
I don't prefer creating multiple jobs if only the reader is changing.
I thought of using Factory/Strategy patterns but this are only achievable if Step is not a bean. Here all of them are beans which are loaded during application startup.
Regardless of patterns, a solution to use different Readers in step based on JobParameters would be helpful.