[Laszlo-dev] The case for Spring

Mika Göckel mika.goeckel at gmx.de
Sat Nov 12 06:46:11 PST 2005


Hi.

I ran into a question which made me looking deeper into the openlaszlo 
server java code.
The question was: How do I provide a server side Java object called by 
<javarpc...> with a link to Hibernate.

As these object are created via newInstance() in 
org.openlaszlo.data.JavaDataSource there is no way to inject 
dependencies other than pre-creating them at a different place 
(ServletFilter for example) and storing them into the session object.
I don't think that this is a good solution, because you twiddle around 
with session objects which you probably don't really should know about 
(The SessionBindingMap i.E.) if the rules of cohesion and coupling still 
apply. That means you need knowledge about the internal structure of 
openlaszlo and create an unnecessary dependency.

A solution I see here is letting a Factory create this objects, and as 
I'm a fan of Spring I would propose to let Spring 
(www.springframework.org) take over this task.

Having said that I'd like to ask if it wouldn't be a good idea to 
refactor the laszlo server code and bring spring in, because I see many 
places, where a little bit more Inversion of Control or Dependency 
Injection would clarify the code a lot.

What are your thoughts?

Cheers, Mika
-------------------------------
cyber:con
Gesellschaft für neue Medien mbH
Rathausallee 10
53757 Sankt Augustin
Germany
www.cybercon.de

tel.: +49 2241 93 50 0
fax: +49 2241 93 50 99
mob +49 172 279 2771
skype mika.goeckel



More information about the Laszlo-dev mailing list