Sorry to bump this, but to help me from going down a dead end, is
getting the request not supported for UniformResource in a
JaxRsApplication or am I doing something wrong? Does it work in 2.1?

Regards,
Carl.

On 15 June 2012 09:54, Carl Pritchett <[email protected]> wrote:
> I'm using 2.0.14 - anyone have a thought on this?
> It looks like the init method on s UniformResource never gets called -
> all I can find is a reflection call that instantiates the class and
> invokes the matching resource method (in JaxRsRestlet).
>
> How can I get the init method called with the context, request and
> response? I'm trying to find a nice hook point to do this.
>
> Regards,
> Carl
>
> On 7 June 2012 16:18, Carl Pritchett <[email protected]> wrote:
>> Hi,
>>
>> I've made a JaxRsApplication Restlet application that works. But I'm
>> trying to get the HttpServletRequest in a ServerResource via
>> ServletUtils.getRequest(getRequest()). This fails as getRequest()
>> returns null, as does getContext(), getInfo(), getResponse() etc.
>>
>> One of the only UniformResource call that doesn't return null is
>> getApplication().
>>
>> My JaxRsApplication is as follows:
>>
>> public class MyJaxRsApplication extends JaxRsApplication
>> {
>>    public MyJaxRsApplication(Context context)
>>    {
>>        super(context);
>>        add(new MyRestletApplication());
>>    }
>>
>>    public class MyRestletApplication extends Application
>>    {
>>        public Set<Class<?>> getClasses()
>>        {
>>            Set<Class<?>> rrcs = new HashSet<Class<?>>();
>>            rrcs.add(AResource.class);
>>            return rrcs;
>>        }
>>    }
>> }
>>
>> and the AResource is:
>>
>> @Path("/")
>> public class AResource extends ServerResource
>> {
>>
>>    @GET
>>    @Produces("text/html")
>>    public String getResult()
>>    {
>>        // The next line returns null....
>>        org.restlet.Request restletReq = getRequest();
>>        HttpServletRequest req = ServletUtils.getRequest(restletReq);
>>        return req.getServerName();
>>    }
>> }
>>
>> I'm I missing something? The UniformResource does not appear to get
>> the request set when it is initialised.
>>
>> Regards,
>> Carl

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

Reply via email to