In fact I think the problem comes from the 2 "new", they create the
DAO instead of Guice, so there is no injection.

The problem is the objects have mutual reference, so when I try
injection on them I have an infinite loop.

How can I make Guice avoid the loop ?

On Oct 27, 11:34 pm, Simon <[email protected]> wrote:
> I am writing a app engine application and I can't find a way to bind a
> provider into an object.
>
> I could bind this object into the Servlet, but couldn't into another
> object (which is injected into the servlet via a provider).
>
> I don't find why Guice do not inject the serviceDAOProvider into the
> ServerDAO.
>
> Here is the code :
>
> The servlet :
>
> @Singleton
> public class GreetingServiceImpl extends RemoteServiceServlet
> implements GreetingService {
>         @Inject private ServerDAOProvider serverDAOProvider;
>         @Inject private ServiceDAOProvider serviceDAOProvider;
> ...
>
> Here are the providers :
>
> public class ServiceDAOProvider implements Provider<ServiceDAO> {
>         @Override
>         public ServiceDAO get() {
>                 return new ServiceDAO();
>         }}
>
> public class ServerDAOProvider implements Provider<ServerDAO> {
>         @Override
>         public ServerDAO get() {
>                 return new ServerDAO();
>         }
>
> }
>
> And the class where the field serviceDAOProvider is not injected:
>
> @RequestScoped
> public class ServerDAO extends Updater<Server, ServerDTO> {
>         @Inject private ServiceDAOProvider serviceDAOProvider;
>
>         public Server update(Server entity, ServerDTO dto) {
>                 System.out.println(+serviceDAOProvider); // Null !
> ...
>
> Can you help me please I don't find the solution ...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to