Spring Petclinic is on Github!

Engineering | Michael Isvy | March 21, 2013 | ...

We are pleased to announce that the Spring Petclinic sample application has been refactored.

The source code is now available on github. Here is a screenshot of the new application:

And here is an overview of the new architecture:

Spring, Spring, Spring

We have used the following Spring features:

  • Dependency Injection using Annotations
  • Data Access Integration using jdbc (JdbcTemplate), JPA or Spring Data JPA (repository layer). You can choose which implementation to use by setting up the corresponding bean profile in web.xml or in one of the JUnit tests.
  • Transactions using @Transactional (service layer)
  • Caching using @Cacheable with ehcache as a cache implementation (service layer)
  • Aspect Oriented Programming (to monitor how many times has been called each of the Repository methods)
  • Spring MVC: Form validation using Bean Validation (JSR-303)
  • Spring MVC: content negotiation (html, xml or atom) using ContentNegotiatingViewResolver.
  • Spring MVC: exception handling using SimpleMappingExceptionResolver
  • Spring MVC: use of the Spring MVC Test Framework

 

Our Vibrant Community

We have had quite a lot of contributions from experts in our community (including the leads of several open source projects).

 

Thymeleaf

In case you haven’t heard of it yet, Thymeleaf can be seen as a replacement for JSP. it defines itself as an  XML / XHTML / HTML5 template engine.

It is based on some plain HTML files with a little bit of namespace magic.

Daniel and Soraya from the Thymeleaf project have created a Spring-Petclinic branch that uses Thymeleaf instead of JSP. They have documented the migration steps in this blog entry: http://www.thymeleaf.org/petclinic.html

The Thymeleaf branch of Spring Petclinic is available here: https://github.com/thymeleaf/thymeleafexamples-petclinic

To learn more about Thymeleaf: http://www.thymeleaf.org

To follow Thymeleaf on twitter: https://twitter.com/thymeleaf

 

Dandelion

Dandelion provides a set of taglibs that you can use with JSP or Thymeleaf.

We have used it inside Spring-Petclinic to work with DataTables. It generates tables based on jQuery DataTables and Bootstrap.

You can do things like that:


<datatables:table data="${ownerList}" id="dataTable"  theme="bootstrap2" export="pdf">
 <datatables:column title="Name" property="name" sortable="true" />
 <datatables:column title="Address" property="address" sortable="true" />
</datatables:table>

The output html table then looks like this:

Dandelion is used inside the main branch of Spring Petclinic.

Thibault Duchateau from the Dandelion project has written a nice blog entry that describes the migration of the Spring Petclinic application

To learn more about Dandelion:  http://dandelion.github.com/

To follow them on twitter: https://twitter.com/dandelion_proj

 

Maven or Gradle?

By default, Spring Petclinic uses Maven as it is the most common choice for Java applications. While Spring Petclinic is fairly small in comparison to most real-life applications, its Maven pom.xml file is pretty verbose already.

Li Yanhui from Thoughtworks China has been nice enough to migrate Spring Petclinic to Gradle. That is a great way to compare Maven and Gradle side by side. The build.gradle configuration file is indeed much simpler to understand. It currently contains 143 lines (as opposed to 543 lines for the Maven POM).

You can browse the Gradle-based version of Spring Petclinic here: https://github.com/whimet/spring-petclinic Thanks to them we have been able to identify a few places inside Spring Petclinic that contained code duplication and lacked of automated testing.

 

Performance Testing: Let’s Scale!

Would it be possible to take Spring Petclinic as it is now and scale it up to 1000 requests per second on a single server instance? Julien Dubois from Ippon Technologies has written a great series of five blog entries on that topic.

It answers questions such as: - Should I rely on the session context? (part 2) - Which Apache Tomcat connector should I use? (part 2) - Which database connection pool should I use? (part 3) - Is JDBC faster than JPA or Spring Data JPA? ( part 4) - What are the pros of using OpenSessionInViewFilter? ( part 4)

 

References

