Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- @ConfigurationProperties("oracle")
- class OracleConfiguration {
- @Autowired
- private ConnectionUsernameProvider contextProvider
- private OracleDataSource dataSourceInternal
- String username
- String password
- String url
- @Bean
- @Profile(["local"])
- OracleDataSource oracleDataSource() throws SQLException {
- dataSourceInternal.user = username
- dataSourceInternal.password = password
- dataSourceInternal.URL = url
- dataSourceInternal.implicitCachingEnabled = true
- dataSourceInternal.fastConnectionFailoverEnabled = true
- return dataSourceInternal
- }
- @Bean
- @Profile(["dev", "uat", "prod"])
- OracleDataSource jndiDataSource() {
- JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup()
- dataSourceInternal =
- dataSourceLookup.getDataSource("java:comp/env/jdbc/datasource") as OracleDataSource
- return dataSourceInternal
- }
- @Bean
- @Primary
- DataSource dataSource() throws SQLException {
- ProxyDataSource dataSource = new ProxyDataSource(dataSourceInternal, contextProvider)
- return dataSource
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement