Results 1 to 2 of 2

Thread: Initializing bean with (derived) commandline arguments

  1. #1
    Join Date
    May 2005
    Location
    Belgium
    Posts
    1

    Default Initializing bean with (derived) commandline arguments

    Hi,

    I'm new at Spring, and I am currently refactoring a legacy standalone app, introducing Spring. The app uses some commandline arguments, for example the url of the jdbc datasource to use. So my question is: how van I initialize a Spring managed bean with commandline arguments ? Any help is appreciated.

    Thx.

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    AFAIK, Spring doesn't contain any cmd line parser and your code probably already contains such functionality. You can either initialize the bean yourself with the given values (but this doesn't uses Spring IOC) or write a beanPostProcessor that access the command-line attributes and finishes the bean initialization.
    A good example is org.springframework.beans.factory.config.PropertyP laceholderConfigurer
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 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
  •