Results 1 to 4 of 4

Thread: Dealing with XML config maintenance

  1. #1
    Join Date
    Sep 2004
    Location
    Berthoud, CO
    Posts
    13

    Default Dealing with XML config maintenance

    Are there any recommendations for validating your various Spring XMLs for code changes such as renaming a class or removing a setter from a class? The concern is mostly related to the production XML, but for example WRT a name change, that name may be in multiple Spring files. I can evaluate the test XML easy enough by running the test suite and fixing any failures/errors, but it would be nice not to have to hit RuntimeExceptions to debug the production XML.
    .rob.park.

  2. #2
    Join Date
    Aug 2004
    Location
    u.s.a
    Posts
    399

    Default

    Not runtime, of course, but the Spring IDE eclipse plug-in does validation.

  3. #3
    Join Date
    Aug 2004
    Posts
    107

    Default

    I too was annoyed that I had to wait until the runtime to fix bad bean defs (with jboss, the exception trace is so long and I found it difficult to get the original exception).

    So I wrote a simple ant target to validate my spring files:

    <target name="validate-spring">
    <java fork="true" failonerror="true" classname="SpringFilesValidation">
    <arg value="applicationContext-XXX.xml"/>
    <arg value="applicationContext-Jmx.xml"/>
    ...
    <arg value="test/applicationContext-for-validation.xml"/>
    <classpath>
    <pathelement path="${classes.dir}"/>
    <path refid="path.classpath"/>
    </classpath>
    </java>
    </target>

    public class SpringFilesValidation {

    public static void main(String[] files) {
    try {
    System.out.println(" Validating springs files...");
    // Disable the logging (was too verbose and not necessary)
    System.setProperty("org.apache.commons.logging.Log ", "org.apache.commons.logging.impl.NoOpLog");
    new ClassPathXmlApplicationContext(files);
    System.out.println(" *** Spring files are OK *** ");
    System.out.println();
    } catch (BeansException e) {
    //e.printStackTrace(System.out);
    //System.err.println();
    System.err.println("############## ERROR IN APPLICATION CONTEXT ############");
    System.err.println();
    ///printBeansException(e);
    System.exit(-1);
    }
    System.exit(0);
    }
    }

    It will at least validate the basic definitions and associations. But I had to override certain beans (via applicationContext-for-validation.xml) since some of them require a running app server for validation (such as Jms and JNDI lookup).

    Dino

  4. #4
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    The org.springframework.test package is handy for integration tests that are still outside the server. So no phone book stack traces.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. Overrides another bean within config...
    By kajh in forum SpringSource Tool Suite
    Replies: 2
    Last Post: Sep 16th, 2005, 12:38 PM
  2. Cannot reference my spring config files from another project
    By lorelia in forum SpringSource Tool Suite
    Replies: 4
    Last Post: Aug 30th, 2005, 01:52 AM
  3. Unexpected behaviour with multiple config files
    By rgitzel in forum Container
    Replies: 7
    Last Post: Mar 8th, 2005, 07:11 PM
  4. Config files with imports
    By p_d_austin in forum Container
    Replies: 3
    Last Post: Oct 25th, 2004, 11:33 AM
  5. Replies: 12
    Last Post: Sep 25th, 2004, 04:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •