This Week in Spring, September 20th, 2011

Engineering | Josh Long | September 20, 2011 | ...

Welcome back to another installment of "This Week in Spring." We've got a lot of content this week surrounding Spring Roo, and so, in that spirit, I move that we christen today Rooday, in honor of all the great Roo-related content in this week's roundup.

Things are kicking into over drive at SpringSource as everybody's preparing for SpringOne. This year's show is an exciting one because it'll be the first year where CloudFoundry will be present, which means that there will be lots of content around CloudFoundry and Spring, together, working as an unbeatable combination. I can't wait!

  1. InfoQ did an interview with Spring Social lead Craig Walls on the just-released Spring Social 1.0. Fascinating read! Once the interview has whetted your appetite, be sure to try the Spring Social quickstart.

    Spring Social got some great coverage elsewhere, too, including this post from adtmag.com on the new 1.0 release.

  2.  <LI> <a href = "http://www.springsource.org/node/3235">SpringSource Tool Suite 2.7.2 has been released.</a>  The new release features 
    	 support for vFabric tc Server 2.6,
    	support for Spring Roo 1.2.0.M1, and also updates  Mylyn to 3.6.2. Great stuff!
    	
     </li>
    
    <LI>
    	<a href = "http://blog.springsource.com/2011/09/14/spring-roo-1-2-0-m1-released/">Spring Roo 1.2.M1 released. 	</a>
    	The new release is a <EM>really</EM> exciting one.  There are some exciting <em>backoffice</em…

Spring Roo 1.2.0.M1 released

Engineering | Alan Stewart | September 14, 2011 | ...

The Spring Roo team is delighted to announce the availability of our first 1.2.0 milestone. The Roo 1.2.0.M1 release continues the Roo vision of making it fast and easy to build Spring-based enterprise Java applications. We’ve listened to the community and included in this release some of the most highly-requested features:

  • Ten times faster (!). We know many people are using Roo for very large projects, so we’ve continued our attention to Roo internals to ensure it operates smoothly and quickly despite this. Through attention to profiling, file monitoring, disk I/O, XML models and round-tripping, we’ve increased Roo’s performance for large benchmark projects by a factor of 10.
  • Now Apache licensed. With Roo 1.0/1.1, we used the GPL license to encourage any improvements made in Roo to be shared with the community. In response to feedback, we’ve shifted to the Apache Software License 2 (ROO-2253) so you have complete flexibility on how you use Roo in commercial and non-commercial projects. This also makes Roo consistent with most of the other Spring projects.
  • Moved to GitHub. Social coding is on the rise, and GitHub has become the de facto site for open source source code management. We’re pleased to have moved Roo’s code base to GitHub so that you can easily fork it, make changes, and submit pull requests. This will greatly simplify the receipt of new contributions from the community. Take a look at ROO-2708 or visit https://github.com/SpringSource/spring-roo for more info.
  • Repository layer flexibility. It’s now possible to define your own repository layer approach, with full awareness of your choices in the Roo-managed web tiers, integration tests and data-on-demand mechanisms. This is a significant step forward for those preferring a more traditional layering approach than the Roo 1.0/1.1 “Active Record”-like model. Of course the philosophy that favoured the earlier approach remains, so Roo still fully supports embedding convenient Active Record-style methods in entities. You can learn more about this new feature in the Pizza-Shop sample (see the /samples directory of the distribution) and ROO-301.
  • Services layers. We also decided to tackle another highly-requested community feature: services layer support. You can now easily add a services layer (via a Roo "service" command) and have this used by the Roo-managed web tiers, integration tests and data-on-demand features. The custom services layers can also be used at the same time as custom repositories, giving you complete flexibility to build whichever application layering you prefer. You can read more in ROO-340 and Stefan Schmidt is publishing a blog shortly giving more details.
  • Flexible GWT support.  Now you can skip the UI and just let Roo manage syncing your RequestFactory classes (EntityProxy, RequestContext, and Locator) with your domain model and service layers. Previously the GWT UI scaffolding was mandatory, but with 1.2.0.M1 you can be more selective on how Roo integrates with your project.
  • MongoDB support. Whether you’re a Cloud Foundry user, or just a Mongo fan, we’ve now added support for storing your entities in MongoDB. Mongo is a fast, shard-aware, schema-less document database that supports map-reduce and is a good fit for those wanting to use noSQL with Roo. Learn more in ROO-2693.
  • Database Reverse Engineering (DBRE) Multi-Schema Support. One of the most popular features in Roo is DBRE support, which allows you to not only scaffold an entity model from your relational schema, but also automatically maintain that entity layer as the schema changes. This takes a schema-first approach to development and we know of users employing DBRE in projects with many hundreds of tables. As part of ROO-1408 we’ve added support for DBRE sourcing its structure from multiple schemas at the same time, and indeed you can even have different schemas manage entities in different Java packages.
  • Shell improvements. Lots of people enjoy Roo's usability and indeed the shell has found its way to many other VMware products. We’re pleased that a number of minor fixes have made its way into JLine 1.0 (ROO-2608) and in turn the Roo shell (such as backspace to a previous line will finally work!). You can also run operating system commands directly from the Roo shell via the “!” operator (ROO-2457) and shell on start up now displays the latest community tweets  (ROO-2677).

