How can/should I pass an object from a ContainerRequestFilter to a (post-matching) resource in (JAX-RS) Resteasy version 3.0.11 that has undertow embedded and uses Guice?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
The method ContainerRequestContext#setProperty stores values which are synced with the
HttpServletRequest
. So with plain JAX-RS you can store an attribute like this:And afterwards you can obtain it in your resource class:
With CDI you also can inject any bean in the filter and resource class:
In your resource class:
I'd expect the same to be working with Guice.
Update: As @bakil pointed out correctly you should use a
@RequestScoped
bean if the object you want to pass should only be associated with the current request.