File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
spring-framework-reference/src Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -1491,14 +1491,26 @@ public class JndiDataConfig {
1491
1491
}</programlisting >
1492
1492
1493
1493
<programlisting language =" java" >@Configuration
1494
- @Profile("production")
1495
- public class JndiDataConfig {
1494
+ public class TransferServiceConfig {
1495
+
1496
+ @Autowired DataSource dataSource;
1496
1497
1497
1498
@Bean
1498
- public DataSource dataSource() throws Exception {
1499
- Context ctx = new InitialContext();
1500
- return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource" );
1499
+ public TransferService transferService() {
1500
+ return new DefaultTransferService(accountRepository(),
1501
+ feePolicy() );
1501
1502
}
1503
+
1504
+ @Bean
1505
+ public AccountRepository accountRepository() {
1506
+ return new JdbcAccountRepository(dataSource);
1507
+ }
1508
+
1509
+ @Bean
1510
+ public FeePolicy feePolicy() {
1511
+ return new ZeroFeePolicy();
1512
+ }
1513
+
1502
1514
}</programlisting >
1503
1515
1504
1516
<programlisting language =" java" >package com.bank.service;
You can’t perform that action at this time.
0 commit comments