package jj.tech.paolu.config.lock;

import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.jdbc.lock.DefaultLockRepository;
import org.springframework.integration.jdbc.lock.JdbcLockRegistry;
import org.springframework.integration.jdbc.lock.LockRepository;

@Configuration
public class LockRegistryConfiguration {
	
	@Bean
	public DefaultLockRepository defaultLockRepository(DataSource dataSource){
	   return new DefaultLockRepository(dataSource);	//DefaultLockRepository.setTimeToLive(1000 * 100);
	}

	@Bean
	public JdbcLockRegistry jdbcLockRegistry(DefaultLockRepository lockRepository){
	   return new JdbcLockRegistry(lockRepository);
	}

}
