If I amend the example so that the endpoint also injects the
HTTPServletRequest, we can see that it works for the endpoint, just not for
the interceptor:

package test.tomee.webservice;

import java.util.Collections;

import javax.enterprise.context.RequestScoped;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;

import test.tomee.interceptor.InterceptMe;

@InterceptMe
@RequestScoped
@Path("/test")
public class TestService {

        @Context
        HttpServletRequest request;
        
        @GET
        @Path("/sayHello")
        @Produces("text/plain")
        public String sayHello()
        {
                System.out.println("endpoint says headers are: " +
Collections.list(request.getHeaderNames()).toString());
                return "hello";
        }
}

the output is:

In interceptor
calling method: public java.lang.String
test.tomee.webservice.TestService.sayHello()
arguments are: []
request headers are: null
endpoint says headers are: [host, user-agent, accept, accept-language,
accept-encoding, deviceid, connection]
called method: public java.lang.String
test.tomee.webservice.TestService.sayHello()





--
View this message in context: 
http://openejb.979440.n4.nabble.com/Custom-Security-for-REST-tp4660361p4660384.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to