As you can see, we’ve made a lot of enhancements to Roo 1.2 and look forward to your feedback. We’ve got many exciting new features still coming in the next Roo 1.2 milestone, including JSF/PrimeFaces (ROO-516) support and multi-module Maven (ROO-120) project support. These two are also highly-requested community features.

Please remember this is a milestone release, so you should keep using Roo 1.1.5 for production projects. However, you might like exploring these new features in Roo 1.2.0.M1 by experimenting with the included sample projects.

We hope you enjoy this new release. Please share your experiences via the community forum, follow @SpringRoo for the latest news, or use #springroo in your tweets

Alan Stewart, Project Lead - Spring Roo

New application layering and persistence choices in Spring Roo 1.2

Engineering | Stefan Schmidt | September 14, 2011 | ...

Java enterprise applications can take many shapes and forms. Depending on their requirements, developers need to decide which specific architectural layers their application needs. Up until now, Spring Roo has taken a pragmatic approach to reduce the often unnecessary complexity introduced by service facade, repository or DAO layers. The newly-released Spring Roo 1.2.0.M1 (see announcement) includes frequently requested support for architectural layers which can be tailored to the needs of the application. This article provides an overview of Roo's new service and repository layer features.

Spring Roo Application Layering Support

Spring Social 1.0: What a Year Makes

Engineering | Craig Walls | September 08, 2011 | ...

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…

This week in Spring: August 30th, 2011

Engineering | Josh Long | August 31, 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…

Using Postgres on Cloud Foundry

Engineering | Thomas Risberg | August 30, 2011 | ...

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…

RabbitMQ: Enabling Grails full text search on Cloud Foundry

Engineering | Peter Ledbrook | August 29, 2011 | ...

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…

Clean Code in Android Applications

Engineering | Roy Clarkson | August 26, 2011 | ...

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.

So moving forward in time, you have completed your first app, and have submitted it to the Android Market. Congratulations are in order, as your friends are all downloading your app and tweeting about it. Now it is time to start on your second app. You spend a few days, and suddenly realize that you are starting to reuse code from your first app, which in itself is not a bad thing. Code reuse can be valuable. But you notice there is a lot of boilerplate code that tends to be repeated often, and that can be distracting from focusing on your business logic. Fortunately, there are some ways to improve upon this.

In this blog post, I will provide an overview of Android and the application lifecycle, and discuss some of the limitations imposed by the framework. I will also review a few of the techniques and third party projects that can help you clean up your Android code, and focus on what you want to achieve with your app.

Android Overview

