tags:

views:

746

answers:

4

Is there any reason to use Spring (or other similar frameworks) as a server for GWT RPC? As far as I can tell, 99.9% features of Spring will not be used. Yet, lots of people are looking for best ways to use them together.

Could someone please explain, what are the benefits of using MVC frameworks (on server) with GWT, when all you need on server side is business logic?

Thanks in advance.

+9  A: 

I don't see any generally good point in using Spring MVC or another enterprise Java MVC library (like Struts) together with a layer which - as you said - offers only business logic (and therefore can be kept as small and clean as possible).

But Spring itself is way more than just a web (MVC) framework layer and using the dependency injection or AOP features or the ORM API or the Scripting language Groovy (which works fine with Spring) can be a huge benefit for any application.

Daff
Dependency injection can be achieved using different libraries. For example the light-weight Guice.Never used AOP, so don't know if it's cool or not.ORM... Yes, I forgot about that. May be a nice point.
Max
If your GWT app needs to make RPC calls to the server, then the MVC layer is still relevant.
skaffman
Don't see how I could include classical MVC there properly. The view is just a representation (XML or JSON) of the data so you really don't need the whole HTML/JSP/Taglib stuff. Of course separation of model and controller should still exist.
Daff
There are gwt-rpc libraries for spring that automatically wrap everything you need to gwt-rpc format. So you do not ned no XML or JSON.
Max
Well ok the GWT-RPC data are transferred just in another format, my point was that you can spare all the HTML/JSP fuzz that most Java Web Frameworks offer when using GWT-RPC (or any other serialized format).
Daff
+5  A: 

Spring is much more than just MVC.

Even when you do your UI with GWT, you still need some kind of backend logic. Things like databases, transactions, security, additional services integrations (emails? SOAP?) and so on.

For this Spring or any other Java server side technology can be a good solution.

Gregory Mostizky
+6  A: 

As daff said, Spring brings DI + AOP + transactions + many things... It is useful to have those stuffs managed on your server side with Spring.

Furthermore, the library gwtrpc-spring offers a very convenient way to declare POJOS as rpc services, with the @Service annotation. It avoids declaration of each rpc servlets in the web.xml, as the scan for classes with @Service is automatic.

GWT is just a toolkit, not a framework. If Spring can ease your dev, just use it.

ipingu
+3  A: 

I tend to go for GWT + GIN on the client side and Guice on the server side. But Spring could just as wel be used for persistance, transactions and organising your business logic on the server side.

David Nouls