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!

Reply via email to