Why I Wrote Yet Another Java Bean Framework

With so many Java Bean XML and dependency injection frameworks out there – did I really need to write another? Am I suffering from some terrible ‘Not Invented Here’ syndrome? In this post I’m hoping to persuade myself that I’m not, and hopefully I can persuade you that it might be worth a look too.

It all came down to Drag and Drop. I wrote my own framework because I couldn’t find another that allowed beans to be Cut, Pasted and Configured in place – while running – no restart required!

Here it is working between two server processes, scroll quickly for that Flip Book animation effect!

Oddjob Drag and Drop 1Oddjob Drag and Drop 2Oddjob Drag and Drop 3What’s going on? – I’m dragging the XML configuration for a bean from one server process to another. Here are those server processes:

Oddjob Drag and Drop ServersNow I’m going to drag that job straight into this post…

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<echo id="echo-job"><![CDATA[Hello from ${server.name}]]></echo>

…and no I didn’t cheat!

Here is that server drag and drop again, except in code:

public class CutAndPaste {

	public static void main(String... args) throws Exception {

		Oddjob oddjob = new Oddjob();
		oddjob.setConfiguration(new XMLConfiguration(new File("client.xml")));


		OddjobLookup lookup = new OddjobLookup(oddjob);

		DragPoint drag1 = lookup.lookup("client1/server-jobs", ConfigurationOwner.class

		String copy = drag1.copy();

		DragPoint drag2 = lookup.lookup("client2/server-jobs", ConfigurationOwner.class

		drag2.paste(0, copy);

		Runnable job = lookup.lookup("client2/server-jobs/echo-job", Runnable.class);



I also run the job in its new location – just for good measure.

Now many of you will be saying ‘Why would I want anyone dragging around my applications configuration!’, and yes, in production this is quite dangerous and most of the time you probably do want all your beans and their dependencies locked down.

But sometimes it might be really useful to have a bit of flexibility with your remote components configuration, and for those sometimes I wrote a cut and paste Java Bean XML based dependency injection framework.

Now I’m expecting lots of feedback telling me that XYZ framework will do this already, and I’m looking forward to it, and I don’t mind – because there is another reason I wrote the framework, the main reason… I loved every minute of it!