Results 1 to 5 of 5

Thread: Bean ID management.

  1. #1

    Default Bean ID management.

    I have some problem of bean ID overlap-addition by many developers on one project.
    Is there any solution to avoid this issue?

    Thanks,
    Edward.

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    For larger projects I found it useful to separate contexts into several files and use bean ids with an according prefix to avoid name clashes.
    E.g. in a context file "security" I would have a "security.authenticationManager" bean.

    Hope that helps,
    Andreas

  3. #3

    Default Thanks for your help.

    Andreas, Thanks for your help. It's a helpful suggestion.

    BTW, I have additional question. If overlap-addition occur, Spring returns the bean which is defined at last without any exceptions. Isn't problematic? I had a vague awakening to spring intention, but i really wonder why it doesn't throw an exception as detail as possible.

    Any advice are welcome.

    Thanks,
    Edward.

  4. #4
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    The "last bean definition wins" rule can be utilized to create default wirings which might be overriden (e.g. in testing scenarios) by loading extra context files. So there is really a use-case for that behavior.

    If you really do not want that behavior I think it can be changed. I vaguely remember a forum thread describing how to subclass an ApplicationContext class to achieve this. It wasn't too difficult though I do not remember the details. Maybe searching the forum and/or having a look at API documentation and source code does reveal the details.

    Regards,
    Andreas
    Last edited by Andreas Senft; Apr 16th, 2008 at 02:27 AM. Reason: typo

  5. #5

    Default Thank you for your reply.

    The "last bean definition wins" rule can be utilized to create default wirings which might be overriden (e.g. in testing scenarios) by loading extra context files. So there is really a use-case for that behavior.

    If you really do not want that behavior I think it can be changed. I vaguely remember a forum thread describing how to subclass an ApplicationContext class to achieve this. It wasn't too difficult though I do not remember the details. Maybe searching the forum and/or having a look at API documentation and source code does reveal the details.
    Thank you very much, I understand and will do.

Posting Permissions

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