Open testn opened 9 years ago
The issue when using vertx-jersey is you are not running inside a web container so there is not a ServletContext
to inject. The vert.x HttpServerRequest
/HttpServerResponse
does not implement ServletRequest
/ServletResponse
.
However there is nothing stopping you from implementing your own ServletContext
and binding it for injection as a singleton to use for getAttribute()
/setAttribute()
.
However, if all you want is getAttribute()
/setAttribute()
, then consider using vert.x's shared data:
http://vertx.io/docs/vertx-core/java/#_using_shared_data_with_vert_x
@testn any further discussion on this topic?
I think it's sometimes important to have at least a fake implementation of ServletContext. A good example is swagger. Swagger uses ServletContext to cache the swagger definition without making the resource to be a singleton.
It looks like currently ServletContext is not injected. It would be nice to have it injected so that it can access ServletContext.getAttribute/setAttribute as a caching mechanism.