Spring Petclinic on GitHub Spring Petclinic on Cloud Foundry Petclinic + Thymeleaf Petclinic + Gradle

 

When.js 2.0.0 Released

Releases | Jeremy Grelle | March 20, 2013 | ...

Dear Spring Community,

We are pleased to announce the release of when.js 2.0.0.

When.js is cujojs’s lightweight Promises/A+ and when() implementation, and powers the async core of wire.js, cujojs’s IOC Container. It also provides several other useful Promise-related concepts, such as joining multiple promises, mapping and reducing collections of promises, and timed promises.

This major release brings full Promises/A+ compliance, and async promise resolutions. It also includes a few new features, including a new when/keys module for working with object keys.

See the cujojs discussion group for further detail, and check out the full changelog for more info and direct links to docs for the new features.

Webinar Replay: Multi-Client Development with Spring

News | Pieter Humphrey | March 18, 2013 | ...

No application is an island and this is more obvious today than ever as applications extend their reach into people's pockets, desktops, tablets, TVs, Blu-ray players and cars. What's a modern developer to do to support these many platforms? In this talk, join Josh Long to learn how Spring can extend your reach through (sometimes Spring Security OAuth-secured) RESTful services exposed through Spring MVC, HTML5 and client-specific rendering thanks to Spring Mobile, and powerful, native support for Android with Spring Android.


About the speaker

Josh Long

Josh Long

Josh Long is the Spring developer advocate. Josh is the lead author on Apress’ Spring Recipes, 2nd Edition, and a SpringSource committer and contributor. When he's not hacking on code, he can be found at the local Java User Group or at the local coffee shop. Josh likes solutions that push the boundaries of the technologies that enable them. His interests include scalability, BPM, grid processing, mobile computing and so-called "smart" systems. He blogs at blog.springsource.org or joshlong.com and can be found on Twitter at @starbuxman.

More About Josh »

Spring Data GemFire 1.3.0 Released

Engineering | David Turanski | March 14, 2013 | ...

I am pleased to announce the GA release of Spring Data GemFire 1.3.0. In addition to many minor bug fixes and enhancements, this release includes some notable new features to make writing Java applications with GemFire even easier:

Annotation Support For Functions

GemFire provides the ability to "bring the code to the data" by providing a framework for remote function execution. In keeping with Spring's core values, Spring Data GemFire hides the boilerplate code necessary to register and execute remote functions, allowing you to write POJOs and focus on application logic. See the Annotation Support for Function Execution chapter in the Spring Data GemFire Reference Guide for details.

Simplified Connection to a GemFire Datasource

GemFire exposes a lot of options for tuning the performance of it's connection pool, and to configure how local data is managed an synchronized. The Spring Data GemFire namespace supports all of these options, however many applications are clients that simply need read/write access to the GemFire data grid. For this class of applications, it is now possible to connect to GemFire as a client without explicitly configuring a pool or client regions:

 <gfe-data:datasource>
        <gfe-data:locator host="${host}" port="${port}"/>
 </gfe-data:datasource>

The above configuration will create a client cache, pool, and proxy client regions for all available regions on the server, with sensible defaults, and register them as Spring beans.

JSON Support

GemFire 7.0 provides the ability to store JSON with full query support. Typically this requires the application to use the JSONFormatter to convert GemFire's internal format to and from JSON Strings. Spring Data GemFire now provides an option to perform this conversion automatically for selected regions, as will as one way conversion from Object to JSON using Jackson's ObjectMapper. This feature uses Spring AOP to intercept appropriate operations on Region and GemFireTemplate. See the Spring Data GemFire Reference Guide for details.

Performance Improvements in STS 3.2.0

Engineering | Martin Lippert | March 12, 2013 | ...

The latest release of the Spring Tool Suite (3.2.0) contains a large number of performance improvements in many different areas. We are not only adopting the latest improvements from the Eclipse Juno SR2 maintenance release (which fixes a large number of performance issues with the new Eclipse 4 platform UI), we also worked on the performance of many of the STS internals, specifically targeting Java editing and build times for Spring projects.

