Josh Long

Josh Long

Josh (@starbuxman) is the Spring Developer Advocate at Pivotal and a Java Champion. He's host of "A Bootiful Podcast" (https://soundcloud.com/a-bootiful-podcast), host of the "Spring Tips Videos" (http://bit.ly/spring-tips-playlist), co-author of 6+ books (http://joshlong.com/books.html), and instructor on 8+ Livelessons Training Videos (http://joshlong.com/livelessons.html)

Recent Blog posts by Josh Long

This week in Spring: March 22nd, 2011

Engineering | March 23, 2011 | ...

Another great week - lots of new (and novel!) types of content and indeed, new sources of new content, too! Enjoy!

  1. SpringSource unveiled the new SpringSource YouTube channel. This channel features exciting technical content on the SpringSource technologies, and should be your first destination for new content and for content that you might've missed the first time around. Check it out today! Personally, I find that this channel is fantastic on a big screen TV that supports a browser or YouTube (Google TV/Apple TV/slingbox/etc.) or on a peripheral screen - like a second laptop or second monitor. You can also listen to it on a portable device like an iPhone in the car, on the commute.
  2. ...Speaking of the YouTube channel, the content and slides of last week's webinar - Getting Started with Spring and STS - is available for those that missed it. Juergen Hoeller, lead of the Spring framework, introduced the exciting next generation (3.1) of the Spring framework a few weeks ago in a live webinar, which is also available on the SpringSource YouTube channel!
  3. Martin Lippert has announced the latest release of the SpringSource Tool Suite, version 2.6.0. The new release is packed with new features, and tracks the latest versions of various projects (Spring Roo 1.1..2, Eclipse Helios SR2, Groovy 1.7.8, Grails 1.3.7). It included updated support and performance for both Spring Roo and Groovy on Grails, a graphical editor for Spring Web Flow, and new support for content assist, quick fixes and refactorings for Spring annotations (@Autowired, @Qualifier, @RequestMapping, etc.).
  4. Ramnivas Laddad pointed This Week in Spring to this very innovative Chrome browser plugin. To use it, type "spring" in the omnibox bar (the search/address bar) followed by a space, and then the nane of the class that you are searching for. It'll automatically bring up candidate results linked to the documentation! Fantastic, and handy! (NB: we tested this with the just-released Chrome 10, though it no doubt works with at least Chrome 9.)

  5. InfoQ has the video of Mark Pollack's and Chris Richardson's amazing introduction to Spring Data from the SpringOne2GX event last year in Chicago. Spring Data is a great way to take advantage of these new, powerful datastore options (sometimes called "NoSQL" stores) in a way that's familiar, and idiomatic for Spring users. Check it out!
  6. The latest release of the Spring Data project featuring support for Neo4j has been released. The new version includes many new features and tracks the latest version of Neo4j, itself. Neo4j is one of the many new specialized datastores available to developers today. Neo4j models data as relationships and nodes. It's optimized for fast node traversal, as in a Facebook friend-graph, for example.
    Additionally, SpringSource is producing a webinar on Spring Data (and specifically, the Spring Data Graph subprojct encompassing the Neo4j support) on April 20th. The presentation will be presented for both North America and for Europe. Register now!
  7. The Spring framework helps you build the best applications. Spring Social builds on that promise and lets you integrate your application with your users. The JTeam group is at it again, this time with an interesting updated look at Spring Social complete with source code and a sample application. Check it out!
  8. Spring MVC provides support for many different types of views, including RESTful payloads, Velocity templates, JSPs, and Tiles-based views. This blog post explains how to integrate Spring MVC with Tiles
  9. Ken Rimple from Chariot Solutions has recorded a screencast on the newest member of the SpringSource family, Wavemaker.
  10. More people are using the Spring framework now than ever before, and a consequence of that that growth is newer, specialized support for Spring in various tools. One UML toolmaker - Architexa - talks about their enhanced support for the Spring framework in their Eclipse-based product. Check out this blog for more.
  11. Ashish Jain provides an interesting perspective on Spring 3.1's new caching support.

    Ashish's chosen to simplify his software stack (by removing Hibernate, and instead using straight JDBC through the Spring framework's JdbcTemplate, a…

