Results 1 to 3 of 3

Thread: ClassPathResource vs FileSystemResource for configurations

  1. #1
    Join Date
    Nov 2004
    Posts
    2

    Default ClassPathResource vs FileSystemResource for configurations

    Our development effort is using Spring and Eclipse and would like to use Spring-IDE to verify the Spring configuration files that we build. We prefer to load Spring configuration files from the Java classpath, instead of from an absolute location. This makes it very easy to define a set of beans in one Eclipse project and use them from other projects. It also makes it easy to define testing-specific configurations in the unit test directory (src/unit) that modify the standard definitions (in src/java). We access our configuration files like this:

    Code:
    ClassPathResource resource = new ClassPathResource("application-config.xml");
    XmlBeanFactory factory = new XmlBeanFactory(resource);
    Unfortunately, Spring-IDE 1.2 only supports relative file paths to locate imported configuration files, so when I load up our configuration files (spread across many source directories and projects), most of them are "broken" even though they work fine.

    How difficult would it be to support ClassPathResources in addition to FileResources?

  2. #2
    Join Date
    Aug 2004
    Location
    Frankfurt/Main, Germany
    Posts
    253

    Default Re: ClassPathResource vs FileSystemResource for configuratio

    Quote Originally Posted by ct7
    How difficult would it be to support ClassPathResources in addition to FileResources?
    I see your point. But Spring IDE isn't able to support classpath resources because it can't instantiate a full-blown Spring bean factory (IMHO it makes no sense for validation to fire up the whole config with JNDI lookups and stuff likes this). Spring IDE simply parses the config files and creates it's own internal bean model from it. This is because Spring IDE lives within it's own small world (Eclipse classloader).

    Currently you have no other choice than using config sets with externally defined Spring config files (see http://forum.springframework.org/showthread.php?t=14506). But we have an issue with Eclipse 3 handling absolute references to workspace resources (http://springide.org/project/ticket/80). So you have to wait for Spring IDE 1.2.1 :-(.

    Cheers,
    Torsten
    Last edited by robyn; May 16th, 2006 at 04:33 AM.

  3. #3
    Join Date
    Nov 2004
    Posts
    2

    Default Re: ClassPathResource vs FileSystemResource for configuratio

    Quote Originally Posted by Torsten Juergeleit
    I see your point. But Spring IDE isn't able to support classpath resources because it can't instantiate a full-blown Spring bean factory (IMHO it makes no sense for validation to fire up the whole config with JNDI lookups and stuff likes this). Spring IDE simply parses the config files and creates it's own internal bean model from it. This is because Spring IDE lives within it's own small world (Eclipse classloader).

    So you have to wait for Spring IDE 1.2.1 :-(.
    I don't think that supporting ClassPathResources should be fundamentally more difficult than FileSystemResources. Since you're parsing the files yourself, it should just be a matter of using a different lookup mechanism, one that knows to hunt through the available resources on the project's build path, instead of by using a filesystem relative pathname.

    Admittedly, I am not an expert at writing Eclipse plugins, but I've written code to do the same thing just by parsing the .classpath files directly. I seem to recall in my researches that there's an API to make it easy for you.

    In the meantime ... what's the current projected availability of Spring IDE 1.2.1?

Similar Threads

  1. ClasspathResource
    By bendg25 in forum Container
    Replies: 1
    Last Post: Mar 10th, 2005, 09:42 AM

Posting Permissions

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