To demonstrate the improvements, here is a quick screencast showing STS 3.1.0 and 3.2.0 side-by-side:

There is still more to do and we will continue to work on these areas for the STS 3.3.0 release, scheduled to arrive in July 2013. If you want to know more details, watch for further improvements, submit additional information, and/or report specific performance or memory issues, please watch/use this JIRA ticket: https://issuetracker.springsource.com/browse/STS-3054

SpringOne 2GX 2012 Replays: Addressing Messaging Challenges Using Open Technologies, Introduction to Spring Integration and Spring Batch

News | Pieter Humphrey | March 12, 2013 | ...

Addressing Messaging Challenges Using Open Technologies

For Modern Applications Many businesses are faced with some new messaging challenges for modern applications, such as horizontal scalability of the messaging tier, heterogeneous messaging systems and access methods, and extreme transaction processing. This presentation/demo will cover how businesses can overcome these messaging challenges with the use of Spring and RabbitMQ technologies.

Tom will build a case for AMQP, explain how SpringSource is providing AMQP support via Spring AMQP and Spring Integration, explain how RabbitMQ is a modern messaging solution that offers a reliable, highly available, scalable and portable messaging system with predictable and consistent throughput and latency, and demonstrate how Spring Integration and RabbitMQ can be progressively introduced into a standard Spring web application.


 

About the speaker

Tom McCuch

Tom McCuch

Tom McCuch is a Solution Engineer for Hortonworks with over twenty two years of experience in software engineering. Tom specializes in the architecture, implementation, and deployment of distributed systems requiring high Reliability, Availability, and Scalability (RAS) features. Prior to Hortonworks, Tom worked for SpringSource - handling field architecture for their global accounts including Financial Services, Transportation, and Energy. Tom has consulted enterprise clients across multiple industries in the architecture of mission-critical solutions based on open source software as well as led the engineering of enterprise Java middleware supporting next-generation telecommunications products deployed at tier-1 telcos both in the U.S. and Europe.

More About Tom »

Oleg Zhurakousky

Oleg Zhurakousky

Oleg is a Principal Architect with Hortonworks responsible for architecting scalable BigData solutions using various OpenSource technologies available within and outside the Hadoop ecosystem. Before Hortonworls Oleg was part of the SpringSource/VMWare where he was a core engineer working on Spring Integration framework, leading Spring Integration Scala DSL and contributing to other projects in Spring portfolio. He has 17+ years of experience in software engineering across multiple disciplines including software architecture and design, consulting, business analysis and application development. Oleg has been focusing on professional Java development since 1999. Since 2004 he has been heavily involved in using several open source technologies and platforms across a number of projects around the world and spanning industries such as Teleco, Banking, Law Enforcement, US DOD and others. As a speaker Oleg presented seminars at dozens of conferences worldwide (i.e.SpringOne, JavaOne, Java Zone, Jazoon, Java2Days, Scala Days, Uberconf, and others).

More About Oleg »

 

Introduction to Spring Integration and Spring Batch

In this session you will learn what Spring Integration and Spring Batch are all about, how they differ, their commonalities, and how you can use Spring Batch and Spring Integration together.

We will provide a short overview of the Enterprise Integration Patterns (EIP) as described in the highly influential book of the same name. Based on these patterns, we will then see how Spring Integration enables the development of Message-driven applications. This allows you to not only modularize new or existing applications but also makes it easy to integrate with external systems.

This session will also introduce Spring Batch. Spring Batch addresses the needs of any batch process, be it complex calculations in large financial institutions or simple data migration tasks as they exist in many software development projects. We will cover what Spring Batch is, how Spring approaches the concepts of batch and how Spring handles scaling batch processes to be able to handle any volume of data.

You will also see how Spring Integration and Spring Batch maximize the reuse of the integration support provided by the core Spring Framework. In addition to providing a robust, proven foundation, this also flattens the learning curve considerably to all developers already familiar with Spring.



