Meaningless Drivel is fun!
The moose likes Spring and the fly likes Spring Architecture help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Architecture help" Watch "Spring Architecture help" New topic

Spring Architecture help

Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
I am at beginner level of designing apps in spring. That's why i am posting here to seek suggestions and help from you guys.

the project was based on simple daos with hibernate, struts and front end is using struts + freemarker (freemarker only at few pages). now the very first task it so add spring to handle the beans. I have break up my task as

1: spring beans injections
2: spring transaction management
3: spring bean injectsion in sturts actions etc.

for part 1, I am just pulling up the DAO to DAO Interfaces and adding the bean entry in application context

- for classes which are already using these daos, will get these beans from webcontext of spring.
- right now the transaction wil be managed with transaction util class which was already being utilized

My question here is it the right approach? (since i have no one aruond me to consult on it). Secondly how can i test it ? right now i have added some logging msgs in beans constructor which are pritned when maven build the project and run it.

The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Personally, I would add a Service layer to act between your Controller/Struts Action classes and your DAOs. This will allow for more flexibility later if you decide on adding business logic, which should not be in either your Actions or DAOs, they belong in their own layer.

Hope that helps.

Also make sure the Service classes have interfaces too.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
yeah, that was my proposal to the senior management to add the service layer as well. well what would be heirarchy then if i add service layer ?

i.e suppose the struts have controller name countryAction and the DAO's name i already mentioned. then there will be another third class say, countryService in between those? or what ?
I agree. Here's the link:
subject: Spring Architecture help
jQuery in Action, 3rd edition