Results 1 to 3 of 3

Thread: Check some Spring potential errors on buildtime, not only on runtime

  1. #1
    Join Date
    Sep 2005
    Posts
    15

    Default Check some Spring potential errors on buildtime, not only on runtime

    I like Spring but I can't check some errors on buildtime.

    For example :

    I write sommething like

    Datasource datasource = (Datasource) factory.getBean("datasource");

    If datasource doesn't exist in applicationContext.xml or the type of the class is not Datasource, we can't see that on buildtime but only on runtime.

    Is it possible to check on buildtime this kind of errors?

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    Don't use factory.getBean() at all, and use local= in your xml to refer to dependencies. It isn't a complete solution in all situations (e.g. the bean references have to be local - in the same xml file), but it is the only way I know to do dependency checking without starting Spring.

    Also checkout the new ideas on Java configuration in Rod's blog (http://blog.interface21.com/main/200...n-for-spring/). The project is not released into core Spring yet, but it may well be the perfect answer to your question when it is.

  3. #3
    Join Date
    Sep 2005
    Posts
    15

    Default

    When I wrote

    Datasource datasource = (Datasource) factory.getBean("datasource");

    I thought the interaction between your java code and your xml files, not ontly th e dependencies inside your xml files.

    Concerning your article, I read it one or two month ago and I didn't realise this bean configuration allow to check errors on buildtime or to refactor your code. The configuration seems a quite strange at the beginning but so powerfull compared to xml configuration.

    Thanks.

Posting Permissions

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