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

Add getDataSource method to DefaultBatchConfigurer #3872

Conversation

acktsap
Copy link
Contributor

@acktsap acktsap commented Mar 26, 2021

When customizing createJobRepository using DefaultBatchConfiguer (according to official docs), it force us to use DataSource bean explicitly.

@Bean
public BatchConfigurer batchConfigurer(DataSource dataSource) {
	return new DefaultBatchConfigurer() {
		@Override
		protected JobRepository createJobRepository() throws Exception {
			JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
			factory.setDataSource(dataSource);
			factory.setTransactionManager(getTransactionManager());
			factory.setTablePrefix("SYSTEM.TEST_");
			factory.afterPropertiesSet();
			return factory.getObject();
		}
	};
}

Using getDataSource() method, we can use like this.

@Bean
public BatchConfigurer batchConfigurer() {
	return new DefaultBatchConfigurer() {
		@Override
		protected JobRepository createJobRepository() throws Exception {
			JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
			factory.setDataSource(getDataSource());
			factory.setTransactionManager(getTransactionManager());
			factory.setTablePrefix("SYSTEM.TEST_");
			factory.afterPropertiesSet();
			return factory.getObject();
		}
	};
}

@acktsap acktsap force-pushed the feature/default-batch-configurer-getdatasource branch from 103d34f to bed4d72 Compare March 31, 2021 11:46
@fmbenhassine fmbenhassine added this to the 5.0.0-M1 milestone Aug 25, 2021
@fmbenhassine
Copy link
Contributor

Rebased and merged as 26fc468. Thank you for your contribution.

@acktsap acktsap deleted the feature/default-batch-configurer-getdatasource branch August 26, 2021 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants