Hello,

I am building a small framework in which I want to call a method
dynamically. The method can have injectable parameters. I want to use
Guice's internal method injection to call this method, but it seems
that this is not possible. A small (simplified) example:

class TestClass
{
   public void testMethod(@Named("name") String test)
   {
        System.out.println(test);
   }
}

In the module I want to bind it:

bind(String.class).annotatedWith(Names.named("name").toInstance("value");

And then at runtime do something like this:

Method method = TestClass.getMethod("testMethod", String.class);
guiceInjector.callMethodWithInjection(method);

As far as I can see the way to go is to manually build a key for each
parameter and use an injector to get the instances. Then once I have
all the parameters, call the method. Since this seems to duplicate the
functionality of method injection, it feels a bit odd to duplicate
code.

Any advise?


Greetz Erik

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