This Week in Spring - March 26, 2013

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

Welcome to another installment of This Week in Spring! This week I'm in chilly (brrr!) London, England and Paris, France, for Devoxx UK and Devoxx FR and - tonight - I gave a talk at Skills Matter for the London Spring User Group. What a pleasant experience. If you're in France and want to talk Spring, don't hesitate to ping me.

  1. The CujoJS team has announced that When.js 2.0 is now available.
  2. I found a few nice posts introducing Spring Integration. Here's part 1 and part 2.
     These posts are very thorough and well worth a read! </LI>
     <LI>New SpringOne2GX replays now available in HD on YouTube: <a href="http://www.springsource.org/node/4302">What's New in Spring Integration 2.2 and Spring Integration, Batch, &amp; Data Lightning Talks</a>.</LI>
     <LI> Did you guys miss SpringOne2GX 2012? Don't fret, Oleg Zhurakousky and Arjen Poutsma's talk introducing <a href="http://t.co/nquWxe7L3u">how to use Spring with Scala is now available on InfoQ</a>. </LI>
     <LI>Michael Isvy's been hard at work refactoring the code 
    	 of the canonical Spring PetClinic reference…

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

 

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

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…

This Week in Spring - March 5th, 2013

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

Welcome back to another installment of This Week in Spring.

We've got a lot to cover, though, so let's get to it!

  1. 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!
  2. Join Damien Dallimore and David Turanski on a webinar as they introduce the Webinar: Extending Spring Integration for Splunk - March 28th, 2013
  3. New SpringOne2GX replays now available in HD on YouTube: Spring Data Repositories: A Deep Dive, and Intro to Cascading
  4. @SpringSource is launching a (quick) swag-giveaway campaign!
  5. Spring Security lead and ninja Rob Winch has announced the initial support for Java-based configuration in Spring Security. This is a wonderful milestone. Recently, we've seen Java-configuration alternatives to the XML DSLs offered for Spring Social, Spring Batch and - now - Spring Security. Check out the Spring Security Java-based configuration for more details.
  6. I had the unique privilege of visiting the Alibaba group in China where they're doing some amazing things with Spring. Read more in my blog, Spring at China Scale: the Alibaba group.
  7. Someone asked me this the other day and I felt like it was worthy of a mention: in your Spring MVC @Controller class handler methods, make sure that the BindingResult argument is immediately after the model or command argument, like this:
     <CODE>@RequestMapping(...) public String handleRequest( @ModelAttribute @Valid YourCustomPojo attempt, BindingResult result)</code>. 
    	 
    	 In this example, <CODE>handleRequest</Code> will validate the POJO (<CODE>YourCustomPojo</code>) - checking the POJO for JSR303-annotations and attempting to apply the constraints because the POJO is annotated with <CODE>@Valid</CODE> - and stash any errors  in the <CODE>BindingResult</code>, which it makes available if we ask for it.
    	 
    	 
    
  8. Speaking of validation using JSR 303, I found this amazing post from 2010 that I felt worth inclusion. This post introduces a custom annotation, called @SpelAssert, that works like JSR303's @ScriptAssert.
  9. Do you want to use Cloud Foundry with the continuous integration capabilities offered by CloudBees? We got you covered! The Cloud Foundry and Cloud Bees teams worked to integrate the process, and the step-by-step introduction is given here.
  10. Alvaro Videla has introduced and open-sourced his RabbitMQ simulator. The RabbitMQ simulator is an awesome visualization tool to demonstrate how RabbitMQ topologies work.
  11. Gary Russell has announced that Spring AMQP 1.1.4 is now available.
  12. The Fstyle blog has an interesting post on how to unit test Spring Security with Spring MVC test mocks.
  13. Our pal Boris Lam is back, this time with a post on how to integrate Spring Data, MongoDB and JavaServer Faces.
  14. Indika Prasad, on the Programmer's Guide blog, has put together a tutorial showing how to use Spring Security with Webdav and password encryption.
    </LI>
    <LI> The  <EM>Java J2EE SOA Key Points</EM…

Scripted 0.4 released

Engineering | Andy Clement | March 05, 2013 | ...

This week we've released version 0.4 of our JavaScript focused code editor. You can read about the background of Scripted here.

The full release notes for 0.4 are here but in this article I'll call out a few of the more interesting changes.

Tooltips


