Spring Social 1.0: What a Year Makes

Show of hands: Who’s on Facebook? Any Twitter users reading this?

Almost everyone I know is on Facebook, Twitter, LinkedIn, or some other social network site. In fact, most people I know maintain a presence on multiple social network sites. According to recent numbers thrown about, Facebook has over 750 million users and Twitter has over 200 million users. Even my mom is on Facebook.

Okay, you can put your hands down now.

With such a large audience, it can be easy to find business-led motives for building applications that target those users. From a more personal, individual perspective, working with a social networking service is also fun. It can be very rewarding to develop something that your friends and family will recognize, understand, and maybe even use. In addition to the “fun” factor, there’s also a “wow” factor when you tell people you write programs that target those platforms. When you say “Facebook” or “Twitter” everyone—even my mom—understands at least some part of what your app does.

Read more

This week in Spring: August 30th, 2011

Welcome to another edition of
“This Week in Spring”
There’s a lot to get to, so we’ll get to it. A quick note: if you’re at VMworld 2011 in sunny Las Vegas, come on over to the Cloud Application Platform booth and say hi.

  1. What a week for CloudFoundry! The week saw the release and availability of Micro Cloud Foundry, the freely downloadable “PaaS-on-a-stick.”
    Micro Cloud Foundry is a complete, local version of the popular, open source Platform as a Service that lets developers run a full featured cloud on their Mac or PC. Using Micro Cloud Foundry developers can build end-to-end cloud applications locally, without the hassles of configuring middleware while preserving the choice of where to deploy and the ability to scale their applications without changing a line of code.

    To learn more about the Micro Cloud Foundry, check out these three blog posts introducing Micro Cloud Foundry to Spring developers and Grails developers, and introducing the support for Micro CloudFoundry in SpringSource Tool Suite.

        <LI>Thomas Risberg blogged today about <A HREF="">using PostgreSQL on Cloud Foundry</a>. The recently announced  PostgreSQL support   makes CloudFoundry the natural place to deploy your enterprise applications: between MySQL and PostgreSQL there's very likely few speed or feature that you can't match on CloudFoundry. <a href="">Try it out today!</a>  
         </LI><LI> Mark Thomas had an article on <a href="">Tomcat Expert</a> last week about  <A href="">Tomcat 8 and Java 7</a>, answering the  question: <EM>will they work together</EM>? 
         <LI>Roy Clarkson, lead of the Spring Android project, <a href="">recently blogged about the various dependency injection options for Android</A> and how to write cleaner code. Check it out for a look at the modern Android developers toolkit. 
        <LI> Spring provides many ways to support configuration. Spring 2.5 enhanced the options available with <EM>stereotypes</EM>, which let you 
             specify a marker annotation as a way to define an injection site.
             This <a href="">very nice blog post</a> first introduces some of the earlier ways to make maximum use of the type system with <CODE>@Autowired</CODE>, then introduces the <EM>stereotype</EM> model, cleanly and consistently. 
             I wholly recommend it for a great look at an easy way to achieve  
             cleaner code.
           In addition to the MicroCloud, last week saw <A HREF="">the announcement</A> of the availability of <a href="">PHP</a> and <a href="">Python</a> support through    community CloudFoundry providers. 
            This is an ideal situation for developers on those platforms and if you've always wanted first-class support for Python and PHP on a cloud, this release is for you! And, of course, if you're a Python developer, you should no  doubt be looking at <a href="">Spring Python</a>, the <EM>Pythonic</EM>     port of the Spring framework. 
        <LI> Last week, Alan Stewart, lead of the Spring Roo project, <a href="">announced the availability</a> of the O'REILLY book, <EM>Getting Started with Spring Roo</EM>, that my co-author Steve Mayzak and I put together. O'REILLY worked closely with us to help make the book concise, and useful. O'REILLY have graciously agreed to make the book  <a HREf= "">available for free download here</a>, as a <CODE>.PDF</CODE>. 
            Readers who want an alternative e-reader-specific format or want to get a print copy of the book on-demand may of course pursue those options at the <a href="">O'Reilly page for the book</a>. 
           The book features an introduction to Spring Roo as well as an introduction to two of the many powerful, new addons being developed for Spring Roo: the Spring Data Neo4j addon, and the Vaadin web framework addon.         
             <A href ="">Virgo 3.0 and Gemini Web 2.0</a> have been released. 
              The theme of Virgo 3.0 is better integration with EclipseRT technologies. To that end, we have created a Jetty variant of the Virgo web server and have switched from Felix to Equinox implementations of some OSGi services. 
              Gemini Web and the Tomcat variant of the Virgo web server have been upgraded to Tomcat 7 and Servlet 3.0.       
            <A href="">Spring AMQP 1.0 GA has been released!</A> 
            I don't know about you guys, but I've been waiting for this one for a <EM>looong</EM> time. RabbitMQ  is one of the  most powerful messaging options available to enterprise Java developers today in traditional Spring applications <A href="">as well as in the cloud.</a>  
              Spring AMQP provides the idiomatic Spring support for RabbitMQ, including support for a <CODE>PlatformTransactionManager</CODE> abstraction, 
             and a message listener container abstraction similar to the support available for JMS.
             The GA release of the Spring AMQP integration clears the way for the inclusion of the Spring Integration AMQP support in the imminent  Spring Integration 2.1. Powerful stuff! Developers looking to get started with messaging in Spring might take a look at <a href="">this GreenBeans post ("Getting Started with Enterprise Messaging with Spring")</a>, which may be a bit out of date but provides a clear, concise introduction to the relevant concepts and options for both AMQP and JMS integration with Spring. 
           <LI><A href="">Spring GemFire 1.1.0.M2 has been released!</a>
             This new release includes dedicated support for continuous query (Message Driven POJOs for GemFire), extensive client cache support,
             and namespace support for region expiration. Very cool release, and users are highly encouraged to check it out. The continuous query support underlies the new Spring Integration Gemfire adapter that's expected to be in Spring Integration 2.1, as well: very powerful stuff! </LI>

  2. Spring Social 1.0.0.RC3 has just been released.
    This release includes fixes for bugs reported since 1.0.0.RC2 and tweaks to the API: ConnectInterceptor implementations can now add parameters to the authorization URL, Twitter TimelineOperations.updateStatus() can now post a photo, along with the status, returns a Tweet object, and can also be used to post a reply to an existing status.

        The set of sample applications has been updated, including two new examples: One to demonstrate a popup-based connection flow and another to demonstrate using Spring Social within a Facebook Canvas application.
        </li>  <LI> 
        Adobe Technical Evangelist Christophe Coenraets
        <a href= "">
          has updated the Flex / Spring Mobile Test Drive. 
        The new code is available on <a href=""></a>.      </li>
        This <a href="">post, by Artur Mkrtchyan</a>, does a nice job providing an introduction to writing a MongoDB client using regular Java and then taking it a step further and using the Spring Data project to talk to MongoDB. Good stuff, Artur!

  3. Job scheduling support in Spring’s always been pretty robust, historically supporting Quartz, and - from Spring 3.0 and later - supporting
    the @Scheduled annotation. However, there is always room for improvement, and this blog
    explores this, even linking to code that would allow you to build on core Spring, and get @Scheduled-like ease-of-use
    while delegating to Quartz’s power.
    Even if you’re not interested in job scheduling, this post serves as a fine example of how anybody can build on the rich lifecycle hooks and component model to extend Spring’s API for your own application using the same hooks as the framework itself uses.
    Good stuff!
  4. <LI> <a href ="">
      This post on</A> about using Spring Web Services with JAXB is both concise and useful. It introduces the data modeling approach for  
        contract-first web services using Spring Web Services and JAXB, the Java API for XML binding.     
  5.  A blogger, Roger Hughes, has written up a string of blogs recently that are really insightful! 
     The <a href="">first post</A> introduces  Spring 3's <CODE>@NumberFormat</CODE>. The <a href="">second</A>  introduces Spring 3's <CODE>@DateTimeFormat</CODE></A> annotation.  The <a href="">third post</A>  introduces Spring MVC's <CODE>Conventions</CODE> class, which is at the heart of some of the major convention-over-configuration centric changes seen in recent Spring MVC releases that let you, for example, add any object to the <CODE>Model</CODE> that is made available to the view and omit the name used to store that model attribute, deferring to the <CODe>Conventions</CODE> class to provide a sane name based on the <a href="">JavaBeans specification</A>.    

    In this latest post, he cautions that while using the conventions in some cases can be very helpful (such as with <mvc:annotation-driven/>), using some defaults can cause confusion. This is a fair point, and it’s nice to have the choice, either way.
    Nice work, Roger!

  6. This blog post highlights the fact that Spring.NET supports bi-direction injection
    , a feature that distinguishes it from Ninject and MS Unity.

  7. Want to run multiple Tomcat instances on one machine? This blog post explains the nitty gritty details. Good stuff.

