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

  • configuration question

    I'm converting a standalone command-line app to use Spring. It's basically a report generating thing; it reads some stuff from a database and then formats it and then ftp uploads that to an IBM mainframe to generate billing.

    For the program's configuration I'm using the Jakarta Commons Configuration package and have several xml configuration files; email addresses to email results to, ftp logins and passwords, etc.

    What I don't understand is should I move everything from Commons Configuration to my Spring config files? It seems more natural to only use the Spring configuration files for wiring together the classes.

  • #2
    Hi,

    I think it really depends on what are you configuring. If you're using only flat data, like could be put in a properties file, them Spring configuration can be nice, but if you're working on structured data, them maybe you should keep your xml.

    Comment


    • #3
      Let me try to explain this a little more. I'm not averse to using Spring to configure everything. But if I have, for example, a class for sending the email results of some process, call it EmailSender, it needs a recipient's email address, sender's name, the email server's host name, and perhaps the subject for the message.

      I would think that you wouldn't want to put these configuration elements in the bean definition for EmailSender. They are more site-specific things that could change if the program is used elsewhere. You wouldn't want people to have to change the application context xml file just to change the host name for the email server. I'd think that you'd want all of the site-specific stuff off in separate files.

      Also, some of this config stuff is a list, so using resource files won't work since they're single valued.

      If you do put site-specific configuration stuff in a separate config file, how do you do it? PropertyPathFactoryBean? FieldRetrievingFactoryBean? Or is there something better?

      Comment


      • #4
        If you expect this configuration to be cahnged very often (ok, any configuration should change -or be prepared to do so - but things like bean definitions are not supposed to change much), use the properties approach.

        I suggest you to keep your properties independent of Spring. Let Spring's IoC give your object the name (and maybe the path) of the file, but load it as you'd do in any other applications, through Classloader or well known path.

        Comment


        • #5
          Originally posted by pcalcado
          ... of the file, but load it as you'd do in any other applications, through Classloader or well known path.
          What format are you proposing that the file be in?

          Comment


          • #6
            Common map-like properties files.

            If you don't have heavy-structured data, that's all you need in most cases.

            Comment


            • #7
              That's my problem; in my app I'm trying to convert to Spring I've switched to Jakarta Commons Configuration because I have configuration items that are lists. The regular properties files don't support lists, Commons Configuration does.

              Comment


              • #8
                So I think you should keep this as is is now.

                I can't see any good in configuring this in your bean definitions.

                Comment

                Working...
                X