Results 1 to 8 of 8

Thread: configuration question

  1. #1
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default 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. #2
    Join Date
    Jun 2005
    Location
    Rio de Janeiro - Brazil
    Posts
    8

    Default

    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.
    Phillip Calçado \"Shoes\"
    http://www.fragmental.com.br
    \"There is no spoon\" -- Matrix
    \"There is no fork()\" -- AmigaOS
    ________________________________________
    If you\'re not confused, you\'re not paying attention.

  3. #3
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    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?

  4. #4
    Join Date
    Jun 2005
    Location
    Rio de Janeiro - Brazil
    Posts
    8

    Default

    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.
    Phillip Calçado \"Shoes\"
    http://www.fragmental.com.br
    \"There is no spoon\" -- Matrix
    \"There is no fork()\" -- AmigaOS
    ________________________________________
    If you\'re not confused, you\'re not paying attention.

  5. #5
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    Quote 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?

  6. #6
    Join Date
    Jun 2005
    Location
    Rio de Janeiro - Brazil
    Posts
    8

    Default

    Common map-like properties files.

    If you don't have heavy-structured data, that's all you need in most cases.
    Phillip Calçado \"Shoes\"
    http://www.fragmental.com.br
    \"There is no spoon\" -- Matrix
    \"There is no fork()\" -- AmigaOS
    ________________________________________
    If you\'re not confused, you\'re not paying attention.

  7. #7
    Join Date
    May 2005
    Location
    California, US
    Posts
    735

    Default

    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.

  8. #8
    Join Date
    Jun 2005
    Location
    Rio de Janeiro - Brazil
    Posts
    8

    Default

    So I think you should keep this as is is now.

    I can't see any good in configuring this in your bean definitions.
    Phillip Calçado \"Shoes\"
    http://www.fragmental.com.br
    \"There is no spoon\" -- Matrix
    \"There is no fork()\" -- AmigaOS
    ________________________________________
    If you\'re not confused, you\'re not paying attention.

Similar Threads

  1. Replies: 4
    Last Post: Aug 8th, 2005, 05:20 PM
  2. Configuration / Deployment question
    By hay7777 in forum Container
    Replies: 9
    Last Post: Jun 21st, 2005, 04:32 AM
  3. logging configuration question
    By pdemilly in forum Container
    Replies: 3
    Last Post: Jan 22nd, 2005, 06:48 AM
  4. Replies: 4
    Last Post: Oct 12th, 2004, 06:21 AM
  5. Replies: 5
    Last Post: Aug 27th, 2004, 07:13 PM

Posting Permissions

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