Spring 2.0 integration
Martin Klang <[email protected]> Mon, 29 May 2006 12:41:56 +0100
| Newsgroups | gmane.text.xml.o-xml |
|---|---|
| Message-ID | <[email protected]> |
Hi again! Question: anyone on the list using Java Spring [1]? It's a pretty cool IOC framework (Inversion of Control, aka 'the Hollywood principle'), which basically means that you can get the benefits of a full application framework without the massive overheads (and headaches) that come with traditional J2EE systems such as EJBs. It is based around POJO beans that are tied together with each other and the framework using configuration files. As of Spring 2.0 you can define beans in scripting languages such as JRuby, Groovy and Beanshell. This is really rather interesting, as it provides a way for developers to mix and match languages, choosing the most suitable language for any particular task. In reality things might be a bit more complicated, but at least that's how it might work. In short, a very nice feature. Having thought about it for a while I figured I should try to code up adaptors to add o:XML as one of the supported languages. It was actually pretty easy, even though I don't really know much about Spring. All I had to do was create a ScriptFactory that compiles and runs o:XML code, and a wrapper to handle function calls. Easy. The wrapper handles transformations to and from DOM Nodes, so that you can pass and receive DOM objects to/from o:XML beans without worrying about conversions. Same with primitive types: String, Boolean, Number etc. It's a bit tricky to explain, but if you know Spring you probably get the picture. The end result is that the o:XML beans are made part of the framework with a simple config file, and the other components don't even know that they're o:XML. Likewise, o:XML can work seamlessly with objects that are written in Ruby or plain Java (I've tested - it works!). Now I'll just see if the Spring people want the adaptors in their codetree, otherwise I'll add them into the stock ObjectBox. If anyone wants to have a play, there's source and/or binary jars available for the asking, together with a few examples. Oh, and you'll need Spring 2.0 M2. /m [1] http://www.springframework.org/