I should've mentioned that JAX-RS 1.1 allows for the injection of configuration into Application implementations but I'm presuming it is contexts like ServletConfig which can be injected so you'd have to manually create the (Spring) ApplicationContext (by getting the right parameter from ServletConfig and proceeding from there)... I'll also work on updating CxfNonSpringJaxrsServlet so that users can extend it and override methods like configureResourceInstance or configureProvider etc
thanks, Sergey Sergey Beryozkin-2 wrote: > > Hi, > > AFAIK the idea behind introducing JAX-RS Application is to let users write > portable 'deployment descriptors' in the form of > Application implementations. Application instances can tell the runtime > about the root resources and providers and clarify which > lifecycle policy they depend upon. > > Thus we don't really support combining Application and Spring. But if we > did then it would likely make the given Application > instance unportable.... Is there any reason why you can not use Spring > jaxrs:server definitions ? And then the injection of the > additional config would not be an issue. > > cheers, Sergey > > > I'm trying to understand where/how to inject configuration information... > I'm developing a base-bones application using JSR-311 > style annotations, with a simple javax.ws.rs.core.Application instance at > its core. My web.xml has just the minimal: > > <servlet> > <servlet-name>Sandbox</servlet-name> > <servlet-class> > org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet > </servlet-class> > <init-param> > <param-name>config-location</param-name> > <param-value>/WEB-INF/beans.xml</param-value> > </init-param> > <init-param> > <param-name>javax.ws.rs.Application</param-name> > <param-value>play.Sandbox</param-value> > </init-param> > <load-on-startup>1</load-on-startup> > </servlet> > <servlet-mapping> > <servlet-name>Sandbox</servlet-name> > <url-pattern>/api/*</url-pattern> > </servlet-mapping> > > in it. > > I'm using a database, and so I'd like to put the schema username/password > (and so on) into a config file. I'd then like to make use > of it, to initialize my persistence layer. However, it isn't clear to me > where/how that might work. > > For example, there's no static, run-once spot available to me, that I can > tell -- because, in particular, the Application instance > doesn't provide one (it merely exposes a getClasses() that sets up the > list of resources to use). > > This page: > > http://cxf.apache.org/docs/jax-rs.html > > has a lot of information, but not in a form that I've been able to piece > together. > > What I think I need is: > > 1. Spring configuration file (beans.xml, presumably). > 2. An annotated "Config" class into which config-file information is > injected. > 3. Some other class, into which the Config bean is injected...? > 4. Additional magic. > > (where #3 and #4 are the missing links), whereby I can make use of the > configuration information in a persistence-layer set-up > method... > > Can someone provide a link to sample code that's written in a > beginner-friendly way (tutorial-style, maybe), or other (similar) doc? > > Thanks! > > > -- View this message in context: http://old.nabble.com/injecting-configuration-info-%28JAX-RS%29-tp26372397p26379001.html Sent from the cxf-user mailing list archive at Nabble.com.
