JBossWS CXF – POJO vs Stateless [1104]

Cleaning up a bunch of code to reduce object instantiations got me thinking about the webservice layer. We are using POJO based webservices but it got to me wondering whether useless Stateless web service beans would improve memory usage. More accurately, whether it would improve garbage collection performance.

To test this, the plan was to build two versions of the same web service and load test it to see the memory and cpu utilisation to compare cost / performance.

In the process, I also discovered other differences.

Continue reading

Android – Managing Global Configuration

The Problem

Accessing preferences / configuration / settings from Android is actually pretty straightforward as long as you are in an Activity. To read:

// PREFS_FILENAME = "nameOfPrefsFile";

SharedPreferences pref = getSharedPreferences(PREFS_FILENAME,

String string = pref.getString("key", "default");
// 1 is the default if key isn't set
int intValue = pref.getInt("intKey", 1); 

// and so on

SharedPreferences is the key class. To write, you also need the SharedPreferences.Editor class, as follows:

// PREFS_FILENAME = "nameOfPrefsFile";
SharedPreferences pref = getSharedPreferences(PREFS_FILENAME,
Editor editor = pref.edit();
editor.putString("key", "value");
editor.putInt("intKey", 5);  

// Until you call commit, the changes will not
// be written, so don't forget this step

In general however, you will need access to settings in more than one activity and it seems a bit wasteful to get these bits littered through the application. Since I am lazy and like to write things just once, I  separated all the prefs stuff into one class called Settings.

Continue reading