Java Code Examples for org.springframework.cloud.task.repository.dao.JdbcTaskExecutionDao

The following examples show how to use org.springframework.cloud.task.repository.dao.JdbcTaskExecutionDao. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void testDefaultDataSourceConfiguration() throws Exception {
	this.context = new AnnotationConfigApplicationContext(
			DefaultDataSourceConfiguration.class);

	DataSource dataSource = this.context.getBean(DataSource.class);

	TaskExecutionDaoFactoryBean factoryBean = new TaskExecutionDaoFactoryBean(
			dataSource);
	TaskExecutionDao taskExecutionDao = factoryBean.getObject();

	assertThat(taskExecutionDao instanceof JdbcTaskExecutionDao).isTrue();

	TaskExecutionDao taskExecutionDao2 = factoryBean.getObject();

	assertThat(taskExecutionDao == taskExecutionDao2).isTrue();
}
 
Example 2
Source Project: spring-cloud-task   Source File: TestDBUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a pagingQueryProvider specific database type with a query containing a where
 * clause.
 * @param databaseProductName of the database.
 * @param whereClause to be applied to the query.
 * @return a PagingQueryProvider that will return the requested information.
 * @throws Exception exception thrown if error occurs creating
 * {@link PagingQueryProvider}.
 */
public static PagingQueryProvider getPagingQueryProvider(String databaseProductName,
		String whereClause) throws Exception {
	DataSource dataSource = getMockDataSource(databaseProductName);
	Map<String, Order> orderMap = new TreeMap<>();
	orderMap.put("START_TIME", Order.DESCENDING);
	orderMap.put("TASK_EXECUTION_ID", Order.DESCENDING);
	SqlPagingQueryProviderFactoryBean factoryBean = new SqlPagingQueryProviderFactoryBean();
	factoryBean.setSelectClause(JdbcTaskExecutionDao.SELECT_CLAUSE);
	factoryBean.setFromClause(JdbcTaskExecutionDao.FROM_CLAUSE);
	if (whereClause != null) {
		factoryBean.setWhereClause(whereClause);
	}
	factoryBean.setSortKeys(orderMap);
	factoryBean.setDataSource(dataSource);
	PagingQueryProvider pagingQueryProvider = null;
	try {
		pagingQueryProvider = factoryBean.getObject();
		pagingQueryProvider.init(dataSource);
	}
	catch (Exception e) {
		throw new IllegalStateException(e);
	}
	return pagingQueryProvider;
}
 
Example 3
private void buildTaskExecutionDao(DataSource dataSource) {
	DataFieldMaxValueIncrementerFactory incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(
			dataSource);
	this.dao = new JdbcTaskExecutionDao(dataSource, this.tablePrefix);
	String databaseType;
	try {
		databaseType = DatabaseType.fromMetaData(dataSource).name();
	}
	catch (MetaDataAccessException e) {
		throw new IllegalStateException(e);
	}
	((JdbcTaskExecutionDao) this.dao).setTaskIncrementer(incrementerFactory
			.getIncrementer(databaseType, this.tablePrefix + "SEQ"));
}
 
Example 4
@Before
public void setup() throws Exception {
	this.factoryBean = new SqlPagingQueryProviderFactoryBean();
	this.factoryBean.setDataSource(TestDBUtils.getMockDataSource("MySQL"));
	this.factoryBean.setDatabaseType("Oracle");
	this.factoryBean.setSelectClause(JdbcTaskExecutionDao.SELECT_CLAUSE);
	this.factoryBean.setFromClause(JdbcTaskExecutionDao.FROM_CLAUSE);
	Map<String, Order> orderMap = new TreeMap<>();
	orderMap.put("START_TIME", Order.DESCENDING);
	orderMap.put("TASK_EXECUTION_ID", Order.DESCENDING);
	this.factoryBean.setSortKeys(orderMap);

}
 
Example 5
@Bean
TaskExecutionDao taskExecutionDao(DataSource dataSource) {
	return new JdbcTaskExecutionDao(dataSource);
}
 
Example 6
@Bean
TaskExecutionDao taskExecutionDao(DataSource dataSource) {
	return new JdbcTaskExecutionDao(dataSource);
}