Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] getting HttpServletRequest and HttpServletResponse from within an advice

Hi.

2015-12-11 13:13 GMT+01:00 Floyd Shackelford <F.Shackelford@xxxxxxxxxxx>
@Path("/foo")
@Produces(MediaType.TEXT_PLAIN)
public class Foo {

@GET
@Path("/bar")
  public String bar() {
    return "hello world"
  }
}

How do I get HttpServletRequest, HttpServletResponse, etc. from within my advice without changing bar's signature?

I think that by using an ITD, you can introduce fields of those types annotated with @Context in Foo, which would then get injected by JAX-RS (as long as everything in your "etc." is part of the context). It's been a while since I last used ITDs, so I'm not sure if the fields are actually added to Foo directly; if they aren't, it won't work, of course.

Regards,
Frank

Back to the top