In Listing 20-12, we just need to bootstrap the ApplicationContext and then keep looping. Spring
Integration will perform file polling within the C:/temp/contact folder, which is defined in the inbound
channel adapter bean. To test it, put the file contacts.xml into the C:/temp/contact folder, and from the
STS console output, you should see that the job will be launched automatically. Some sample output is
shown here (the irrelevant output was omitted).
INFO : org.springframework.integration.file.FileReadingMessageSource - Created message:
[[Payload=\temp\contact\contacts.xml][Headers={timestamp=1326274023267, id=17cc6b63-5694-4160-
a2d6-a75430fa7515}]]
INFO : org.springframework.batch.core.launch.support.SimpleJobLauncher - Job: [FlowJob:
[name=importContactsJob]] launched with the following parameters:
[{inputFile=C:\temp\contact\contacts.xml}]
INFO : org.springframework.batch.core.job.SimpleStepHandler - Executing step: [readWriteStep]
Hibernate: insert into contact (ID, BIRTH_DATE, FIRST_NAME, LAST_NAME, VERSION) values (null,
?, ?, ?, ?)
Hibernate: insert into contact_hobby_detail (CONTACT_ID, HOBBY_ID) values (?, ?)
Hibernate: insert into contact_hobby_detail (CONTACT_ID, HOBBY_ID) values (?, ?)
INFO : com.apress.prospring3.ch20.service.jpa.ContactServiceImpl - Finding all contacts
Hibernate: select contact0_.ID as ID0_, contact0_.BIRTH_DATE as BIRTH2_0_,
contact0_.FIRST_NAME as FIRST3_0_, contact0_.LAST_NAME as LAST4_0_, contact0_.VERSION as
VERSION0_ from contact contact0_
INFO : com.apress.prospring3.ch20.batch.listener.ImportContactJobListener - Contact: Contact -
Id: 1, First name: Clarence, Last name: Ho, Birthday: 1980-07-30T00:00:00.000+08:00
INFO : com.apress.prospring3.ch20.batch.listener.ImportContactJobListener - Contact: Contact -
Id: 2, First name: Scott, Last name: Tiger, Birthday: 1990-11-02T00:00:00.000+08:00
INFO : com.apress.prospring3.ch20.batch.listener.ImportContactJobListener - Contact: Contact -
Id: 3, First name: Kim Fung, Last name: Ho, Birthday: 1980-07-30T00:00:00.000+08:00
INFO : org.springframework.batch.core.launch.support.SimpleJobLauncher - Job: [FlowJob:
[name=importContactsJob]] completed with the following parameters:
[{inputFile=C:\temp\contact\contacts.xml}] and the following status: [COMPLETED]
In the output, you can see that the message was created, the job was launched, and the import
contact job completed successfully.
Spring Batch plus Spring Integration provides a powerful batch job execution and enterprise
integration environment that integrates with Spring application's service layer for consistent business
logic execution seamlessly.
For more details on Spring Integration, we recommend the book Pro Spring Integration (Apress,
2011).
Introducing Spring Roo
Another interesting project in Spring's portfolio is the Spring Roo project (www.springsource.org/spring-
roo). Spring Roo provides a next-generation rapid application development platform that greatly
enhances the productivity of developers of Spring-based applications.
Spring Roo provides an innovative command-line interface with useful hints that can help you
define a Domain Object Model (DOM), persistence layer, service layer, and presentation layer quickly. In
the persistence layer, Spring Roo provides first-class support on JPA 2, and with Spring Roo 1.2, Spring
Data JPA's repository abstraction support was also added.
With Spring Roo, you have the option to have the persistence logic built into the JPA entity classes,
or you can instruct Roo to generate a service layer to host your business logic. JSR-303 is supported out
of the box.
On the presentation layer, Roo provides first-class support for Spring MVC and can generate a basic
user interface automatically with templating support (with Apache Tiles), theming, i18n, validation, and
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home