REST in Spring 3: RestTemplate

Engineering | Arjen Poutsma | March 27, 2009 | ...

In an earlier post, I blogged about the REST capabilities we added to Spring @MVC version 3.0. Later, Alef wrote about using the introduced functionality to add an Atom view to the Pet Clinic application. In this post, I would like to introduce the client-side capabilities we added in Milestone 2.

RestTemplate

The RestTemplate is the central Spring class for client-side HTTP access. Conceptually, it is very similar to the JdbcTemplate, JmsTemplate, and the various other templates found in the Spring Framework and other portfolio projects. This means, for instance, that the RestTemplate is thread-safe once constructed, and that you can use callbacks to customize its operations.

RestTemplate Methods

The main entry points of the template are named after the six main HTTP methods:

HTTPRestTemplate
DELETEdelete(String, String...)
GETgetForObject(String, Class, String...)
HEADheadForHeaders(String, String...)
OPTIONSoptionsForAllow(String, String...)
POSTpostForLocation(String, Object, String...)
PUTput(String, Object, String...)

The names of these methods clearly indicate which HTTP method they invoke, while the second part of the name indicates what is returned. For instance, getForObject() will perform a GET, convert the HTTP response into an object type of your choice, and returns that object. postForLocation will do a POST, converting the given object into a HTTP request, and returns the response HTTP Location header where the newly created object can be…

Using Bundlor in Eclipse

Engineering | Christian Dupuis | March 26, 2009 | ...

In an earlier blog, Ben introduced Bundlor, the concepts behind it and how to use it from the command line as well as from within ANT and Maven. In this post I'll show how Bundlor can be used in an Eclipse environment.

When developing OSGi-based applications, some users don't want to spend time constantly updating their MANIFEST.MF, but instead want to focus on actual business logic in their application components: in such a scenario the Bundlor Eclipse integration will ensure that the MANIFEST.MF file reflects actual dependencies expressed by code artifacts in the project and removes the need to manually manage classpath settings in Eclipse. Additionally BundlorEclipse can help to cleanly separate runtime dependencies from test dependencies by introducing test-only

See you at SpringOne Europe!

Engineering | Rod Johnson | March 24, 2009 | ...

It's the conference season. Despite the busy schedule, however, one conference stands alone for Spring content. SpringOne Europe is approaching fast. This year, it will be in Amsterdam, from April 27-29. Not only is Amsterdam a great destination in itself, the conference ends just before the Queen's Day holiday in the Netherlands: a fun cultural experience if you can spare an extra day.

SpringOne has always been a great conference, offering deep technical content and comprehensive coverage of Spring topics. We've been particularly busy over the last few months, so this year should be better…

Getting Started with Bundlor

Engineering | Ben Hale | March 20, 2009 | ...

As Rob's post points out, over the last few months we've learned quite a bit about how people want to manage their own OSGi applications.

We found that some developers want to manage their own bundle manifests, but need a bit of help to automate the details such as specifying package versions across a range of imports. Other developers want to have manifests generated based on the content of their project and the dependencies specified in their build files. In addition, both kinds of developers need to work with existing libraries that do not have the necessary OSGi metadata that enable them…

Spring IDE 2.2.2 and dm Server Tools 1.1.2. released

Releases | Christian Dupuis | March 18, 2009 | ...

Dear Spring community,

I'm pleased to announce that our EPL-licensed Spring IDE and dm Server Tools have been updated.

Both releases are mainly addressing bug fixes and minor improvements. Additionally the dm Server Tools got some new features like Bundle and PAR export as well as tailing of application trace files.

You can install both from our new consolidated Eclipse update site available from http://www.springsource.org/update/e3.4 (please note that this update site does not work with a web browser).

Cheers, Christian Dupuis Lead, Spring IDE & SpringSource Tool Suite

Our plans for building OSGi applications

Engineering | Rob Harrop | March 18, 2009 | ...

In the recent days and weeks, we've seen an increasing amount of interest in the future of build solutions for applications made up of OSGi bundles. Due to our heavy involvement with OSGi, this is something that is near and dear to our hearts and we've spent a long time looking at customer requirements and solutions for those requirements. In this blog entry, I will outline the requirements that we have identified and present the solutions that we see to these requirements.

I'm very interested in hearing from anyone who has extra requirements, thinks the requirements we have are bogus or has…

Announcing SpringSource Tool Suite 2.0

Engineering | Christian Dupuis | March 17, 2009 | ...

Today we are pleased to announce the general availability of the 2.0 version of our SpringSource Tool Suite (STS). You can find the press release here.

For the 2.0 iteration we focused on the two major feature areas that we identified based on the great feedback from our customer base and community: provide the best possible environment for Spring-based application development and provide tools to develop enterprise applications based on OSGi and the SpringSource dm Server.

I'd like to use this blog to introduce some of the new Spring development tools of STS 2.0. The new OSGi development tools have already been highlighted in an earlier blog

Adding an Atom view to an application using Spring's REST support

Engineering | Alef Arendsen | March 16, 2009 | ...

In Spring 3.0, Spring MVC will be augmented with REST support. This post describes how to use the REST support to implement an AtomView on top of a simple sample application. Follow this step-by-step process to see how easy it is to implement an AtomView on top of a simple application with the new REST support in Spring MVC.

Step 1: Download the application skeleton

Attached to this blog entry, near the bottom, you will find a simple download that holds a skeleton for a web application. Inside, you will find all Spring 3.0 binaries needed for this application, plus a few extras needed for the Atom functionality. The Spring binaries are based on a nightly build and might be replaced with the final builds once Spring 3.0 has gone final.

Next, load up the project in Eclipse, using the 'Import > Import Existing Projects into Workspace' wizard (from the File menu). The application is a simple Eclipse Dynamic Web Project with all the infrastructure for Spring MVC setup. So if you are familiar to Spring MVC…

Grails 1.1 Released

Engineering | Graeme Rocher | March 10, 2009 | ...

Hot on the heels of the Groovy 1.6 release, we are pleased to announce that Grails 1.1 final is out and available from the Grails site. There are numerous improvements that are listed in detail in the release notes. However, some of the key ones are:

Standalone GORM: It is now possible to use Grails' ORM layer (built on Hibernate) outside of Grails. There is an example that uses GORM inside a Spring MVC application in the samples/petclinic-mvc directory of the distribution. The example configures a GORM enabled SessionFactory using Spring as follows:


<gorm:sessionFactory base-package="org…

REST in Spring 3: @MVC

Engineering | Arjen Poutsma | March 08, 2009 | ...

In the last couple of years, REST has emerged as a compelling alternative to SOAP/WSDL/WS-*-based distributed architectures. So when we started to plan our work on the next major release of Spring - version 3.0, it was quite clear to us that we had to focus on making the development of 'RESTful' Web services and applications easier. Now, what is and isn't 'RESTful' could be the topic of a whole new post all together; in this post I'll take a more practical approach, and focus on the features that we added to the @Controller model of Spring MVC.

A Bit of Background

Ok, I lied: there is some background first. If you really want to learn about the new features, feel free to skip to the next section.

For me, work on REST started about two years ago, shortly after reading the highly recommended book RESTful Web Services from O'Reilly, by Leonard Richardson and Sam Ruby. Initially, I was thinking about adding REST support to Spring Web Services, but after working a couple of weeks on a prototype, it became clear to me that this wasn't a very good fit. In particular, I found out that I had to copy most of the logic from the Spring-MVC DispatcherServlet

Get the Spring newsletter

Thank you for your interest. Someone will get back to you shortly.

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Tanzu Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all