Read more

Using Postgres on Cloud Foundry

When the new open source Platform-as-a-Service (PaaS) offering Cloud Foundry from VMware launched earlier this year, it included a relational database service powered by MySQL along with the NOSQL options of MongoDB and Redis. One of the promises of the Open PaaS is to provide choice both in languages and frameworks you can develop with and in the database services that are available to use. We now have a new relational database service using PostgreSQL available. This is great since we can now choose between the two most popular open source relational databases. PostgreSQL is is a very robust and reliable database that has been around for a long time so it definitely has been battle tested.

Read more

RabbitMQ: Enabling Grails full text search on Cloud Foundry

In my second blog about Grails and Cloud Foundry I introduced a variant of the Grails Twitter example that could be hosted on At the time I mentioned that full text search using the Searchable plugin would limit you to a single application instance because the search indices would be unique to each instance. In other words, you might very easily get different search results depending on which application instance your browser is routed to.

I also said that one option for fixing this problem would be to synchronise the search indices across the instances. But that doesn’t sound particularly easy, does it? As it happens, the introduction of the RabbitMQ service into Cloud Foundry means that the required code changes are far smaller than you might expect. So let’s see how I added full text search for the Grails Twitter status messages.

Read more

Clean Code in Android Applications

Let's say you wake up one morning, and think, "Hey, I'm going to build an Android app today." First off, good choice! As of the end of June, 500,000 Android devices were being activated every day, outpacing even the iPhone. That means there is a large, potential audience for your app. Additionally, Android is built with Java. This may not seem like a big deal, but I have worked in Objective-C on the iOS platform for a few years, and while I am now quite comfortable with it, the iOS SDK offered a steeper learning curve than I experienced with Android. Android just felt more accessible when I first started working with the Android SDK. That said, there are some clear differences from any other Java application you have built in the past, and I'll go over some of those in the first section.

