Results 1 to 3 of 3

Thread: Two questions about bean design with spring framework

  1. #1
    Join Date
    Jun 2005
    Posts
    8

    Default Two questions about bean design with spring framework

    Hi all,

    I am a newbie to spring framework, I have two questions about spring bean design:

    1. What kind of java object should I put in bean config file or just use "new" to create it?

    2. When should I use dependency injection or just diectly call beanFactory to create it?


    Thanks a lot.

  2. #2
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    1. Typically the objects you configure as beans in the application context provide services to your application: DAOs, Service layer objects, Web Controllers, DataSources, ... It's not that common to have Spring manage your domain layer objects.

    2. Use DI whenever it's possible. It will avoid a dependency on Spring and just makes your code easier to use. Only directly use the application context in a "service locator" kind of way when DI can't work, e.g. when the collaborator is only known at runtime.

    Erwin

  3. #3
    Join Date
    Jun 2005
    Posts
    8

    Default

    One more question, what kind of properties should I put in a spring context file or just put them in a separate key-value pair property file?
    Thanks a lot.

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
  •