Hi,
I want to inject things into Groovy scripts, but would prefer to
create them without groovy-guice if possible. My java code looks like
this:
final Class groovyClass = gcl.parseClass(someFile);
Injector childInjector =
mainInjector.createChildInjector(new AbstractModule() {
@Override
protected void configure() {
requestStaticInjection(groovyClass);
}
});
String[] args = {};
Class[] argTypes = {args.getClass()};
Object passedArgv[] = {args};
Method m = groovyClass.getMethod("main", argTypes);
m.invoke(groovyClass, passedArgv);
my groovy looks like:
@Inject Screen screen;
if(screen != null) {
println "We have one!"
} else {
println "There is no screen :("
}
I think this should work ... I believe that Screen is implicitly
static and that requestStaticInjection should cause it to be injected
at the time I create the child injector. However, it doesn't seem to
be working.
I realize this is stuck somewhere between a groovy question and a
guice question but I think it's closer to guice since the groovy class
is just a class (once compiled by the guts underneath
GroovyClassLoader).
What's wrong?
--Chris
--
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.