tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: Custom Security for REST
Date Thu, 24 Jan 2013 10:01:17 GMT
Hi

rest uses @Context, not @inject

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/1/24 dorwin <dorwins@gmail.com>

> Hello,
>
> I just downloaded and tried the 1.5.2 snapshot, and it behaved the same
> way.
> HttpServletRequest is always null in the interceptor. Is there somewhere I
> can find documented what should be available? I first tried to just do
> @Inject HttpServletRequest, but the server complained at startup. Are there
> any pieces of the REST message I can inject here?
>
> The interceptor looks like the following:
>
> package test.tomee.interceptor;
>
> import java.util.Arrays;
>
> import javax.enterprise.context.RequestScoped;
> import javax.interceptor.AroundInvoke;
> import javax.interceptor.Interceptor;
> import javax.interceptor.InvocationContext;
> import javax.servlet.http.HttpServletRequest;
> import javax.ws.rs.core.Context;
>
> @InterceptMe @Interceptor
> @RequestScoped
> public class TestInterceptor {
>
>
>         @Context        HttpServletRequest request;
>
>         @AroundInvoke
>         public Object logStuff(InvocationContext ctx) throws Exception {
>                 System.out.println("In interceptor");
>                 System.out.println("calling method: " + ctx.getMethod());
>                 System.out.println("arguments are: " +
> Arrays.toString(ctx.getParameters()));
>                 System.out.println("request headers are: " + ( request
> !=null ?
> request.getHeaderNames().toString(): "null"));
>                 Object returnValue = ctx.proceed();
>                 System.out.println("called method: " + ctx.getMethod());
>                 return returnValue;
>         }
> }
>
> Thank you
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Custom-Security-for-REST-tp4660361p4660365.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message