Scripted uses an inferencing engine to build an understanding of your JavaScript code. Scripted 0.3 provided some basic tooltips showing inferred information about function calls. In Scripted 0.4 this has been taken further - not only better formatting but also any jsdoc discovered is now included in the tooltips. Here you can see the tooltip that will appear when you hover over the function call:


 

Templates


Template support has been enhanced and you can now replace selections with text expansions that embed the original selection. In the first picture we have selected a function call and pressed Ctrl/Cmd+Space:

And on selecting the first template completion the editor contents become:


 

Extensibility


This version of Scripted includes a basic plugin mechanism. It is possible to write just a single .js file, drop it into the right place, and it will extend the behaviour of Scripted. The plugin API is definitely a work-in-progress but you can already achieve some useful functionality. For example we have on-save source transformer plugins that perform operations like removing white space and adding copyright messages. There is more information on the plugin system in the release notes and here in the wiki. Basically plugin development involves writing an AMD module, 'require'ing the API pieces and you are good to go.

One of the key use cases we had in mind was enabling you to write a plugin that contributed new annotations to the editor (that appear in the left hand ruler and allow styling of the editor text) . Here is a very simple plugin. This simply locates the names of fruits in your code and adds annotations for them. Perhaps not the most useful plugin but it should show what the key parts of a plugin are…

Spring at China Scale: Alibaba Group (Alipay, TaoBao, and TMall)

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

So What Does It Take to Operate at China Scale?

Some of the companies of the Alibaba group

The challenges inherent to building enterprise applications that meet China-scale demand are unparalleled. One exemplary Chinese organization using Spring heavily to solve very unique challenges is the Alibaba group. Alibaba is itself an online auction site, like eBay in the west. The Alibaba group in turn owns a few other online service companies, like Alipay (a secure transaction processor, like PayPal in the west), TaoBao (a comparison shopping engine, like Shopzilla in the west), and TMall (an e-tailer, exposing the catalogues of merchants, like Amazon in the west).

From the InfoQ article, "on 11 November, 2012 (the Double Sticks promotion day), Tmall and Taobao witnessed 147 million user visits, purchases of 30 million people and nearly 100 million paid orders. At 0:00, more than 10 million users were concurrently online." The "double sticks promotion day" is celebrated as a sort of day to honor the single people out there. People make blind-dates, attend speed-dating events, and - somewhat like cyber monday shopping in the US - look for good deals from merchants. TaoBao reported USD $3 billion dollars for a single 24 hour period

This Week in Spring - Feb 26th, 2013

Engineering | Josh Long | February 27, 2013 | ...

Welcome to another installment of This Week in Spring! It's been an exciting two weeks for Hadoop content - Hadoop enthusiasts should check last week's post for an HD quality replay of Building Big Data Pipelines with Spring Hadoop from SpringOne 2GX 2012.

  1. Costin Leau has announced that Spring for Apache Hadoop 1.0 has gone GA!
    	This marks the end of a year in development from the time of the first betas.  There's a lot in this release. For  more information, check out  the blog. </LI>
    
    <LI>Did you guys hear about yesterday's announcement from <A href="http://www.greenplum.com/blog/topics/hadoop/introducing-pivotal-hd">about Pivotal HD, a Hadoop distribution which performs better than the competition, provides a true SQL interface, and features extra tools</a> (like an admin console and an installation, configuration and management facility) and is bundled with Spring for Apache Hadoop? 
    

    The release was in the news a lot yesterday. Here's a nice post on GigaOm, another on
    CIO , and yet another on CRN and another still on Silicon Angle

Spring for Apache Hadoop 1.0 Goes GA

Engineering | Costin Leau | February 26, 2013 | ...

We are happy to announce the first GA release (1.0) for Spring for Apache Hadoop, almost one year to the date from the release of its first milestone release. During that time we have incorporated a great deal of your feedback to drive the road-map, so thanks everyone from the community who have helped! While new features have been added over the year, the goal of Spring for Apache Hadoop remains the same, to simplify the development of Hadoop based applications.

Download it now, or view the maven artifacts here.

Simplified Programming Model & Consistency

What we have observed is that using the standard out of the box tools that come with Hadoop, you an easily end up with Hadoop applications that are poorly structured collection of command line utilities, scripts and pieces of code stiched together. The different origins of the various projects in the Hadoop ecosystem, such as Hive and Pig focusing on declarative usage or Cascading and HBase for a programmatic angle, have led to different approaches to configuration and API designs.

 

Spring for Apache Hadoop provides a consistent programming and configuration…

Get the Spring newsletter

Stay connected with the Spring newsletter

Subscribe