For example, imagine needing to fetch the details on an object in a database for a customer record.
In a traditional service layer, you might use EJB or SOAP, each very complex, and inflexible formats
requiring sophisticated clients. With REST, it might be as easy as performing a GET on a URL
HTTPS, and employ authentication. Need the customer record in XML, JSON, and HTML? You might
change the suffix or send a parameter indicating the payload type. Creation of a new record could be as
simple as a parameterized HTTP PUT against a URL. Deletion of existing records is as simple as an HTTP
DELETE request against a URL. Needless to say, the model is flexible, and works with existing technology.
REST doesn't just work with HTTP; its main benefit is that it is HTTP. HTTP requests are inherently
stateless, meaning they're proxy-friendly, cluster-friendly, and cache-friendly. It is standard HTTP, so
requests travel through firewalls. Indeed, such endpoints work well with Ajax applications because the
payload is a standard format (typically XML, JSON, HTML, or anything else you can imagine wanting
Spring Roo, a very exciting technology announced at SpringOne Europe in 2009, is a sophisticated
round-tripping code generator that makes it quicker and easier than you've ever imagined to create and
evolve Spring applications. This framework makes use of code generation and round-tripping to support
dynamically building a request-response-oriented Spring MVC application with a working Maven build
system, JUnit tests, JPA entities, and more. If you're thinking this all sounds like Ruby on Rails, you
wouldn't be the only one. Naturally, Roo was designed to leverage Spring's capabilities and to provide
tight integration with IDEs. Roo provides a shell that you can use to dynamically navigate the runtime
model of your application. Spring Roo enables the creation of a meta model—a model of your
application—that it uses to generate HTML views, services, entities, controllers, unit tests, Data Access
Objects (DAOs) that you can extend, custom finder methods that you can add if you like, and more.
Currently the “interface” to this model is the aforementioned shell, which is built on top of Maven,
although there's no reason it couldn't also be surfaced through Ant or Buildr. The shell takes simple
commands and generates the scaffolding needed to satisfy the requests. Because it's built on top of
Maven, projects generated with Spring Roo open and work out of the box with all leading IDEs including
Eclipse, Netbeans, and IntelliJ IDEA.
Spring is a powerful tool in Java, but it brings a lot to the table for other platforms, too. Spring.NET
is a well known example. Spring Python released 1.0 recently. Spring Python provides a dependency
injection container, an AOP container and a unified set of APIs—surfaced as the familiar template
objects you're familiar with in the classic Spring. Spring Python offers an XML configuration, but it
sometimes almost seems like overkill given how expressive and succinct Python itself is. So it's no
surprise that Spring Python came out of the gate with Python Config, based on decorators (decorators
are like Java annotations or .NET attributes but with more innate flexibility), à la Spring Java Config
(which is discussed later in this chapter). Besides a very robust AOP facility and a Dependency Injection
(DI) container, Spring Python provides support for database access, transactions, remoting, and
security, among others. Spring Python ships with a console (“coily”) and a plug-in system so that you
can install functionality independent of the main release.
SpringSource bought G2One, the parent company behind the Groovy and Grails technologies in
November, 2008. The purchase could herald many changes, not the least of which is tighter integration
between Spring and Groovy. Already, SpringSource has announced a conference focused on both Spring
and Groovy technologies called SpringOne 2GX.