About the speaker

Gunnar Hillert

Gunnar Hillert

Gunnar Hillert is a member of technical staff (MTS) at SpringSource, a division of VMware, Inc. He is a committer for Spring Integration, Spring AMQP and also contributes to the Cloud Foundry project. Gunnar heads the Atlanta Java Users Group and is an organizer for the DevNexus developer conference.

A native from Berlin, Germany, Gunnar has been calling Atlanta home for the past 11 years. He is an avid gardener specializing in anything sub-tropical such as bananas, palm trees and bamboo. As time permits, Gunnar works on his Spanish language skills and he and his wife Alysa are raising their two children tri-lingually (English, German, Spanish). Gunnar blogs at: http://blog.hillert.com/ and you can follow him on Twitter: https://twitter.com/ghillert

More About Gunnar »

Gary Russell

Gary Russell

Gary has been in software engineering, concentrating on Enterprise Integration, for over 30 years on various platforms, and in the Java space since the late '90s.

He has been developing with the Spring Framework since 2004 and joined SpringSource/VMware in 2009 in a consulting role. From 2009 until the end of 2011 he taught Core Spring and Enterprise Integration with Spring to several hundred developers, as well as providing Enterprise Integration consulting services with Spring Integration, Spring Batch and Core Spring.

He has been a committer on the Spring Integration project for nearly 3 years and became a full time member of the engineering team in January 2012.

More About Gary »



This Week in Spring - March 12th, 2013

Engineering | Josh Long | March 12, 2013 | ...

Welcome to another installment of This Week in Spring! This week, there's a lot of Spring Tool Suite news, so be sure to check out

<A href="http://www.springsource.org/sts"> the new release</a> and try it out. 

One last reminder: be sure to join me Thursday for a <a href="http://www.springsource.org/node/4033">webinar introducing Spring's REST and mobile support</a> at 3:00PM GMT (for Europeans) and 10:00AM PST (for North America). 
 
If you've wanted to learn how to build mobile applications for your Spring-based backend services, then this talk is for you. We'll look
at Spring's rich support for REST,
Android and mobile platforms, in general. 

  1. Jonathan Brisbin's announced that Spring Data REST 1.1.0.M1 has been released. The new release is basically a from-the-ground up rewrite. In the new release, there is support for all repositories including MongoDB and GemFire-based repositories.
  2. Martin Lippert has announced that Spring Tool Suite and Groovy/Grails Tool Suite 3.2.0 have been released. The new version is much faster than the previous version, and includes updated support for Eclipse Juno SR2, high-res displays on OSX, and updated compliance with various Spring projects, including Spring Integration 2.2.
  3. Rob Winch has announced that Spring Security SAML 1.0.0.RC2 has Been Released. Spring Security SAML is a third-party contribution that provides SAML support for Spring Security.
  4. Spring Integration 2.2.2 is Now Available! The new release features various important bug fixes.
  5. I'm presenting a webinar on March 14, 2013 - Multi Client Development with Spring! Join me to learn about REST, OAuth, Spring MVC, Spring Android, and much more!
  6. Join Damien Dallimore and David Turanski on a webinar as they introduce the Webinar: Extending Spring Integration for Splunk - March 28th, 2013
  7. New SpringOne2GX replays now available in HD on YouTube: Addressing Messaging Challenges Using Open Technologies, Introduction to Spring Integration and Spring Batch
  8. @SpringSource is launching a (quick) swag-giveaway campaign!
  9. Spring and Groovy/Grails Tool Suite lead Martin Lippert's put together a video comparing the speed of the Tool Suites at 3.1, versus their speed at 3.2.
  10. Speaking of Spring Tool Suite, are you interested in saving 15% on SpringSource Tool Suite Training?
  11. Yuan Ji has a nice post on how to persist Spring Social connections with Spring Data MongoDB. Awesome! I was about to roll up my sleeves and write such an implementation myself! But this should save me some work. Thanks, Yuan!
  12. The Object Partners Inc. blog has a video up that introduces Spring Batch 2 and how to integrate it with Grails. That's pretty cool! They use a Groovy DSL instead of Spring Batch's native XML format to reduce verbosity. One new alternative is the Java configuration support in Spring Batch 2.2.
  13. Petri Kainulainen has a blog post up that introduces Spring Data SOLR query methods.
  14. The Ippon Technologies blog has a nice post on performance tuning the Spring Petclinic sample application.
  15. Michael Simons has a nice post on using the popular, component-oriented web framework Vaadin with Spring
  16.  Nicolas Frankel has a nice post 
     <a href="http://blog.frankel.ch…

