Sonntag, Mai 20, 2007

Smartfolders in Netnewswire

I am a long time user of NetNewsWire, the best newsreader you can find. Its sometimes hard to manage the huge and ever growing mass of blogs, news etc, so I tried a new strategy: I started using smart folders for the mass and try to keep the number of blogs I read regularly low. So I can concentrate on the things I am really interested in.

Donnerstag, Mai 10, 2007

Nice presentation by Hohpe

Infoq posted a nice presentation by Gregor Hohpe, where he talks about SOA. For him domain specific languages could be an answer to over complicated general languages like BPEL.

Also if you havent done so read his article about starbucks and the two phase commit: a very nice analogy about asynchronous communication in a real world example.

Dienstag, April 03, 2007

Use Burlap to build a simple Java-Ruby bridge

Yes, I know, there is this great tool JRuby which will hopefully be an essential part of the JDK in the near future, and yes there is REST where Restlet seems to be the most promising framework, but all I wanted is to speak with a very simple Java Interface from a Rails application. So I thought there must be an easier way, but it has to deal with ongoing changes to the interface. The answer for me was the Burlap protocol which you get with Spring for free. All you have to do is to expose your Java bean with the Burlap exporter:

<bean id="fooService"

<bean name="/FooService"
<property name="service" ref="fooService"/>
<property name="serviceInterface"

. Thats it for the Java side. Burlap is a very simple protocol where you dont map classes, what you get is a map with key, value pairs. But thats fine for me.

But also the Ruby side is easy to implement. I am still a newby with Ruby but that was relativly quick done (though its still not as easy to get information like you get for J2EE for instance, where you get too much information).
Because the Burlap protocol just supports the POST method you need the low level Ruby methods for Http:

Net::HTTP.start('localhost', 8080) do |request|
response ='/backendservice/FooService',

And here we go. All you have to do is to parse this XML:

vals = []
{|p| vals << p.text }

And as I said, what you get are key-value pairs with the exception of the first element which descripes the original type (classname).
I converted it to a map skipping the first element in the array:

@bashvals = {}
1.step(vals.length-1, 2)
{ |i| @bashvals[vals[i]] = vals[i+1] }

Mittwoch, März 07, 2007

Writing tests that test failure

Often forgotten because most of the time you want to proove that your code runs. Yes I know we all tend to be lazy. But to be complete in a sense of Sir Carl Popper you also have to falsify your assumption. You are forced to think about deeper about what your code does and what it should not do. But even further you proove that exceptions are treated correct in case of an error or worse like it happened to me it gets swallowed. I was about to refactor an ancient piece of software written in the early days of Java development. I wrote a test for a new feature and was happy to see my test was successfull. But writing a failure test I recognized that every exception was swallowed by an nice try {} catch (Exception) block just because this test failed.