Question

I am new GWT. I have a project where I am using GWT and Spring as our technologies to implement. I have done Spring integration with GWT, with the help of following links. http://technophiliac.wordpress.com/2008/08/24/giving-gwt-a-spring-in-its-step/ https://docs.google.com/document/pub?id=1USHYx9cB3B1s1zM4dlkzEZ759D3lEfavn_dDewvBkaA Here with this, I am able to apply the Dependency Injection with only Server side classes which holds the actual business(Remote Service) functionality.

My questions are,

  • How can i apply Dependency Injection for all other classes like those are in client, shared, view, presenter packages?

  • Which dependency Injection is better? I mean GWT provided two dependency injection mechanisms

    1. guice is for implementing dependency injection on server side

    2. gin is for implementing dependency injection on client side.

    3. and Spring Dependency Injection.

    Which one is better to select? either GWT Dependency Injection or Spring Dependency Injection? or combination of both?

Please reply me.

Thanks,

Saritha.

Was it helpful?

Solution

Spring is not supported for GWT so you have to use GIN for the client side.

Combine Guice and Spring on the server-side makes no sense, because Spring managed beans are not compatible to Guice managed beans.

So you have to ask yourself which DI framework you want to use on the server side. Both do a very good job. Guice is more ligthweight and Spring offers a lot of additonal modules.

I don't see any advantages using Guice on the server side because of the fact that your are using GIN on the client side.

OTHER TIPS

GWTP makes heavy use of dependency injection through google-guice and google-gin. You will therefore need to add these libraries to your project.

google-guice is DI for server side and gin is DI for client side.

GIN (GWT INjection) brings automatic dependency injection to Google Web Toolkit client-side code.

Which one is better to select? either GWT Dependency Injection or Spring Dependency Injection? or combination of both?

For client you have only one option that is "gin". because guice & spring both are used at server side. and also combination of spring and guice only for server possible not for client.

GWT client side dependency injection can be provided by Gin framework only. In this case if you want to use GWT best practices (DI, MVP etc) and test your client side code your should look at this question. It explains how to write light-weight JRE mocking tests with the help of Guice. So if you are starting to use Gin than you should not avoid using Guice. There aren't any reasons to use Gin on the client-side and Spring DI at the server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top