This week in Spring: March 8th, 2011

Engineering | March 09, 2011 | ...

This week has seen yet another flurry of exciting new releases and updates, great community content and the exciting announcement welcoming WaveMaker to the SpringSource family.

  1. Rod Johnson announced the acquisition of WaveMaker today in the SpringSource blog. WaveMaker is a widely used graphical tool that enables non-expert developers to build web applications quickly. From the post: "While WaveMaker is already part of the Spring ecosystem, it will now become an integral part of the Spring family and VMware's cloud strategy. All of WaveMaker's staff will be joining VMware." Exciting…

This week in Spring: March 1st, 2011

Engineering | March 02, 2011 | ...

This week has seen yet another flurry of exciting new releases and updates and great community content.

Hold on to your hats!

Let's get right to it.

  1. Spring Roo 1.1.2 has been released. This new release contains over 200 enhancements, new features and fixes since the 1.1.1 release last month. Some of the highlights include enhanced tool usability, persistence enhancements, GWT and Spring MVC enhancements, and library upgrades.
  2. Martin Lippet has just announced the 2.5.2.SR1 and 2.6.0.M2 releases of SpringSource Tool Suite.

    The 2.5.2.SR1 "refresh" has updated support for Groovy 1.7.8, Grails 1.3.7, an update to Eclipse Helios SR2 (3.2.6), and the just-released Spring Roo 1.1.2. The 2.6.0.M2 mileston also includes a Roo plugin manager, improved support for @RequestMapping, and tons of improvements to the Groovy and Grails tooling.

  3. Martin Lippet has also put together information on the oft-asked and newly answered question: how do

    I contribute custom Project…

Green Beans: Getting Started with Spring Integration

Engineering | February 24, 2011 | ...

Applications don't exist in a vacuum. They need to communicate with their customers and with other applications. Application Integration is all about enabling this communication. Integration lets applications share services and data with each other, and, just as often, integration helps applications connect with their users.

Spring Integration provides a framework to build integration solutions, to facilitate these kinds of solutions. Spring Integration solutions describe the flow of data through a pipeline. Data enters the processing pipeline as a message. The message is moved forward through…

This week in Spring: February 22nd, 2011

Engineering | February 23, 2011 | ...

What a week! Lots of good, foundational content available this week from, and for, the community. Let's get right to it.

     <li> <a href="http://blog.springsource.com/2011/02/21/spring-3-1-m1-mvc-namespace-enhancements-and-configuration/">Rossen Stoyanchev</a> continues the whirlwind introduction to the new features in Spring 3.1, this time with a look at the MVC namespace and @Configuration-based improvements. </li>
    
  1. Chris Beams blogged about the upcoming FeatureSpecification support in Spring 3.1 Feature Specifications provide the same features as the XML namespace infrastructure elements, like <tx:annotation-driven>, in a Java configuration-centric way. This is a very powerful feature, and this blog post is the best way to get started.
  2. SpringSource Tool Suite lead Christian Dupuis - tweets that users can now download STS without submitting to the registration form. Very cool!
  3. <li> Can't get enough Spring? 
    

    Check out Spring on your favorite social network!

  4. Glyn Normington has just announced the Eclipse Virgo 3.0.0.M01 release is now available for download. The new version features tighter integration with the Eclipse stack, including the Eclipse Virgo Jetty…

This week in Spring: February 15th, 2011

Engineering | February 16, 2011 | ...

