You can't inject variables that are local to a method body. You'll need to
grab field references to A (or Provider<A>) during the servlet's
construction.

2011/4/29 garey <[email protected]>

> Hi -
>
>    I have a class that needs a database connection, so I have
> provides method in a module and I have a constructor like this
>
> class A {
>
>         @Inject
>         A(Connection c) { ...}
>
>         ...
> }
>
> now I have an init method in a servlet that I call if I want to
> initialize an A. The method requires some parameters, so I do
>
>     public void init( <parameters>) {
>        @Inject A a;
>
>        ...
>     }
>
> but I get a compile time error telling me that I cannot use @Inject in
> this way. What fundamental concept am I not getting (this time)?
>
> Thanks for any help;
>
> Garey Mills
>
> --
> 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.
>
>

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