Spring Tool Suite and Groovy/Grails Tool Suite 3.2.0 released

Releases | Martin Lippert | March 11, 2013 | ...

Dear Spring Community,

we are happy to announce the next major release of our Eclipse-based tooling today: The Spring Tool Suite (STS) 3.2.0 and the Groovy/Grails Tool Suite (GGTS) 3.2.0.

Highlights from this release include:

  • Eclipse Juno SR2 updates (including Mylyn, EGit, m2e, m2e-wtp)
  • added support for high-res displays on Mac OSX
  • updated bundled tc Server to 2.8.2
  • major performance improvements for working with Spring projects
  • major improvements to the Live Spring Beans Graph
  • added support for Spring Integration 2.2
  • updated to include Groovy 2.0.7 and Grails 2.2.1 (Groovy 2.1 is available from the dashboard)

We continue to ship distributions both on top of Eclipse 3.8 and Eclipse 4.2. While the 4.2 stream of Eclipse has improved a lot in the Eclipse Juno SR2 release, we still recommend using the 3.8-based version for optimal performance and stability.

To download the distributions, please go visit:

Detailed new and noteworthy notes can be found here: STS/GGTS 3.2.0 New & Noteworthy.

Updates from STS/GGTS 3.0.0 and 3.1.0 are available through the automatic…

Spring Data REST 1.1.0.M1 Released

Releases | Jon Brisbin | March 11, 2013 | ...

The Spring Data team is happy to announce the next major step in the evolution of exporting domain objects to the web using RESTful semantics: Spring Data REST 1.1.0.M1 is now available in the SpringSource milestone repository.

Spring Data REST Home | Source on GitHub | Reference Documentation

Export domain objects to the web

Spring Data REST is a set of Spring MVC components that you can add to your own Spring MVC applications that export your Spring Data Repositories to the web using RESTful, HATEOAS semantics. It provides a consistent interaction API by exporting repositories to RESTful URLs that are configurable in a couple different ways.

Spring Data REST supports CRUD for top-level entities (those domain objects directly managed by a Spring Data Repository) by literally writing a single line of code that defines an interface that extends Spring Data's CrudRepository interface. That done, your entities then have full RESTful semantics. You can create new ones, update existing ones, and delete them using standard URLs that are, following the principles of HATEOAS, discoverable. That means the user agent accessing your Spring Data REST application doesn't need to have advance knowledge of what resources you are exporting. It can discover what entites exist and what relationships exist on those entities by successive calls to URLs provided in the JSON. These "links" are the real foundation and power of a HATEOAS REST application.

Changes from the ground up

Version 1.1 is virtually a re-write from the ground up. Not only is it easier to configure than 1.0 and better conforms to Spring MVC expections for the transition to Spring 3.2, but the biggest change in the internals of Spring Data REST is that it now supports other types of Spring Data repository implementations beyond just JPA. The HTTP semantics for CRUD and manging relationships (if the datastore supports it) remain the same no matter what backing datastore is used.

That means it's now possible to export JPA entities and MongoDB entities within the same Spring Data REST application and access those entities using a common URL structure and using the standard Spring HATEOAS Resource representation for all entities and collections. The user agent accessing those RESTful URLs does not need any special knowledge on which datastore the backing entities are managed by and, most importantly, you don't have to write any code to get that functionality!