This last week has seen a record number of... well, records, if nothing else! First, Juergen Hoeller - Spring project lead and all around nice guy - gave a webinar introducing the new features in Spring 3.1 to record attendance numbers. Then, as if that weren't enough, the next day the first milestone of Spring 3.1 was released to record numbers of downloads. That would've been enough. I don't know about you, but I could've stopped right there. Then, over the course of the last week we've seen what I imagine is a record number of new releases from other Spring projects! Finally, yesterday, no doubt in reaction to all this other record activity, we saw the largest record number of people hit the SpringSource blog yet! In summary, Spring 3.1 milestone mania, numerous new projects, and as always a healthy dose of community-awesomeness (go team!)

 </p> 
      <li>Hot on the heels of Juergen's Spring 3.1 webinar, Chris Beams got the ball rolling on the  first three   of many  posts on the numerous new features in Spring 3.1. 
    	
    	<a href="http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/">
    

    The first post introduces Spring 3.1 M1, generally. The second post introduces Spring 3.1's "profiles," which let you partition your beans along environment-specific lines with Environments. The third post introduces the Unified Property Management capabilities of the Environment abstraction.

    	  </li>
    
    
    <li>
    	Matt Raible has put…

This week in Spring: February 8th, 2011

Engineering | February 08, 2011 | ...

This has been another exciting week in the Spring community. The community seems abuzz about the new Tomcat release, mobile clients, Spring Data and big data (e.g., Spring Gemfire, Redis, and of course the Spring Data projects.)

A reminder: Juergen Hoeller - lead of the core Spring framework and contributor to all of the sister Spring projects, in some fashion or another - is giving two identical webinars - one for North America and one for Europe - on the new features in Spring 3.1 in two days (February 10th)! Be sure to register for this free webinar on the next iteration of the most widely used Java framework!

This is turning out to be a record event, with incredible advance registration numbers. While there are no Spring 3.1 binaries (yet; stay tuned!), the code for the Spring project is always at your disposal, so - if you're as excited about all the new features as I am - you'll see this webinar and start playing with it long before it's…

This week in Spring: February 1st, 2011

Engineering | February 02, 2011 | ...

This week's been a fascinating rush of developments in the community. Depending on where you look, the excitement is behind the newer, more cutting edge stuff like Spring Data, Gemfire, and Virgo, or it's behind the wonderful refinements to technologies like Tomcat and SpringSource Tool Suite. Either way, there's a lot to take in this week, so let's get started!

  1. SpringSource Tool Suite 2.6.0.M1 has been released. This new version features improved content-assist and quick fixes, new wizards and views for Spring MVC @RequestMapping-based applications. It also features improved content-assist performance for Groovy, and improved syntax highlighting for Groovy.
  2. Spring Data Graph - Neo4j Support 1.0.0.M2 Released. The new release has many new features, including improved indexing support - full, named index support for nodes and relationships, removal of node and relationship entities, strict type checking on entity instantiation from framework methods (according to type strategy), support for dynamic projection to arbitrary graph entities, and new updated support for Neo4j 1.2.
  3. Shekhar Gulati has posted an introduction to Spring Roo (part 1, building from source) on IBM's DeveloperWorks.
  4. Mark Thomas, a senior contributor to the Tomcat project, has written about preventing Cross-Site Scripting attacks in Tomcat 7
  5. The VMWare vFabric GemFire team has just put together a video demonstrating how to setup the GemFire's Hibernate Cache Module. The video demonstrates how to configure the module in Maven and then demonstrates its use in a Spring-DAO based implementation. Finally, the use of Spring Insight to monitor the application's performance is demonstrated. Cool video for an even cooler technology!
  6. Sebastian Pietrowski has published a good introduction to Spring Data Redis.
  7. Shekhar Gulati contributed another great post - also on Spring Data and Redis. Spring Data is the umbrella name for a slew of technologies designed to support more specialized data persistence needs. A large part of this is the deep support for many of the NoSQL data stores available today, as well as more specialized support for JDBC-based persistence.
  8. The Java Code Geeks have written up a good post on Aspect Oriented Programming with Spring AOP
  9. Jose Delgado wrote up a good post on how to configure an application to handle two databases in Spring Roo.
  10. Sivaprasadreddy Katamreddy is at it again, this time on applying Inversion of Control and Dependency Injection to method design
  11. Glyn Normington tweets that the Eclipse Virgo kernel is now running successfully for the first time on a directed graph of regions implemented using OSGi 4.3 framework hooks. Congratulations! Eclipse Virgo is the name of the new-and-improved version of what was formerly the SpringSource dm Server.
  12. David Dossot retweeted an interesting post that explores

    the Activiti BPMN 2 engine using Spring from earlier last month.

  13. With all the exciting news of Tomcat 6 and 7, it's easy to forget that Tomcat 5 is still being updated and supported. Tomcat 5.5.32 has also just been released!