Read more

Using Micro Cloud Foundry from Grails

Back in April, VMware introduced Cloud Foundry to the world and with it came super-simple application deployment for Grails developers. Fast forward several months and now another piece of the jigsaw is in place: Micro Cloud Foundry. You can now have your own Cloud Foundry instance for testing or any other use case. And of course, it’s incredibly easy to use from Grails.

So what is Micro Cloud Foundry? The following screencast gives you a brief overview of the product and then takes you through the process of downloading, installing and configuring it. At the end, you get to see how you can deploy a Grails application to your Micro Cloud Foundry instance instead of

Read more

Micro Cloud Foundry for Spring Developers

Today VMware team released Micro Cloud Foundry, a complete, local version of the popular, open source Platform as a Service that lets developers run a full featured cloud on their Mac or PC. Using Micro Cloud Foundry developers can build end-to-end cloud applications locally, without the hassles of configuring middleware while preserving the choice of where to deploy and the ability to scale their applications without changing a line of code.

Micro Cloud Foundry supports Spring and Java, of course, but also provides runtime environments for Scala, Node.js, and Ruby so that you can release your inner polyglot programmer! Micro Cloud Foundry also provides many services like MongoDB, MySQL, and Redis with come ready to use immediately without having to do extensive installation and configuration. With built-in dynamic DNS support, developers can run their Micro Cloud Foundry wherever they happen to be working – whether at home, office or coffee shop – without any reconfiguration required. After creating and testing your application on Micro Cloud Foundry, you can easily deploy your application without changes to or other instances of Cloud Foundry - it enables true application portability across a range of cloud environments.

Read more

This week in Spring: August 23rd, 2011

Welcome to another edition of
“This Week in Spring”

