img
.
Table 14-1. Maven Dependencies for Validation
Group ID
Artifact ID
Version
Description
1.0.0.GA
JSR-303 API library.
javax.validationvalidation-api
4.2.0.Final Hibernate Validator library that supports JSR-303
org.hibernate
hibernate-
Bean Validation.
validator
2.0
Joda-time (joda-time.sourceforge.net/) is a date-
joda-time
joda-time
time API that Spring Data JPA uses. In this chapter, we
will use it in our domain objects.
1.6.1
The SLF4J logging library (www.slf4j.org) will be used
org.slf4j
slf4j-log4j12
as the logging library for the samples in this chapter.
This library will help chain the SLF4J logger to the
underlying log4j library for logging purposes.
Spring Type Conversion System
In Spring 3, a new type conversion system was introduced, providing a powerful way to convert between
any Java types within Spring-powered applications. In this section, we will discuss how this new service
can perform the same functionality provided by the previous PropertyEditor support, as well as how it
supports the conversion between any Java types. We will also demonstrate how to implement a custom
type converter using the Converter SPI.
Conversion from a String Using PropertyEditors
In Chapter 5, we covered how Spring handles the conversion from a String in the properties files into
the properties of POJOs by supporting PropertyEditors. Let's do a quick review here, and then we will
cover how Spring's Converter SPI (available since 3.0) provides a more powerful alternative.
Consider a Contact class with a couple of attributes, as in Listing 14-1.
Listing 14-1. The Contact Class
package com.apress.prospring3.ch14.domain;
import java.net.URL;
import org.joda.time.DateTime;
public class Contact {
private String firstName;
private String lastName;
private DateTime birthDate;
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home