close

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> 
    
        <LI>Thomas Risberg blogged today about <A HREF="http://blog.springsource.com/2011/08/30/using-postgres-on-cloud-foundry/">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="http://www.cloudfoundry.com">Try it out today!</a>  
    
         </LI><LI> Mark Thomas had an article on <a href="http://tomcatexpert.com">Tomcat Expert</a> last week about  <A href="http://www.tomcatexpert.com/blog/2011/08/25/apache-tomcat-8-and-java-7-will-they-work-together">Tomcat 8 and Java 7</a>, answering the  question: <EM>will they work together</EM>? 
    
        </LI>
         <LI>Roy Clarkson, lead of the Spring Android project, <a href="http://blog.springsource.com/2011/08/26/clean-code-with-android/">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>
        <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="http://code-on.blogspot.com/2011/08/how-to-use-type-safe-dependency.html">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.
           </LI> 
        <LI> 
           In addition to the MicroCloud, last week saw <A HREF="http://blog.cloudfoundry.com/post/9374366916/cloud-foundry-adds-php-and-python-through-community">the announcement</A> of the availability of <a href="http://www.appfog.com/">PHP</a> and <a href="http://www.activestate.com/">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="http://springpython.webfactional.com/">Spring Python</a>, the <EM>Pythonic</EM>     port of the Spring framework. 
        </LI>
        <LI> Last week, Alan Stewart, lead of the Spring Roo project, <a href="http://www.springsource.org/node/3217">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= "http://spring-roo-repository.springsource.org/Getting_Started_with_Roo.pdf">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="http://oreilly.com/catalog/0636920020981">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.         
           </li>
           <LI>
             <A href ="http://www.springsource.org/node/3218">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.       
           </LI>
           <LI> 
            <A href="http://www.springsource.org/node/3219">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="http://blog.springsource.com/2011/08/16/chatting-in-the-cloud-part-1/">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="http://blog.springsource.com/2011/01/25/green-beans-getting-started-with-enterprise-messaging-and-spring/">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>
    
           <LI><A href="http://www.springsource.org/node/3221">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= "http://coenraets.org/blog/2011/08/flex-spring-mobile-test-drive-learn-the-best-way-to-build-java-backed-ios-android-and-playbook-apps/">
          has updated the Flex / Spring Mobile Test Drive. 
        </a>   
    
        The new code is available on <a href="https://github.com/ccoenraets/flex-spring-mobile-testdrive">GitHub.com</a>.      </li>
        <LI>
        This <a href="http://java.dzone.com/articles/spring-data-mongodb">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!
        </LI>
    


  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 ="http://community.jboss.org/people/johnnyren/blog/2011/08/26/understanding-spring-web-service-and-jaxb-integration">
      This post on community.jboss.org</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.     
    </LI>
    
  5.  A blogger, Roger Hughes, has written up a string of blogs recently that are really insightful! 
     The <a href="http://www.captaindebug.com/2011/08/using-spring-3-numberformat-annotation.html">first post</A> introduces  Spring 3's <CODE>@NumberFormat</CODE>. The <a href="http://www.captaindebug.com/2011/08/using-spring-3-datetimeformat.html">second</A>  introduces Spring 3's <CODE>@DateTimeFormat</CODE></A> annotation.  The <a href="http://www.captaindebug.com/2011/08/is-convention-over-configuration-going.html">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="http://www.scribd.com/doc/52811942/53/Capitalization-of-inferred-names">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 CloudFoundry.com 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 cloudfoundry.com:

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 www.cloudfoundry.com 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="http://www.springone2gx.com">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="http://springone2gx.com/conference/chicago/2011/10/register">register now</a>!</li>
    
    <LI> <a href="http://static.springsource.org/spring/docs/3.0.6.RELEASE/changelog.txt">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="http://static.springsource.org/spring/docs/3.0.6.RELEASE/changelog.txt">Change Log</a> for all the details and <a href="http://www.springsource.com/download/community?project=Spring%20Framework&version=3.0.6.RELEASE">download</a> the bits as soon as possible.    
        </LI>  
    
    
        <LI> <a href="http://www.springsource.org/node/3208">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. 
    
    
        </LI> 
    

  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="http://www.cloudfoundry.org">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="http://www.springsource.org/node/3207">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 git.SpringSource.org, but it is now hosted under the SpringSource Github.com 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. TomcatExpert.com 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 TomcatExpert.com is the new closeMethod for speeding up the closing of JNDI resources that would otherwise be closed during garbage collection.

        </lI>
        <LI> This <a href="http://www.ibm.com/developerworks/web/library/x-springandroid/index.html">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="http://www.dzone.com/links/r/spring_integration_with_mvc_freemarker_jsp_webser.html">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="http://www.mkyong.com/spring-security/spring-security-hello-world-example">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.  
    
         </LI>
    
    <LI> 
        <a href="http://www.tomcatexpert.com/blog/2011/08/19/apache-tomcat-6033-released">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.
    
    
    </LI>
    

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