On Sun, Aug 30, 2009 at 11:01 AM, Erdinc <[email protected]> wrote:

>
> Hi,
>
> I have a class which has to be initialised with 2 properties which are
> stored as http session attributes. These initialisation properties
> will be passed to the constructor of the class so, for binding it's
> interface to this class I am thinking of writing a provider. Code is
> something like this:
>
> interface A {
> }
>
> class DefaultA implements A {
>   public DefaultA(String x, String y) {
>       // x and y are values stored in users HTTP session...
>   }
> }
>
> class AProvider implements Provider<A> {
>   public A get() {
>       return new DefaultA(x, y); /// !!!! Here is the problem.. How
> can I access x and y from the HTTP session here?
>   }
> }


Inject HttpSession into the Provider itself (you must be using Guice Servlet
for this). Then you can dig out what you need.

Dhanji.

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