Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation references a class that's deprecated in v4 and removed in v5: MapJobRepositoryFactoryBean #3834

Closed
Calin-Cosma opened this issue Jan 21, 2021 · 5 comments
Labels
status: superseded Issues that are superseded by other issues

Comments

@Calin-Cosma
Copy link

https://docs.spring.io/spring-batch/docs/5.0.0-SNAPSHOT/reference/html/job.html#inMemoryRepository

references MapJobRepositoryFactoryBean which is deprecated in v4 and it's supposed to have been removed in v5.

Same documentation for v4 and current.

@Calin-Cosma Calin-Cosma added the status: waiting-for-triage Issues that we did not analyse yet label Jan 21, 2021
@fmbenhassine
Copy link
Contributor

it's supposed to have been removed in v5.

We did not start working on v5 yet. We have indeed deprecated the MapJobRepositoryFactoryBean in v4 for removal in v5, but the actual removal did not happen yet. You can track the progress on the removal of deprecated APIs in #3836 , in which the documentation will be updated accordingly.

@fmbenhassine fmbenhassine added status: superseded Issues that are superseded by other issues and removed status: waiting-for-triage Issues that we did not analyse yet labels Jan 21, 2021
@Calin-Cosma
Copy link
Author

But the documentation for version 4 also references the already deprecated class:

https://docs.spring.io/spring-batch/docs/4.3.x/reference/html/job.html#inMemoryRepository

If that class is deprecated in v4, it means there's another way to achieve the same thing, and that proper/better way is what should be shown in the documentation.

@fmbenhassine
Copy link
Contributor

All deprecations have been documented in the What's new section. However, the replacement of each deprecated API can be found in its Javadoc, like the one of MapJobRepositoryFactoryBean for example:

Deprecated as of v4.3 in favor or using the JobRepositoryFactoryBean with an in-memory database.

We will provide a complete migration guide in v5 with how to replace each deprecated API. That said, I understand what you are looking for, which I guess some "warning" or "heads-up" note about the deprecated API in its section itself in the reference documentation (in addition to its javadoc). I don't think we should now update the reference docs for all the 30+ deprecated APIs (listed in #3836), but this is something we will certainly consider in future releases.

@Calin-Cosma
Copy link
Author

Calin-Cosma commented Jan 25, 2021 via email

@AlexKorole
Copy link

AlexKorole commented Dec 25, 2023

Our project should be executed from command line. I rewrote in such way, see code below:

class MyTasklet extends CommonBehaviour implements Tasklet {
    public RepeatStatus execute(@Nullable StepContribution contribution,
                                @Nullable ChunkContext chunkContext) {
        System.out.println("Hello, I am tasklet!");
        return RepeatStatus.FINISHED;
    }
}

/**
 * Starting point of application
 */
public class Main {

    MyTasklet myTasklet = new MyTasklet();

    ApplicationContext context;
    public DataSource dataSource() {
        return new EmbeddedDatabaseBuilder()
                .setType(EmbeddedDatabaseType.H2)
                .addScript("/org/springframework/batch/core/schema-drop-h2.sql")
                .addScript("/org/springframework/batch/core/schema-h2.sql")
                .build();
    }

    public ResourcelessTransactionManager transactionManager() {
        return new ResourcelessTransactionManager();
    }

    public JobRepository jobRepository() throws Exception {
        JobRepositoryFactoryBean jobRepository = new JobRepositoryFactoryBean();
        jobRepository.setDataSource(dataSource());
        jobRepository.setTransactionManager(transactionManager());
        jobRepository.afterPropertiesSet();
        return jobRepository.getObject();
    }

    public TaskExecutorJobLauncher jobLauncher() throws Exception {
        TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher();
        jobLauncher.setJobRepository(jobRepository());
        jobLauncher.afterPropertiesSet();
        return jobLauncher;
    }

    public Step step(JobRepository jobRepository) {
        StepBuilder stepBuilderOne = new StepBuilder("LoadAndSendRow", jobRepository);
        return stepBuilderOne.tasklet(myTasklet, transactionManager())
                .build();
    }

    public Job job(JobRepository jobRepository) {
        return new JobBuilder("job", jobRepository)
                .start(step(jobRepository))
                .build();
    }

    public static void main(String[] args) {
        Main obj = new Main();
        obj.runBatchTask();


    }

    private void runBatchTask() {
        try {
            JobLauncher jobLauncher = jobLauncher();
            Job job = job(jobRepository());
            JobExecution execution = jobLauncher.run(job, new JobParameters());
        } catch (Exception e) {
            System.out.println(e.getStackTrace());
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded Issues that are superseded by other issues
Projects
None yet
Development

No branches or pull requests

3 participants