ef-labs / vertx-jersey

Run jersey in vert.x
MIT License
150 stars 47 forks source link

ServletContext should be injected #37

Open testn opened 9 years ago

testn commented 9 years ago

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.

adrianluisgonzalez commented 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

adrianluisgonzalez commented 8 years ago

@testn any further discussion on this topic?

testn commented 8 years ago

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.