Archive

Archive for the ‘Java Development’ Category

J2ME, PushRegistry and reading SMS

July 13, 2010 Leave a comment

J2ME has a nice feature: PushRegistry. You can “register” an event which then starts up automatically your application.

This of course also works for receiving SMS on specific ports.  (SMSes sent to a non-standard port will not show up in the inbox).

If such an SMS comes in on – lets say port 4321 – your application starts up, you can then easily find out that your app was woken up by such an event and read the SMS via the java messaging API. (Create the MessageConnection using a Connector, then call the method receive to get it).

But there is an interesting issue:

if during your tests once your application crashes between starting up and the call to receive, the message will remain in the SMS queue. Now if a new message comes in, your application is triggered, but if you now call the receive method, you will get the first message in the queue and not the actual one.

Now this gets a little bit tricky, as you can not enumerate the message queue and the call to receive is blocking – so you can not just “read until the last message is read”, because you don’t know when the end of the queue is reached and if you call receive once more, your application is stuck until the next message arrives.

Gladly, there also exists the method to setup a messagelistener, which is called once for every message in that queue. But now you have the problem, that this is done asynchronously, so you can not wait until the last message is received by this listener and then continue with it.

The solution is: if your application is triggered, read the message, then install the listener to purge the rest of the queue. If there already was a message in the queue, you have read the wrong one, but at least all following calls will work.

Working Environment

May 14, 2010 Leave a comment

Often I am asked, which is a good software development environment, so I’ll sum up my preferences including some links where things can be found.

If you develop in PHP or Java, I recommend Netbeans from http://www.netbeans.org . It is free, fast, has lots of plugins and everything you need. If you develop Software for Windows, consider buying Visual Studio from Microsoft.

If you work in a team, use Subversion (which is typically part of every Linux distribution – or download it from http://www.collab.net ). Netbeans comes bundled with a subversion client, so you won’t have to deal with this. But for Visual Studio, you need to install the Ankh plugin from http://ankhsvn.open.collab.net/downloads.

If you need Software for Bugtracking and project management, I recommend JIRA and the Greenhopper plugin from http://www.atlassian.com. You then need the Netbeans JIRA plugin or the Atlassian Connector for Visual Studio. I’d further recommend to install the JIRA client (windows software) to integrate it into your development suite.

For developing Java Software that consists of many packages, uses lots of libraries or work in a distributed team, don’t use an ant based project – make it maven based. Then, install your own repository manager on one server (I recommend artifactory) and install hudson for continous build integration. If you include a distributionManagement – part in your maven build file (pom.xml), you can make hudson publish the created artifacts automatically to your repository. There of course exist plugins for integration hudson into Netbeans (to watch and start the builds) and JIRA (which will then show the build status, possible errors and links issues).

Then you of course need documentation for the code. If you are writing Java software, write your javaDoc-code (netbeans will assist you) and if you need really pretty documentation and possible even UML diagrams – use the doxygen plugin and put it in your maven build file.

If you are using Visual Studio, use the XML documentation http://msdn.microsoft.com/en-us/library/b2s063f7.aspx and build it with http://sandcastle.codeplex.com/ – don’t forget to install the ghostdoc plugin which aids you in creating the required sourcecode documentation.

Hello world!

March 5, 2010 1 comment

So here is my blog – the first entry is always the most boring one, so just skip it. 😉