Spring- Wire a property to a property…


Found a back door to a problem I was having this morning. First let me offer some background. I’m in the middle of an ugly hack! A hack unlike anything you’ve ever seen! I’m tying our order entry system into our reporting system in such a way that when a certain report runs we start dummy temporary orders, submit them, and delete them. I’m not going to speak much on the subject, just know that it is absolutely necessary for completing my project. The project itself is a tangle of additional code just to get a report that looks like it was created on one of those legacy dot matrix green bar printers from the seventies. (We’ll soon need to work on improving the look and feel of the reports but that’s another topic.) The hack isn’t what’s important, rather it is the code around the hack that draws our attention today. (By “our attention I’m referring to the combined attention span of both you and I, you’re with me right?) I needed a way to pass a stateful session bean around what was essentially a Springframework-wired report-framework writtent entirely in the POJO programming language. (You have heard about POJO haven’t you? No? Shame on you! I spit at the ground you walk upon!) It’s bootstrapped into EJB/JMS land using “clever” message driven bean delegation pattern which is also poorly implemented. If it’s an EJB and it’s in the same VM as the reporting code then I can use Spring JNDI convenience classes to get the thing out of the naming directory and into my object right? Well, there’s more and it’s not that simple. Our EJBs, stateful as they are, have grown glued to our authentication/authorization code which is hard-wired into every one of our data objects which, themselves, poorly attempt to implement the DTO pattern introduced in the early days of EJB that we have long forgotten. (Well most of us have forgotten while others like myself continue to be pestered by its ugliness.) In short, we have a mess of messy integration that messes everything up whenever you mess with the mess. (If I’m not mess-taken.)

The reporting framework stuff, is far from perfect, though we don’t want to mess it up with our old EJB ugliness and there’s about three or four brittle objects in-between the part where the EJB code breaks off and the POJO code picks up. I didn’t want to mess with that either. I got frustrated and tapped one of my buddyies on the other side of my fabric-like cubicle wall. While talking it out with him (…we never actually help one another with problems, instead one always ends up functioning as a listening board while the other rambles enough about the problem to find his own solution. You really gotta find yourself a buddy like this…) I realized that what I really needed was a way to pass a property from an EJB delegate (the point where the EJB crosses into POJO) into the ugly code I was writing. The property itself was not springwired. Instead it was a value sent from the client over the wire and pushed into the message driven bean delegate by a wrapping EJB/MDB superclass. (The “clever” code.) What I came up with was some Spring descriptor code that allowed me to wire a property from one bean, already instantiated in the descriptor, to another. The Springframework MethodInvokingFactoryBean provided the glue. The net result: I pulled a property from one bean into another without haveing to pass it, daisy-chain style through all the layers in between. I’m probably speaking greek to some of you but this is some really wild stuff. Y’all don’t hear me though…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s