You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Benson Margulies <bi...@basistech.com> on 2007/07/20 13:10:27 UTC

context-params, spring, CXF

The following isn't exactly a cxf issue. It's more of a generic problem
with servlets that I've run into many times. However, I wonder if people
in CXF-land have had some relevant experience.

Consider a software module that is implemented as a CXF service. Its
job, let us say, is to publish a large raft of data from some
database-like location over a service. The author wishes to distribute
the module in the form of a WAR file, and be able to tell the recipient:
"Just drop the war file into the container, \set some parameters to tell
us where you've configured the database,/ and start it up."

The trouble comes in my typewriter italics. How to tell the recipient to
set some parameters? Note that in my particular case the data source is
not, in fact, an actual JDBC datasource, so the 'j2ee light' resource
pools for JDBC and Java Mail often seen in servlet containers aren't any
help.

I can think of a few options:

1) Tell them to drop the web application unpacked, and tell them to edit
web.xml to set one or more context-param elements. In the spring wiring,
use ServletContextPropertyPlaceholderConfigurer to pull those values
into the beans.

2) Let them leave the WAR file packed, but tell them how to use
container-specific configuration to set these parameters at the
container level. I know how to do this for Tomcat, I have no information
on the difficulty level of Jetty or anything else.

3) Have the application start up without the data, and supply an admin
web UI that can accept these parameters and store them ... where?

4) Get involved in JNDI. This presumably requires a custom spring
property editor (or just passing JNDI refs into the beans and letting
them talk to the JNDI API). That's a painful pile of mechanism to set a
simple parameter.

5) Give them a program that they run to push the configuration into the
WAR file by pushing a property file into the classpath.

 Have any of you gentle readers been down this path?

--benson