@@ -312,35 +312,34 @@ public class RewardsTestDatabase {
312
312
</itemizedlist ></para >
313
313
314
314
<para >Here is an example of a Java class providing basic configuration
315
- using the new JavaConfig features: <programlisting language =" java" >@Configuration
316
- public class AppConfig{
317
- @Value("#{jdbcProperties.url}") String jdbcUrl;
318
- @Value("#{jdbcProperties.username}") String username;
319
- @Value("#{jdbcProperties.password}") String password;
320
-
321
- @Bean
322
- public FooServicefooService () {
323
- return new FooServiceImpl(fooRepository());
315
+ using the new JavaConfig features: <programlisting language =" java" >@Configuration
316
+ public class AppConfig{
317
+ private @Value("#{jdbcProperties.url}") String jdbcUrl;
318
+ private @Value("#{jdbcProperties.username}") String username;
319
+ private @Value("#{jdbcProperties.password}") String password;
320
+
321
+ @Bean
322
+ public FooService fooService () {
323
+ return new FooServiceImpl(fooRepository());
324
324
}
325
325
326
- @Bean
327
- public FooRepositoryfooRepository () {
328
- return new HibernateFooRepository(sessionFactory());
326
+ @Bean
327
+ public FooRepository fooRepository () {
328
+ return new HibernateFooRepository(sessionFactory());
329
329
}
330
330
331
- @Bean
332
- public SessionFactorysessionFactory() {
333
- // wire up a session factory using
334
- // AnnotationSessionFactoryBean
335
- asFactoryBean.setDataSource(dataSource());
336
- return (SessionFactory) asFactoryBean.getObject();
337
- }
338
-
339
- @Bean
340
- public DataSourcedataSource() {
341
- return new DriverManagerDataSource(jdbcUrl,
342
- username, password);
343
- }
331
+ @Bean
332
+ public SessionFactory sessionFactory() {
333
+ // wire up a session factory using
334
+ // AnnotationSessionFactoryBean
335
+ asFactoryBean.setDataSource(dataSource());
336
+ return (SessionFactory) asFactoryBean.getObject();
337
+ }
338
+
339
+ @Bean
340
+ public DataSource dataSource() {
341
+ return new DriverManagerDataSource(jdbcUrl, username, password);
342
+ }
344
343
}
345
344
</programlisting > To get this to work you need to add the following component
346
345
scanning entry in your minimal application context XML file.
@@ -431,4 +430,4 @@ public class AppConfig{
431
430
<para >Work in progress... not part of the Spring 3.0 M3 release.</para >
432
431
</section >
433
432
</section >
434
- </chapter >
433
+ </chapter >
0 commit comments