-
May 11th, 2010, 10:55 AM
#1
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
-
May 11th, 2010, 01:30 PM
#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.
-
May 12th, 2010, 04:27 AM
#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
-
May 12th, 2010, 04:41 AM
#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).
-
May 12th, 2010, 08:08 AM
#5
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
-
Forum Rules