In which case the fix for Chris might be as simple as providing a Context
instance to the Application.

I still think it would be worth "future-proofing" FinderFactoryModule,
though.

--tim

On Thu, Aug 14, 2008 at 4:05 AM, Jonathan Hall <[EMAIL PROTECTED]> wrote:

> Maybe down to: "Important Context Changes" dated 29/07/2008
>
>
> "- the Context instance given to an application (or any Restlet actually)
> will be the one effectively used. If parameters are set, they will be
> directly and permanently accessible. If none is given, a null context will
> be returned by getContext(), no default context will be returned anymore."
>
> Tim Peierls wrote:
>
>> Chris,
>>
>> I managed to get some slightly less limited connectivity out here in the
>> Maine woods.
>>
>> When you do discover what changes between m4 and m5 caused
>> Context.getContext() to return null in m5, I think it might be a good idea
>> to change FinderFactoryModule so that subclasses can override the default
>> Provider<Request>, Provider<Response>, and Provider<Context> definitions.
>>
>> I won't be back to full connectivity until the 21st, but you could make
>> this change in your local code by creating three protected methods in
>> FinderFactoryModule and moving the "new Provider..." code in the configure()
>> method to these new methods. I'll give the example for Context:
>>
>>               // in configure()
>>               bind(Context.class)
>>                .toProvider(newContextProvider());
>>
>>    // new method in FinderFactoryModule
>>    protected Provider<Context> newContextProvider() {
>>        return new Provider<Context>() {
>>            public Context get() { return Context.getCurrent(); }
>>        });
>>    }
>>
>> Then whenever you need a non-standard Context provider, you can say:
>>
>>    FinderFactoryModule ffm = new FinderFactoryModule() {
>>        protected Provider<Context> newContextProvider() {
>>            return ...; // your non-standard Context provision code here
>>        }
>>    };
>>
>> This doesn't answer the most important question -- why does
>> Context.getContext() return null -- but it might give you a workaround.
>>
>> --tim
>>
>>
>> On Wed, Aug 13, 2008 at 4:54 PM, Chris Lee <[EMAIL PROTECTED]<mailto:
>> [EMAIL PROTECTED]>> wrote:
>>
>>    Hey guys, I followed Tim Peierls' excellent tutorial on using
>>    Guice in Restlets
>>    (found at
>>
>> http://tembrel.blogspot.com/2008/07/resource-dependency-injection-in.html
>> )
>>    and
>>    found that, while it works quite well with 1.1m4, it does not work
>>    with 1.1m5.
>>
>>    The error seems to be in the Guice Provider for the Context class;
>>    it relies on
>>    Context.getCurrent() which is returning null when called from
>>    within the custom
>>    Finder. I have downloaded the source for m4 and m5, and am looking
>>    into writing
>>    a patch for Tim's code to let it work with m5, but I am not
>>    optimistic if I
>>    cannot get the current context from within the Finder.
>>
>>    If I get it to work, I will post the results here and on Tim's
>>    blog, but I was
>>    hoping someone here (Tim suggested Jerome) might be able to give
>>    me some advice
>>    on the matter.
>>
>>    Thanks!
>>
>>    Chris Lee
>>
>>
>>
>

Reply via email to