Results 1 to 5 of 5

Thread: Application Context Best Uses

  1. #1

    Default Application Context Best Uses

    Hi,

    We are developing a web based application with presentation, business and data layers.

    Now, we get the ApplicationContext reference (from SevletContext) in presentation layer which we can use to get reference of “beans”.


    Now my queries are:

    1) If I need to get a bean reference in business layer, how to do this.
    2) Is it a good idea to pass reference of ApplicationContext to business layer

    Any suggestion is welcome.


    Thanks in advance.

    Best Regards,

    ssroy

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    THe best best practice is to not directly use the BeanFactory/ApplicationContext. You should simply use dependency injection and avoid dependency lookups. It makes your application also a lot simpler and also not dependend on spring.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Thanks Marten for the response.

    I am really not sure how to inject ApplicationContext. Can you please elaborate a bit more on this.


    Thanks & Rest Regards,

    ssroy

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    As stated you shouldn't inject the ApplicationContext, you shouldnlt be using that directly. No matter if you do injection or not. YOu should simply inject those dependencies needed (daos, services etc).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5

    Default

    Thanks a lot Marten. I got your point.

    Best Regards,

    ssroy

Posting Permissions

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