Get the JAX-RS application a resource is attached on

前端 未结 1 459
梦谈多话
梦谈多话 2021-01-25 06:38

I wonder if it\'s possible to get an instance of the JAX-RS Application a resource is attached on. Ideally a way that isn\'t dependent to a specific implementation.

1条回答
  •  再見小時候
    2021-01-25 07:18

    As stated in The Spec

    5.2.1 Application

    The instance of the application-supplied Application subclass can be injected into a class field or method parameter using the @Context annotation. Access to the Application subclass instance allows configuration information to be centralized in that class. Note that this cannot be injected into the Application subclass itself since this would create a circular dependency.

    but from I've experienced, it will most likely not be the actual instance, but a proxy. Also if you're looking to alter anything on it, I'm not sure it's possible. It might be read-only.

    0 讨论(0)
提交回复
热议问题