Jun 7 2009

Google IO 2009: Mobile

I, like many 10-5 developers not working directly with ajaxified web 2.0 applications, was not able to go to the Google I/O conference. I don’t feel so bad not going since Google has just released video recordings of over 80+ technical presentations from Google I/0. Most of the technical presentations are pushing Google’s APIs such as Android, Google App Engine, GWT, and Open Social.

As an aid for myself, and maybe other GWT developers, I have organized the pertinent Android and mobile talks as follows…

Turbo-charge your UI: How to Make your Android UI Fast and Efficient
Learn practical tips, techniques and tricks for making your Android applications fast and responsive. This session will focus on optimizations recommended by the Android framework team to make the best use of the UI toolkit.

Supporting Multiple Devices with One Binary
The Android platform is designed to run on a wide variety of hardware configurations. Learn how to take advantage of the application framework to make your application run on a wide variety of devices without having to build a custom version for each.

Coding for Life — Battery Life, That Is
The three most important considerations for mobile applications are, in order: battery life, battery life, and battery life. After all, if the battery is dead, no one can use your application. In this session, Android engineer Jeffrey Sharkey will reveal the myriad ways — many unexpected — that your application can guzzle power and irritate users. You’ll learn about how networking affects battery life, the right and wrong ways to use Android-specific features such as wake locks, why you can’t assume that it’s okay to trade memory for time, and more.

A General-purpose Caching Architecture for Offline-capable Web Applications with HTML 5 Databases or Gears
Puzzled by all the new architectural choices possible when trying to build an offline-capable web application? So were we until we decided to design the newly launched Gmail Mobile Web for iPhone and Android’s offline capabilities by analogy with microprocessor caches: offline via a portable write-through caching layer running on either HTML 5 or Gears databases.

Mastering the Android Media Framework
Some monks might take a vow of silence, but Android certainly hasn’t. Attend this session, and help your app find its voice. Android engineer David Sparks will explore the multimedia capabilities of the Android platform, lifting the covers on the infrastructure to show you how it works and the right (and wrong!) ways to use it. You’ll learn how things work under the hood, how to dodge the common media-related developer pitfalls, and how to write secure and battery-efficient media code.


May 14 2009

Lookup Pattern and Java Generics

In some situations I dislike the verbosity of declaring Java generics.

Map<Key<String, Integer>, List<Item>> m = getItemsMap();

But using Java generics reduces other forms of tedious class casting common when using List and Map objects. For example, in my current project their we use a Lookup pattern, used to locate concrete implementation to certain key services. For example, to read and write application data we use a FileService which we can get via the Lookup class.

FileService fs = (FileService)Lookup.lookup(FileService.class)

These services we lookup are stateless and we can switch the underlying implementation by modifying some configuration file. In terms of this discussion, I wanted to note that casting. Using Java generics that cast is not required if you use parameterized types. Notice that the key of the lookup is a Java type, in our application it is an interface which the underlying implementation class needs to implement. As you can imagine, the implmenation of the lookup method can be simplified to the following…

public static Object lookup(final Class type) {
    // compoments is a map of implementation service
    Object comp = components.get(type);
    return comp;
}

Using Java genetics we can use the class information in the parameter to cast the return type correctly. We can remove the required class cast by updating the code that locates the required concrete class for the service requested. Here is a simplified version of the lookup method which removes the need to cast.

public static <t> T lookup(final Class<t> type) {
    T comp = (T)components.get(type);
    return comp;
}

Now, using this updated lookup method and employing Java generics our lookup can be of the following form.

FileService fs = Lookup.lookup(FileService.class);

Apr 8 2009

Google App Engine for Java

Google App Engine was originally released, in Google beta, a year ago. Google App Engine originally had programming support for the Python programming language, but today, on the one year anniversary of its beta release Google has added Java support. Building Java support into Google App Engine means that they have built it for JRuby, Groovy, JavaScript, and all those languages that run on the JVM.

You can request access to Google App Engine for Java via this sign up. I am sure there will be a more news, documentation, and tutorials at Google I/O Developer Conference in May. In the mean time here are plenty of resources to get you started.

Google App Engine for Java


Apr 7 2009

Java Web Service with HTTPS

I recently had to write a small Java client that calls out to a Java Web Service that was sitting behind HTTP over SSL (HTTPS). From what I could tell, they had an expired or self signed certificate because calling the Web Service would throw an nested SSLHandshakeException, ValidatorException, and SunCertPathBuilderException that read something like the following

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

After searching around I found a 2006 article from Andreas Sterbenz describing the solution to the unable to find valid certification problem I was encountering. The article went into to much detail as far as I am concern but it did provide the right solution.

The gist of the solution is to download and compile this Java class that saves the certificates from a particular domain to a file. This program will save a keystore with the certificates called jssecacerts in the local directory where you run the Java class.

This keystore needs to be used from the client application that is connecting to a SSL service. You can start the client Java process with the following Java system property: -Djavax.net.ssl.trustStore=<PATH TO KEYSTORE> … or you can replace the the cacerts file under jre\lib\security for the JVM you are using with the jssecacerts keystore file created from the aforementioned Java program.

Using the keystore file correctly should fix the unable to find valid certifiction exception.


Dec 7 2008

Top Programmers on Twitter to Follow

Earlier this year I created a short list of top rubyist to follow on Twitter. At that time, that list was the first list of programming twitterers I had come across. Since then many other folks have created lists of programmers that are on twitter to follow. No matter how long the list of twitterers to follow is, you will always miss someone. So instead of coming up with yet another list of programmers to follow on twitter, I came up with a list of list of favorite .net, ruby, java, and technologist to follow on twitter.

If you like you can follow me too.


Nov 14 2008

Silicon Valley Codecamp 2008

There was a large contingent of Microsoft evangelist at this years Silicon Valley Codecamp 2008 pushing Microsoft Azure, XNA, and Silverlight technologies. I was able to see Microsoft Surface in action. Surface is an interactive table top, it reminds me of a large iPhone made into a coffee table. Just like the iPhone, you gesture at the Surface screen to manipulate objects. Java, Groovy, and Flex also had a good showing. Below are conference notes from each of the sessions I was able to attend.

Continue reading