Green Beans: Getting Started with Enterprise Messaging and Spring

Engineering | January 26, 2011 | ...

In this post, we will introduce the core concepts of messaging, as well as the rich support for various types of messaging that the Spring framework and its sister projects provide.

What is Messaging? To best explain this, I'll paraphrase the example offered by the groundbreaking Enterprise Integration Patterns book by Gregor Hohpe and Bobby Woolf (Addison Wesley, 2004). When you make a telephone call, you attempt to relay information to another party. This only works if the second party is available when you place the phone call. Because it is not always possible to answer phone calls, we use a voice-mail boxes to queue the messages. Callers leave messages in the voice-mail box and the callee is then free to retrieve the message (or, indeed, many messages) at a later point, asynchronously.

In that example, a voice-mail box sits in the middle of the two parties. It stores the message and then delivers it when the callee – the recipient – retrieves it. In the world of enterprise messaging, things work very much the same: a party sends a message to a messaging broker (also known as messaging-oriented middle-ware – MOM) and another party – when that party can – takes delivery of, or explicitly queries for, any messages from the message broker.

Here is where the analogy stops being useful. Message brokers, in contrast to voice-mail boxes, have a lot of options. Message brokers are ideally positioned to provide extra services, like routing, and to make guarantees about message delivery. Message brokers can be optimized for different use cases, for example, you can trade speed for durability. Message brokers may persist messages to an external store to ensure durability, though this is typically a configuration that can be toggled in the name of speed.

In the voice-mail box example, a message was sent by one party and then delivered to another – the communication was point-to-point. Message brokers support this, as well as another type of communication called publish-subscribe, where messages are delivered to multiple clients.

A common use of message brokers is to solve integration problems between two different systems. Data sent to a message broker is usually of a format common to both the sender and recipient of the message. The only thing that two systems need to agree on to use a message broker is the data contract. Messages typically have a message body, in which the contents of the message itself are stored, and message headers, which are key / value pairs that provide meta-data about the body of the message that can be used to aid consumers of the messages in processing the message. Message headers can be anything you like, but they typically relate to the message itself, or to the processor of the message.

Java Message Service

The Java Message Service (JMS) API specifies client interfaces for interacting with message brokers. Each message broker provides its own implementation of the API, very much like JDBC drivers do for the JDBC API. This implies that JMS clients should generally use the same version of the client as the server. There are many, many fine JMS broker implementations to choose from. One reason for this is that messaging ihas always been an important part of application development, and continues to be even more so today. JMS has been a part of the J2EE (now Java EE) specifications since 1.1. The JMS specification has been at version 1.1 for most of the last decade.

In JMS, clients use a javax.jms.ConnectionFactory to create a javax.jms.Connection. The Connection can then be used to create a javax.jms.Session. The Session represents the client interaction with the broker and allows for sending and receiving messages as well as other less obvious operations.

The most useful methods on the interface concern the creation of a message producers, and message consumers that send and receive messages to and from a javax.jms.Destination. A Destination maps the JMS concept of an "address" on a message broker. It also maps the concept of where a broker stores messages. In JMS, messages are sent to, stored in, and consumed from the same place, all represented by a javax.jms.Destination instance.

[caption id="attachment_7506" align="alignnone" width="573" caption="Above, blue elements represent producers and consumers. The orange elements represent destinations in the broker where messages are buffered. In JMS, these are either topics or queues."][/caption]

Destination is an interface and has two more specific sub-interfaces, javax.jms.Queue and javax.jms.Topic. A Queue represents a standard queue, which is a point-to-point construct as described before. A Topic provides publish-subscribe messaging and can deliver a single message to multiple recipients.

To send a message to a Destination, you must create a javax.jms.MessageProducer. The MessageProducer can then be used to send javax.jms.Messages.