Things are moving fast and furious as we near next week’s VMworld 2011. I want to invite any attendees to visit your expert technologists at the VMWorld Spring booth. Let me know if you read this weekly roundup.
Lots to talk about this week, so let’s get to it!

    <li>The preliminary session schedule has been published for <a href="">SpringOne 2GX 2011</a>. This year's show is going to be another fantastic mix of deep technical content, cutting edge development and the absolute best place to learn about everything in the Spring universe. Be sure to <a href="">register now</a>!</li>
    <LI> <a href="">Spring 3.0.6's was just released!</a>       
         This release addresses over 50 minor issues and includes about a dozen small improvements. Be sure to read the <a href="">Change Log</a> for all the details and <a href="">download</a> the bits as soon as possible.    
        <LI> <a href="">Spring Data Graph 1.1.0 with Neo4j support</a> has just been released. The new version features improved support for the latest and greatest Neo4j iteration, (1.4.1), as well as improved support for queries. You can now build repositories using Spring Data Graph with much greater ease. Also, the project's been renamed to reflect its core focus, Neo4j, thus, this will be the <EM> Spring Data Neo4j</EM> project, going forward. This rename is already evident in the packages in the project. 

  1. Eclipse Gemini Blueprint lead Costin Leau chimes in to note that Eclipse Gemini Blueprint 1.0.0.RELEASE has just been released!
    The 1.0.0.RELEASE completes the migration of Spring DM to the Eclipse Foundation (see this guide for more information).
    Nice job, guys!
  2. I like <a href="">CloudFoundry.</a> Others may not be using CloudFoundry, as it is relatively new. Some might still be using Google App Engine, for example. And that's OK. Spring always has been, and will continue to be, about portability and choice. So it is great to see a post that demonstrates <a href="">it is easy to get Spring Roo applications running on Google App Engine</a>, too!  </LI>

  3. The Spring Integration repository has changed addresses! Formerly, the repository was hosted on, but it is now hosted under the SpringSource presence.

  4. Ken Rimple has another great post, this time on the upcoming Spring Roo 1.2 release, which features support for both the ActiveRecord-style entities that Roo has traditionally generated as well as services, which many will no doubt be familiar with. While it’s always been possible to use services in conjunction with Spring Roo, this new release makes it a natural part of the workflow.

  5. Agile developer Tarun Sapra, at Xebia India, has written a nice post on the golden rule of when to use to Spring’s singleton concept: only use singletons for beans that don’t have to have client-specific state. While he poses the golden rule slightly differently, I think the distinction is important. Spring beans can themselves maintain state, but they must guard that state from mutations by multiple (and often concurrent) clients.

    A lot of times, too, Spring lets you work as though you have client-specific state, but are in fact using a singleton. An example of this is in the way Spring supports injection of the JPA <CODE>EntityManager</CODE>, which is <EM>not</EM> thread-safe. Spring intercepts calls to the EntityManager proxy that's injected and then, in a thread-local, creates an EntityManager so that each request <em>effectively</em> has client-specific state, but they can program in terms of single-threaded access. 

    That said, this post is a very good read.

  6. comments on the support for explicit release of JNDI resources in Apache Tomcat.
    Apache Tomcat 7 contains a number of new features around database connection pooling, which help administrators keep their application available and serving content, collecting customer information, and supporting their applications. The main one that has garnered a lot of attention is the new JDBC Connection Pool feature introduced by Filip Hanik last year. Another connection pool attribute not yet discussed here on is the new closeMethod for speeding up the closing of JNDI resources that would otherwise be closed during garbage collection.

        <LI> This <a href="">post</A> by Deepak Vohra on IBM's DeveloperWorks has some great information on using Spring Android's <CODE>RestTemplate</CODE> support to consume RESTful web services (which, in this example, were developed using JAX-RS). Interoperability is king, and Spring's REST support makes it easy.

  7. <LI><a href="">This fantastic post covers using  FreeMarker</a> (via the <CODE>org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver</CODE> view resolver) for Spring MVC views</a>. I like FreeMarker, and it has a lot to offer compared to straight <CODE>JSP</CODE> (and even compared to straight <CODE>JSPX</CODE>!) The take away, for me, is that Spring MVC supports lots of options, and provides SPIs that make it very simple to integrate new technology for each of the core pieces of the integration.

    Great stuff!

  8. …which brings me to this implementation of a Spring MVC view by a Sean Scanlon, supporting Mustache.js templates.
    Great stuff, too!
  9.          <LI>  Blogger Mkyong has posted a tutorial <a href="">introducing how to use Spring Security 3.</a>
         The tutorial covers the basics of setting up Spring Security 3 with Maven 3 for a simple web application login scenario.  
        <a href="">Apache Tomcat 6.0.33 has been released!</a>
        Apache Tomcat 6.0.33 is primarily a security and bug fix release. All users of older versions of the Tomcat 6.0 family should upgrade to 6.0.33.
        Note that is version has 4 zip binaries: a generic one and three bundled with Tomcat native binaries for different CPU architectures.
        Apache Tomcat 6.0 includes new features over Apache Tomcat 5.5, including support for the new Servlet 2.5 and JSP 2.1 specifications, a refactored clustering implementation, advanced IO features, and improvements in memory usage.

Read more

Countdown to Grails 2.0: Database Migrations

One of the many nice features of Grails is the way it will automatically create your database schema for you from your domain model. Admittedly it’s a feature of Hibernate that Grails uses, but still, it helps you get started very quickly with database-driven web applications without having to worry about the database schema.

What happens once your application moves to production? During development, losing the data in between server runs isn’t a big issue. But you can’t just drop the database in production. So that rules out the “create” and “create-drop” values for the dbCreate data source setting. What about “update”? It won’t clear the data from your database, so it’s often used by people. Yet it doesn’t work well for production because it has significant limitations. For example, it can’t handle simple column renames and it certainly can’t handle modifications to existing data that might be a necessary part of an upgrade. Although it’s tempting to use dbCreate = “update” for your deployments to production, it is usually the wrong solution.

Read more

Chatting in the Cloud: Part 1

Last week the availability of RabbitMQ as a service on Cloud Foundry was announced. Any application running on Cloud Foundry may now send and receive messages via a RabbitMQ broker that can be provisioned as a service with a single command (e.g. ‘vmc create-service rabbitmq’). Instances of the messaging service may be shared between applications, and since RabbitMQ is a protocol-based broker, those applications may even be written in different languages. So, this is an exciting announcement for those interested in modular, polyglot, event-driven applications running in the cloud. I will be posting a series of blogs that focus on those types of applications. In this post, I am going to keep things simple and focus on the initial experience for Spring developers.

Read more