Announcement Announcement Module
Collapse
No announcement yet.
ClassPathResource vs FileSystemResource for configurations Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Re: ClassPathResource vs FileSystemResource for configuratio

    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, 05:33 AM.

    Comment


    • #3
      Re: ClassPathResource vs FileSystemResource for configuratio

      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?

      Comment

      Working...
      X