how to get named property directly from an injector

104 views
Skip to first unread message

Alper Akture

unread,
Dec 4, 2012, 9:19:14 PM12/4/12
to google...@googlegroups.com
Is there a way to get a name property directly from an injector? I know we shouldn't use injectors directly, but this is a special circumstance. I was looking for something like

boolean authBypass = injector.getProperty(@Named("bypass_auth"))

or similar

Thanks!

Christian Gruber

unread,
Dec 4, 2012, 9:25:18 PM12/4/12
to google...@googlegroups.com
How about…

injector.getInstance(Keys.get(Boolean.class, Names.named("bypass_auth")));

Christian.

Alper Akture

unread,
Dec 5, 2012, 4:20:40 PM12/5/12
to google...@googlegroups.com
thanks! I'd seen that but wasn't sure if it was what I needed. Looks like will work.
Reply all
Reply to author
Forward
0 new messages