Announcement Announcement Module
Collapse
No announcement yet.
Using import for externalizing configuration. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using import for externalizing configuration.

    Spring offers me two ways to externalize my configuration - use the import tag or pass an String array containing configuration file names while creating ApplicationContext.

    I was able to locate some Spring best practices at http://www.onjava.com/pub/a/onjava/2...practices.html. The author (in best practice 6) recommends the latter approach.

    IMHO the import tag may be a good idea if I am able to break down my configuration in some hierarchy (the breakdown of configuration can be functional and there is one root configuration) also I dont have to modify my code if there is a need to add a new configuration. However if there are multiple top-level configurations then the 2nd option makes sense.

    I would want to hear the community's take on this.

  • #2
    Indeed the import makes sense if you have a hierarchy of beans that can be aggregated somehow into particular files. I usually use an array (which should not have more then 10 xml files) to bootstrap spring as each file contains components of my applications - such as web, middle tier, jmx exposure.

    Comment


    • #3
      SingletonBeanFactoryLocator provides another way to locate configuration locations - through a bean id representing the application context (or bean factory). You can create arbitrary hierarchies of bean factories, and have independent subsets.

      You get the same effect from bean factor parent-child relations in a standard MVC web app with the ContextLoaderListener, but it is slightly less flexible and has a fixed hierarchy structure (one parent, one "middle" layer, and child contexts for each dispatcher servlet instance). You have to specify the config locations for the "middle" tier application context

      Comment

      Working...
      X