Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. @Configuration
  2. @ConfigurationProperties("oracle")
  3. class OracleConfiguration {
  4.  
  5. @Autowired
  6. private ConnectionUsernameProvider contextProvider
  7.  
  8. private OracleDataSource dataSourceInternal
  9.  
  10. String username
  11.  
  12. String password
  13.  
  14. String url
  15.  
  16. @Bean
  17. @Profile(["local"])
  18. OracleDataSource oracleDataSource() throws SQLException {
  19. dataSourceInternal.user = username
  20. dataSourceInternal.password = password
  21. dataSourceInternal.URL = url
  22. dataSourceInternal.implicitCachingEnabled = true
  23. dataSourceInternal.fastConnectionFailoverEnabled = true
  24. return dataSourceInternal
  25. }
  26.  
  27. @Bean
  28. @Profile(["dev", "uat", "prod"])
  29. OracleDataSource jndiDataSource() {
  30. JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup()
  31. dataSourceInternal =
  32. dataSourceLookup.getDataSource("java:comp/env/jdbc/datasource") as OracleDataSource
  33. return dataSourceInternal
  34. }
  35.  
  36. @Bean
  37. @Primary
  38. DataSource dataSource() throws SQLException {
  39. ProxyDataSource dataSource = new ProxyDataSource(dataSourceInternal, contextProvider)
  40. return dataSource
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement