public class MyScript extends GroovyScript {
public void run(String... args) {
@Inject Screen screen;
if(screen != null) {
println "We have one!"
} else {
println "There is no screen :("
}
}
}
There are a couple of ways to get around this:
1) You can use the new annotations in Groovy 1.8 that make script variables members or static. I think these annotations are part of Groovy 1.8, but don't take my word on that. I think these look like this:
@Member @Inject Screen screen
@Static @Inject Screen screen
2) You can perform some AST to move the variables from the run() method to the class as an instance variable or static variable
I went with #2 since I didn't have access to the annotations.
-bp
> --
> You received this message because you are subscribed to the Google Groups "google-guice" group.
> To post to this group, send email to google...@googlegroups.com.
> To unsubscribe from this group, send email to google-guice...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
>