开发者

Accessing context-param values from within a RESTEasy provider

I have created a MessageBodyReader/MessageBodyWriter that needs to 开发者_JAVA技巧read a configuration value. Ideally I'd like this to be held in the web.xml as a context-param. Is there any way that a RESTEasy provider can access context params? Is there any type that I can inject using @Context that will allow me to get context-param values? I haven't been able to find one.

Alternatively, is there a better way to provide configuration values to a provider? I'd like to avoid having to use a system property.


In answer to my own question, one solution is to use Spring.

When RESTEasy beans are created via the the Spring context, one can easily provide configuration values in the application-context.xml. It's even possible to use context-param values from the web.xml using the ServletContextPropertyPlaceholderConfigurer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