Hi Bruce,

First off I think I have definitely used your blog in the past, I just
want to is has been very useful.

Now I would imagine the question you asked will lead to some very
interesting answers that I look forward to reading. However on the
whole, I don't think it could be class as bad practise using Spring,
unless the size of your application isn't big enough to warrant it, but
then if that was the case would you still use S2?

I love Spring, I am a big fan of the coding by interface and decoupling
of layers. I have fallen into (maybe a trap) the routine of using Struts
(1/2) with Spring and Hibernate JPA. I find this a nice complement of
tools and pretty much allows me to accomplish majority of what my web
application sets out to do.

For example and app I writing at the moment I am using

Struts 2
Scriptaculous/Prototype
Spring 2.5.5
Hibernate JPA

I like splitting my application into layers of

Actions
Service
DAO

However with the light of the entitymanager a DAO is fast becoming
slightly redundant as most of my DAO methods consist of one line.

The beauty of Spring with transactions is the ability to mark out a tx
boundry with simply using the @Tranactional annotation on the service
method. This also allows for encapsulation (I hope I have the right OO
term here) as you can this to the DAO methods but mark it as saying a tx
is required and would fail if a tx isn't open. 

There is also stereotyping which allows you to mark classes as Service,
DAO (actual @ is repository) or Controller (if you are using Spring MVC)
this can lead to a more refined autowiring as well as pretty much
eliminating the need for XML configuration. I personally use
stereotyping for exception translation from the entitymanager (look for
DataAccessException) this allows for a cleaner Service layer.

I have also use Spring in conjunction with EJB's either looking up an
EJB an injection into a POJO or injecting a POJO into an EJB - Very
useful when coming across legacy projects...

Spring is such a huge project and I don't think I have even used the tip
of the ice berg. 


I hope this helps...

James





-----Original Message-----
From: phillips1021 [mailto:bphill...@ku.edu] 
Sent: 25 November 2009 16:29
To: user@struts.apache.org
Subject: Is Using Spring With Struts 2 A Good Idea?


At the University of Kansas (#1 college basketball team :) we use Struts
2
for our web application framework.  Its worked very well for us.

I've been learning the Spring framework and how to use it with Struts 2.
I
think the two frameworks work very well together.

I'm preparing a class for the other Java developers on how to use Struts
2
and Spring together.  As part of my research I'd like to hear from other
Struts 2 developers on if you use Spring with Struts 2 and if you think
its
a good or bad practice.

Thanks in advance for any feedback you can provide on why or why not
it's a
good idea to use Struts 2 with Spring.

Bruce Phillips
http://www.brucephillips.name/blog http://www.brucephillips.name/blog 


-- 
View this message in context:
http://old.nabble.com/Is-Using-Spring-With-Struts-2-A-Good-Idea--tp26515
837p26515837.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to