Results 1 to 4 of 4

Thread: dependency injection and beans

  1. #1
    Join Date
    May 2010
    Posts
    318

    Default dependency injection and beans

    Hello,

    Ive got a newbie question.
    If you develope a bigger project by using spring - do you then every object create by using beans?!
    I mean, do you avoid to write in a class "Object o = new Object()", no matter in what context?

    Im a little bit confused, because when I initialize every object using beans my applicationContext.xml is getting bigger and bigger and bigger.....

    thanks!

  2. #2
    Join Date
    Jun 2009
    Posts
    190

    Default

    hi,

    1) If you want to use other features like AOP on these beans then offcourse these beans have to be Spring managed.

    2) You can always modularise or seperate your application-context.xml and configure it according to load all these files.

    Hope this helps.

    -Hetal

  3. #3
    Join Date
    Nov 2007
    Posts
    420

    Default

    Quote Originally Posted by jeeper View Post
    Hello,

    Ive got a newbie question.
    If you develope a bigger project by using spring - do you then every object create by using beans?!
    I mean, do you avoid to write in a class "Object o = new Object()", no matter in what context?

    Im a little bit confused, because when I initialize every object using beans my applicationContext.xml is getting bigger and bigger and bigger.....

    thanks!
    You are asking about dependency injection, right? So does your class have dependencies that you want to inject? If so, define it as a Spring bean. If it does not, then don't...

  4. #4
    Join Date
    May 2010
    Posts
    318

    Default

    thanks for your answers!

Posting Permissions

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