JMS supports two different mechanisms to receive messages. The first way is to ask for a message, using the javax.jmx.MessageConsumer#receive() method, which returns an individual message from a Destination in a synchronous manner; the method blocks until a message is received, by default. Instead of using a MessageConsumer, clients may install a javax.jms.MessageListener by calling javax.jms.Session#setMessageListener(MessageListener). MessageListener is an interface and has only one method, public void onMessage(javax.jms.Message), which will be called whenever a javax.jms.Message is available for consumption on a Destination. A MessageListener provides asynchronous message processing: as messages arrive, they are processed.

There is quite a bit more to learn in the JMS API, but these classes and concepts will help you most in our discussion of Spring's support for JMS messaging. The first level of support is the org.springframework.jms.core.JmsTemplate, which provides simplifying methods to reduce the things we just discussed to one-liners. The JmsTemplate, requires a javax.jms.ConnectionFactory instance to do its work. JmsTemplate can do a lot of work for you. For example, to send a message, the JmsTemplate establishes a javax.jms.Session, sets up a javax.jms.MessageConsumer or javax.jms.MessageProducer, sets up all the machinery for transactions, and provide you with a reference to the current javax.jms.Session so you can create the message of your choice and send it. With all the error handling and construction logic, that's easily a savings of dozens of lines of code. Once your message has been sent, it destroys or closes most of those objects. This is standard practice in application servers (like a Java EE server) because the ConnectionFactory instances are created by the server, managed by the server, and are pooled. They cache the instances after use. Closing resources in those environments simply returns them to a pool. So, the JmsTemplate does the right thing in the standard case, assuming the ConnectionFactory caches or pools instances.

In a managed environment like an application server, you will typically need to acquire the javax.jms.ConnectionFactory from JNDI. You can use Spring to lookup that reference for you and configure a JmsTemplate. In our examples, we want to operate more loosely, so we will use the standalone ActiveMQ message broker. ActiveMQ is a popular, open-source message broker. To use it, download it, and then run the startup script appropriate to your operating system in the bin folder. In your application, you'll need the client libraries to connect for the corresponding version of ActiveMQ. At the time of this writing, the latest version of ActiveMQ was 5.4.2. If you are using Maven, add the following dependencies to your Maven pom file:



            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-core</artifactId>
                <version>${activemq.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-optional</artifactId>
                <version>${activemq.version}</version>
            </dependency>

Be sure to either create a Maven property for ${activemq.version} or replace the string manually with the appropriate version. There is an activemq-all dependency out there as well, but it brings down a lot of perhaps unnecessary jars. For our application, the two dependencies above suffice.

Using Spring with JMS

Let's examine the configuration for a basic JMS application. First, let's examine the basic Spring XML configuration:



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/200…

This week in Spring: January 18th, 2011

Engineering | January 18, 2011 | ...

Another fantastic week for the Spring community at large. In addition to the exciting announcement of the stable release of Tomcat 7, there were numerous great posts from the community.

  1. Continuing the back-to-basics "Green Beans" series, we've just published a post on using Spring and Maven together.
  2. The Tomcat Expert community has announced the first stable build of Tomcat 7. We know Tomcat is the favorite place for Spring developers to run their applications, so be sure to check out the latest features.
  3. Nicholas Sankel has written up a blog on using Spring Roo with the Vaadin UI framework.
  4. The Tomcat Expert community has provided a list of the top 10 articles from 2010.
  5. Tomasz Nurkiewicz has written a fantastic blog exploring how you can completely strip out XML using the Spring framework.
  6. Sivaprasadreddy Katamreddy has written up an introduction to Spring AOP that progresses from problematic code all the way to the improved code using Spring AOP.
  7. A gentleman named (from what I can tell) Warlock has blogged on Spring MVC's annotation-based session-handling support.
  8. Sal Peace has written up a fantastic introduction to using Spring MVC 3.0's portlet support with WebSphere 7.
  9. Viral Patel has written up a tutorial on saving and retrieving BLOB object data in Spring 3 MVC and Hibernate
  10. Jorram Barrez (from the Activiti project) has posted on using Spring to connect an Activiti BPMN 2.0 business process to EJB business services.

Get ahead

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

Learn more

Get support

Tanzu Spring 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