Let's begin with a brief overview of how Android works. Android applications (apps) are built using Java, and compiled to class files. The class files are then compiled into the Dalvik Executable (DEX) format, so they may run on the Dalvik virtual machine used by Android. After conversion to DEX format, the class files are zipped to an Android Package (APK) for distribution to devices. Because of the use of the DEX format, the Dalvik VM is not a true Java Virtual Machine, since it does not operate on Java byte code. Additionally, the Dalvik VM is based on a subset of the Apache Harmony project for its core class library. This means that many of the classes and methods to which you are accustomed in Java SE are available, but certainly not all. I have found the API reference on the Android developer web site to be an invaluable resource for reviewing these differences.

By default, each Android application is assigned a unique Linux user ID by the Android operating system. When started by the system, an application runs in its own Linux process, within its own virtual machine (VM). The system manages the starting and shutting down of this process when needed. As you can guess, this means that each application runs in isolation from the other running applications. When installed, an app can request permission to access hardware features or interact with other applications. The user elects to grant these permissions to the app or to not install it. The permissions required or requested by an app are defined in each app's Android Manifest file. This is an XML file that lists all the components of the app, and any settings for those components. The four types of application components are activities, services, content providers, and broadcast receivers. For the purposes of this post, I will be focusing on activities.

Activities basically represent a single screen of an Android application. For example, a Twitter app may have a login screen, a screen with a list of tweets, and a screen for authoring a new tweet. Each of these screens represent different activities within the application. As a developer you never instantiate an activity object yourself. Activities are activated by sending an asynchronous message called an Intent, as seen in the example below.


startActivity(new Intent(context, HomeActivity.class));

When startActivity(Intent intent) is called, the system either creates a new instance or reuses an existing one in order to display the activity to the user. The important point is that the system controls the starting and stopping, and creation and destroying of the application and each activity. If you want to interact with this process, then the application and activity classes provide methods for different lifecycle events that you can override in a subclass.

Dependency Injection

The Spring Android project recently reached its fourth milestone release. With that release we have continued to improve upon the RestTemplate and Spring Social support for Android, which simplifies the process of making RESTful HTTP requests and accessing REST APIs secured by OAuth. And while we believe these are valuable additions for Android development, some developers have asked questions regarding the possibility of dependency injection support in Spring Android, because as you are probably aware, the Spring Framework already provides a popular Inversion of Control (IOC) container for enabling dependency injection in enterprise Java applications. Early in the Spring Android planning stages, dependency injection support was identified as a potential candidate for inclusion in the project. At that point, it was unclear what that support would entail, and how it would be implemented. Because of this, I began the process of researching and investigating the possible methods available for, and limitations of, performing dependency injection in Android.

Well, what is dependency injection? If you ask two different developers, you may get two different answers. You might hear about IOC, XML files, annotations, or some other implementation detail. In reality, dependency injection is simply a technique to reduce coupling by handing an object what it needs to work, rather than having the object reach out into its environment. That sounds easy enough, and you might be thinking to yourself you can already get this with class constructors and setter methods, which is completely true. However, recall from the overview section above, the Android system drives the application lifecycle, so the way we can do this is limited.

The Android Way

Without using any third party libraries, it is rather easy to pass a dependency to an Activity. As discussed earlier, the system creates the application instance. So by extending application, you can effectively create a singleton dependency instance, which can then be accessed by any of the activities in the app.


public class MainApplication extends Application  {

    private MyService service;

    @Override
    public void onCreate() {
        super.onCreate();
        service = new MyServiceImpl();
    }

    public MyService getMyService() {
        return this.service;
    }
}

The activity class has a method called getApplication() which returns a reference to the application object that owns the activity. We simply cast it to MainApplication, and we can access the getter method for the MyService. Of course, the activity now has to "know" about the application, which might seem like a disadvantage. But remember, the activity already knows about its application. The method is built in.


public class MainActivity extends Activity  {

    private MyService service;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MainApplication app = (MainApplication…

This week in Spring: August 23rd, 2011

Engineering | Josh Long | August 24, 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…

Micro Cloud Foundry for Spring Developers

Engineering | Josh Long | August 24, 2011 | ...

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…

Get the Spring newsletter

Stay connected with the Spring newsletter

Subscribe

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