Hello,

i'm trying to follow the example at 
http://code.google.com/p/google-guice/wiki/ServletModule
named "Using RequestScope".
I need to inject a username (a string) classes of my webapps.

So a added a servlet filter doing something like :
---8<---
httpRequest.setAttribute(Key.get(String.class,
Names.named("username")).toString(), my_username));
---8<---
and i added the filter mapping in my guice ServletModule

Then in a class requesting the username, an injected it as :
---8<---
private final Provider<String> username;

@Inject
public MyUserService(@Named("username") Provider<String> username) {
    this.username = username
}
---8<---

but when the MyUserService class is instancied by guice, i get an
exception :
No implementation for java.lang.String annotated with
@com.google.inject.name.Named(value=username) was bound.
  while locating com.google.inject.Provider<java.lang.String>
annotated with @com.google.inject.name.Named(value=username)

Any idea on how to inject the "Key" added to servlet attribute ?

Thanks
Anthony.

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