Tuesday, March 8, 2011

jBPM5 lightweight? Running on Android!

I recently bought myself a new Android phone, and as a developer, that obviously means I have to try and write my own application for it ! :)

And since we always claim jBPM is such a lightweight engine that you can embed it practically anywhere, I decided to give that a try: run the jBPM5 engine on Android. Some people might be thinking, why would I want to do that? Well, my primary goal was just as a proof of concept. But maybe, if we extend that proof of concept a little more and add more Android tasks, end users without any real development experience might be able to use it do model simple Android applications as well, who knows!

So after downloading the Eclipse tooling and following a hello world example, I decided to create a simple process that first asks the user for some keyword and then uses this keyword to search the jBPM community forum for entries containing that keyword (I know, not rocket science, you don't really need a workflow engine for that but it's just a demo example).


After adding the jBPM5 jars to the classpath, I updated my application to start this process when the application is started. I also created two domain-specific services for Android, one for requesting some input from the user (where I then bind this result to a process variable) and one for showing a web page (which shows a URL, which I created based on the input of the user).

And it worked almost[*] out of the box! So this is what it looks like (on the emulator, but it runs nicely on my phone as well). First you start the jBPM application ...



The first node in the process will ask you for a keyword you want to search for ...


And the last node will show the results of the query on the jBPM community forum in a browser ...


I'm pretty sure there are a lot of developers out there that try to play with new technologies like this, so if you're interested in playing with this and maybe extending this a little, let me know. Imagine we add a few more default services for showing an image, getting some file, getting GPS location, etc. Would be pretty cool if you could create more advanced applications like that.

I've uploaded the source code and the jbpm-android.apk so you can give it a try yourself !

[*] A small modification is needed in org.drools.util.CompositeClassLoader. Apparently, the Android JVM doesn't allow null as the parent classloader so I changed that to super(CompositeClassLoader.class.getClassLoader()) in the constructor, and that works fine.

7 comments:

  1. Kris,

    Very cool! Will be the first app I install when I get an android phone! ;-)

    ReplyDelete
  2. Pretty cool man! I hope that community people extend this application!

    ReplyDelete
  3. Hmmm... great. Let me give it a try as well.

    ReplyDelete
  4. Great stuff, i was hoping to find something like this, thanks man!
    One more thing, i'm trying to make it work with a *drl file instead, but i can't manage to make it work! any ideas?

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. great work, If someone is looking for run drl rules on android, I made a demo project on github:

    https://github.com/jorgemfk/dr-drools-android-demo

    https://play.google.com/store/apps/details?id=mx.dr.drools

    ReplyDelete
  7. I have worked on this in google summer of code program and It was a success. I have integrated jBPM5 engine to the android and automated the process.
    Code :
    https://github.com/supunasp/jbpm-android

    ReplyDelete