You should be using one Injector, total. That's a core part of how Guice
works. Add all your Modules to this single injector:

   Injector injector = Guice.createInjector(new DemoModule(), new
ClientModule());

Colin

On Wed, Jul 21, 2010 at 10:56 AM, Jerem's <[email protected]> wrote:

> hmm maybe there few thibgs I have not understood yes about guice.
>
> I have One injector per module.
> But I don"t understand what do you mean by installing module....?
> what do you mean by "installing?
> yes it is that main class where I saw errors.
>
> I Don't think I have install anything, so it must be my error.
>
> Jérémie
>
> On 21 juil, 15:38, Sam Berlin <[email protected]> wrote:
> > On Wed, Jul 21, 2010 at 5:31 AM, Jerem's <[email protected]> wrote:
> > > hmm no. I delete the "annotatedWith(ToDot.class)". so I don't use
> > > anotation,
> >
> > > My main class look like that :
> >
> > >        public static void main(String[] args) {
> > >                Injector demoInjector = Guice.createInjector(new
> > > DemoModule());
> > >                Injector clientInjector = Guice.createInjector(new
> > > ClientModule());
> > >                ISimpleGraph demo =
> > > demoInjector.getInstance(ISimpleGraph.class);
> > >                IClient client =
> clientInjector.getInstance(IClient.class);
> >
> > Is this the same main class you're using where you said you saw errors
> using
> > MapBinder?  Are you installing the module with the MapBinder bindings in
> > DemoModule or ClientModule?  Why are you using two different Injectors?
> >
> > sam
> >
> >
> >
> >
> >
> > >                System.out.println("Drawing graph...");
> > >                try {
> > >                        client.executeService(demo, DrawGraphType.DOT,
> > > "demo.dot");
> > >                        client.executeService(demo, DrawGraphType.TEXT,
> > > "demo.txt");
> > >                } catch (IOException e) {
> > >                        System.out.println("failed !!!");
> > >                        System.out.println(e);
> > >                        e.printStackTrace();
> > >                }
> > >                System.out.println("Done.");
> >
> > >        }
> >
> > > Jeremie
> >
> > > On 20 juil, 23:03, IvanoBulo <[email protected]> wrote:
> > > > Because you've specified "annotatedWith(ToDot.class)". But when you
> > > > getting instance through injector, as a key you are using an
> interface
> > > > only.
> >
> > > > You may try:
> >
> > > > class Test {
> > > > @Inject @ToDot
> > > > IDrawGraphService drawDotService;
> >
> > > > public Test () {
> > > >  Injector drawGraphInjector = Guice.createInjector(new DrawModule());
> > > >  drawGraphInjector.injectMembers(this);
> >
> > > > drawDotService.draw(); ///or whatever
> >
> > > >  }
> >
> > > > }
> >
> > > > - Ivan
> >
> > > > On 19 Лип, 17:21, "Jerem's" <[email protected]> wrote:
> >
> > > > > Hello I try to use annotatoij on a local variable :
> >
> > > > > this is my module :
> >
> > > > > public class DrawModule extends AbstractModule {
> >
> > > > >         @Override
> > > > >         protected void configure() {
> >
> > >
> this.bind(IDrawGraphService.class).annotatedWith(ToDot.class).to(DrawDotSer
> > > viceImpl.class);
> > > > >         }
> >
> > > > > }
> >
> > > > > and my Annotation look like that :
> >
> > > > > @Retention(RUNTIME)
> > > > > @Target({ LOCAL_VARIABLE, FIELD, PARAMETER })
> > > > > @BindingAnnotation
> > > > > public @interface ToDot {
> >
> > > > > }
> >
> > > > > and I try to do that :
> >
> > > > > Injector drawGraphInjector = Guice.createInjector(new
> DrawModule());
> > > > > @ToDot
> > > > > IDrawGraphService drawDotService =
> > > > > drawGraphInjector.getInstance(IDrawGraphService.class);
> >
> > > > > But I have an exception :
> >
> > > > > Exception in thread "main"
> com.google.inject.ConfigurationException:
> > > > > Guice configuration errors:
> >
> > > > > 1) No implementation for
> > > > > fr.irisa.cairn.simpleGraph.drawGraph.service.IDrawGraphService was
> > > > > bound.
> > > > >   while locating
> > > > > fr.irisa.cairn.simpleGraph.drawGraph.service.IDrawGraphService
> >
> > > > > 1 error
> > > > >         at
> > > com.google.inject.InjectorImpl.getProvider(InjectorImpl.java:784)
> > > > >         at
> > > com.google.inject.InjectorImpl.getProvider(InjectorImpl.java:743)
> > > > >         at
> > > com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793)
> > > > >         at
> > > > >
> fr.irisa.cairn.test.simpleGraph.runTimeTest.Launch.Main.main(Main.java:
> > > > > 25)
> >
> > > > > do you know why?
> >
> > > > > jérémie
> >
> > > --
> > > 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]<google-guice%[email protected]>
> <google-guice%2bunsubscr...@google groups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-guice?hl=en.
>
> --
> 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]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
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