Hi David,

I've had no time to look into my own code or work with it, so I forget, 
that the injection was changed.
Use a field (or parameter) of type javax.ws.rs.ext.Providers, annotate 
it with @Context and use method getContextResolver(...) .

I hope, that's the right solution. As said, I've long time no time to 
keep me busy with Restlet and JAX-RS. Sorry for the wrong information first.

best regards
   Stephan

David Fogel schrieb:
> Stephan-
>
> Maybe I should write shorter messages, so as to encourage people to
> actually read them.  :-)
>
> As I said in my previous message, I tried to use field injection as
> well as constructor param injection.  Both attempts failed.
>
> This is the log message I get when I try the annotated field approach
> that you recommend:
>
>     Mar 20, 2009 12:48:14 PM
> org.restlet.ext.jaxrs.internal.wrappers.ResourceClasses addRootClass
>     WARNING: The root resource class com.example.TestResource has an
> illegal annotated and typed field: class com.example.StorageService
> must not be annotated with @Context
>
> Here is the method in your class
> org.restlet.ext.jaxrs.internal.wrappers.params.ContextInjenctor
>
> static Object getInjectObject(Class<?> declaringClass,
>             ThreadLocalizedContext tlContext, Providers providers,
>             ExtensionBackwardMapping extensionBackwardMapping)
>             throws IllegalTypeException, ImplementationException {
>         if (declaringClass.equals(Providers.class)) {
>             return providers;
>         }
>         if (declaringClass.equals(ContextResolver.class)) {
>             // NICE also throw, where the error occurs.
>             throw new IllegalTypeException(
>                     "The ContextResolver is not allowed for @Context
> annotated fields yet. Use
> javax.ws.rs.ext.Providers#getContextResolver(...)");
>         }
>         if (declaringClass.equals(ExtensionBackwardMapping.class)) {
>             return extensionBackwardMapping;
>         }
>         if (declaringClass.equals(PathSegment.class)) {
>             final String msg = "The use of PathSegment annotated with
> @Context is not standard.";
>             logger.config(msg);
>             return new GetLastPathSegment(tlContext);
>         }
>         if (declaringClass.equals(SecurityContext.class)
>                 || declaringClass.equals(HttpHeaders.class)
>                 || declaringClass.equals(Request.class)) {
>             return tlContext;
>         }
>         if (declaringClass.equals(UriInfo.class)) {
>             throw new ImplementationException(
>                     "You must not call the method
> ContextInjector.getInjectObject(.......) with class UriInfo");
>         }
>         // NICE also allow injection of ClientInfo and Conditions. Proxies are
>         // required, because the injected objects must be thread local.
>         throw new IllegalTypeException(declaringClass
>                 + " must not be annotated with @Context");
>     }
>
> It doesn't appear that this code currently supports having custom
> ContextResolver providers (although they appear to be available in the
> "providers" parameter).
>
> I'd very much appreciate it if you could take a closer look at this-
> seems like an important part of any JAX-RS implementation!
>
>   -Dave Fogel
>
> On Fri, Mar 20, 2009 at 4:04 AM, Stephan Koops <stephan.ko...@web.de> wrote:
>   
>> Hi David,
>>
>> use
>>
>>  @Context
>>  private StorageServiceResolver serviceResolver;
>>
>> best regards
>>   Stephan
>>     
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1365883
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1388032

Reply via email to