Hi Jeffrey,

I can understand that using JNDI is quite attractive for administration.

About changing the applicationContext. You could do this in maven by using resource filtering. For the src/main/resources directory this is already turned on. So you can write ${propertyname} in the context. Each property known by maven will then be replaced. For example I defined properties for the library versions. You could of course do the same for queue names. If you call maven with "mvn -DmyProp=test install" then the property myProp is also available. Or you simply embed a small ant script in mven using hte antrun plugin.

Having said that it is no good practice to change an applicationContext during the build. Better use spring PropertyPlaceHolderConfigurer for this task at runtime. See: http://almaer.com/blog/spring-propertyplaceholderconfigurer-a-nice-clean-way-to-share

You can store a property file for tests into src/test/resources. This is then available in Eclipse and maven when you run unit tests.

For production you best put a properties file outside the war that is somewhere on the classpath. Our admins often had a directory config that they added to the classpath of the container that contained the property files. The nice thing with this solution is that like in JNDI the admin can change the properties after you built the war.

The solution with using properties in the app context also scales nicely to osgi. Spring propvides an element <osgix:cm-properties id="cm" persistent-id="com.xyz.myapp"/> that also replaces properties but uses the osgi config admin service as source.

Btw. there is another nice thing you might want to try. I have attached a small class JettyStarter. You can put this in src/test/java and add the below dependencies to the pom. Then you can start this class from eclipse to start an embedded jetty with your project. This even works without building the jar first and allows an extremly fast roundtrip from changing code to debugging.

Christian
-----
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>7.2.2.v20101205</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>7.2.2.v20101205</version>
<scope>test</scope>
</dependency>
-----
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

/**
 * <
 * Starts a jetty server for the project.
 * This is mainly to run and debug the tests in you ide.
 * For production you would either build a war file or deploy
 * the project to an osgi runtime like karaf.
 * </p>
 */
public class JettyStarter {

    public static void main(String[] args) throws Exception {
System.setProperty("org.apache.cxf.Logger", "org.apache.cxf.common.logging.Log4jLogger");
        new JettyStarter().run();
    }

    private void run() throws Exception {
        Server server = new org.eclipse.jetty.server.Server(8080);

        WebAppContext webappcontext = new WebAppContext();
        webappcontext.setContextPath("/");
        webappcontext.setWar("src/main/webapp");
        webappcontext.setClassLoader(this.getClass().getClassLoader());
        server.setHandler( webappcontext);

        server.start();
    }

}
-----

Am 11.02.2011 01:44, schrieb Jeffrey Knight:
So my question is why don“t you simply use an ActiveMQConnectionFactory in 
spring and skip all the JNDI stuff. I have done some deployments in an 
enterprise environment
and we most times did not use jndi
Very strict client corporate/enterprise requirements that resources be managed 
in WAS. (We're using IBM MQ via JNDI not activeMQ but for sample purposes 
probably helpful to Camel users to show both.) There's in fact a separate team 
dedicated to creating the JNDI resources in WAS who manage scalability etc and 
simply dole out the JNDI info for clients to connect. If they felt like 
swapping out IBM MQ for ActiveMQ our app in fact would never know! Also, 
authentication credentials are managed at this level.
It is quite complicated.

Thanks for the CFX feedback I can remove that.

Note that the ant build.xml updates applicationContext.xml before war'ing it. 
Not sure how to do that in maven ...

--
----
http://www.liquid-reality.de

Reply via email to