MongoDB support

Spring Data REST 1.1 now supports exporting MongoDB CrudRepository implementations. The same HTTP semantics apply to MongoDB @Document entities as apply to JPA entities. GET, POST, PUT, DELETE are of course supported, but so is @DBRef. You can view and manage the relationship between two documents using GET, POST, PUT, and DELETE and you can export finder methods based on your @Query definitions. Please reference the spring-data-mongodb reference documentation for the full details of how the object mapping differs from JPA style mapping and how query definitions work.

Gemfire support

Spring Data REST 1.1 now supports exporting entities that use the high-performance Gemfire database to different Regions. Read the Spring Data Gemfire documentation for the full explanation of the vast configuration options and how POJO mapping in Gemfire differs from other mapping technologies.

Neo4J support is next

Spring Data REST 1.1 is now set to support Neo4J GraphRepositorys with the next version of spring-data-neo4j, version 2.3. When that's generally available (which should be around or before the general availablity of Spring Data REST 1.1 RELEASE), you will be able to access @NodeEntitys and their relationships using standard HATEOAS semantics, just like you do with the other datastores.

Add it to your existing apps

Spring Data REST is designed in such a way that you can, if you wish, create an entire application for the Spring Data REST application. It's just a standard Spring MVC webapp after all. But things get really interesting when you add Spring Data REST to your own services.

Spring HATEOAS author Oliver Gierke has created an example application that demonstrates the use of HATEOAS principles in a modern web application. It's called spring-restbucks and is an implementation of the Restbucks application described in the Systematic Theology of REST services: REST in Practice by Jim Webber, Savas Parastatidis and Ian Robinson.

Mixin REST services

By mixing Spring Data REST with your other RESTful services, you can get a seamless integration between those domain objects exported by Spring Data REST--objects for which you didn't have to write any code to have them exposed--and those services that don't represent an actual entity but a process. You can see an example of how a payment service might interact with domain object CRUD in the spring-restbucks application, where credit card payment processing is handled by a custom controller, while object CRUD is handled by Spring Data REST. Your custom controllers can actually piggyback onto the Spring Data REST URLs so that a consistent and simple URL structure can be maintained throughout the appliation, no matter whether the URL refers to your custom controller, a Spring Data REST JPA Repository, or any of the other supported Repository styles.

It's not exclusive

It's not an either-or with Spring Data REST. If you don't want all of your Repositories exposed to a web client, no problem! There a several different ways you can turn off functionality for Repositories. You can embed annotations into your source code or, if you don't have access or simply can't add the Spring Data REST annotations, you can use a fluent, DSL-style configuration to tell Spring Data REST how your resources should be exposed. Using Spring Data REST in your application isn't an exclusive committment to only one way of doing things. Spring Data REST is structured in a what that it will play nicely with your existing application so you can incorporate those bits of functionality from Spring Data REST you want, while still maintaining all the custom-coded services you're used to creating in Spring MVC controllers.

JSONP support moving to a filter

The JSONP support that was built into Spring Data REST 1.0 has been removed from the core framework in preference to a forthcoming general-purpose JSONP Serlvet Filter that will work much better than the way JSONP was implemented in version 1.0. When that filter is generally available, then JSONP support can be added not just to Spring Data REST, but virtually any Servlet-based REST resource.

Installation and Documentation

To get started playing with Spring Data REST, have a look at the reference documentation to get the lay of the land, so to speak, and get started playing with it in your own application by simply adding a dependency to the spring-data-rest-webmvc artifact (currently at 1.1.0.M1 in the SpringSource milestone repository) then import the Spring Data REST configuration like you see being done in the spring-restbucks application.

Learn more at CONFESS_2013

If you're planning on attending CONFESS_2013 in Vienna the first week of April, then you can hear all about Spring Data REST at my talk on exporting entities to the web.

Links

Spring Data REST Home | Source on GitHub | Reference Documentation

Get the Spring newsletter

Stay connected with the Spring newsletter

Subscribe