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…
We are pleased to announce general availability of Spring Social 1.0!
Spring Social is an extension of the Spring Framework that enables you to connect your Java applications to Software-as-a-Service (SaaS) providers such as Facebook and Twitter.
The big 1.0 release includes fixes for all bugs reported since 1.0.0.RC3. See the change log for all the details (Core | Facebook | Twitter)
Spring Social requires Spring Framework 3.0.5 or > to run. We recommend Spring 3.1 for new applications to take advantage of the latest advances in the core framework. See the reference manual for a full description of dependencies.
It has been an awesome year leading up to this release. We are thankful for all of the community involvement that has helped make this a useful, quality project. Special thanks go to Matt Wright, Morton Andersen-Gott, Stefan Fussenegger, Bryce Fischer, Gabriel Axel, Marc Schipperheyn, Domingo Suarez, Gordon Dickens, Arjen Poutsma, and Juergen Hoeller for their support. I've taken the opportunity to reflect on our work in the last year at our team blog.
Join me for the webinar that I'll be hosting on September 29th.
On the heels of the Spring Data MongoDB 1.0.0.M4 release I'd like to announce the availability of Spring Data JPA 1.0.1 and 1.1.0.M1. The point release contains a variety of bugfixes listed in the changelog. The first milestone of the 1.1 train contains these bug fixes as well of course, adds IgnoreCase as keyword for the query parser and allows users to use that version alongside Spring Data MongoDB 1.0.0.M4 as they both refer to the same version of Spring Data Commons.
Beyond that we ship a ton of bug fixes and improvements mostly around the mapping subsystem and performance. For a detailed list of tickets fixed have a look at the changelog…
Releases | Adam Fitzgerald | September 02, 2011 | ...
There are less than two weeks to save $200 off the registration for SpringOne 2GX 2011! SpringOne 2GX is a one-of-a-kind conference for application developers, solution architects, web operations and IT teams who develop business applications, create multi-device aware web applications, design cloud architectures, and manage high performance infrastructure. The sessions are specifically tailored for developers using the Spring technologies, Groovy & Grails, and Tomcat. The recent releases of Platform as a Service solutions from multiple vendors (including VMware's Cloud Foundry technology) will be a central focus of many of the technical sessions and will provide developers with the optimal blueprints for the cloud. Whether you're building and running mission-critical business applications or designing the next killer cloud application, SpringOne 2GX will keep you up to date with the latest enterprise technology.
Be sure to register today to lock in this $200 discount.
I am pleased to announce the availability of Spring Data MongoDB 1.0.0 M4. Here are the most important features added:
Support for map-reduce operations in MongoTemplate
Provided means to use externalized queries to be executed by repositories
Support for geoNear queries on MongoTemplate and the repositories
New DocumentCallbackHandler interface on MongoTemplate
A DB wide WriteConcern can now be configured on the SimpleDbFactory
A WriteConcern configurable on MongoFactoryBean
Added a QuerydslRepositorySupport base class to ease implementing Querydsl based repositories
Configurable TypeMapper interface to control how type information is written and retrieved to and from Mongo documents
Beyond that we ship a ton of bug fixes and improvements mostly around the mapping subsystem and performance. For a detailed list of tickets fixed have a look at the changelog.
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.
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.
</li><LI>Thomas Risberg blogged today about <AHREF="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…
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…
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…
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.
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.
publicclassMainApplicationextendsApplication{
private MyService service;
@OverridepublicvoidonCreate(){
super.onCreate();
service = new MyServiceImpl();
}
public MyService getMyService(){
returnthis.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.
Spring enables you to focus on your business problem rather than the plumbing that connects components and systems. Take a tour of Spring’s key features from the core framework to infrastructure and data services and learn how to build, run and manage your modern Java applications. Getting started is easy and you can do it now.
Spring Framework Features
The Spring Framework helps you build Java Applications faster because it allows you to focus on your business problem rather than the plumbing code that connects components and systems. The features of Spring include: