Announcement Announcement Module
Collapse
No announcement yet.
Application Context Best Uses Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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

      Comment


      • #4
        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).

        Comment


        • #5
          Thanks a lot Marten. I got your point.

          Best Regards,

          ssroy

          Comment

          Working...
          X