Hi,
Could you please explain why "A method annotated with @Resource" is a correct answer?
For instance: If we consider @Resource at another method which doesn't relate to DataSource.
Thanks in advance.
About Question enthuware.jwpv6.2.670 :
Moderator: admin
-
- Posts: 42
- Joined: Tue Feb 12, 2013 4:35 pm
- Contact:
-
- Site Admin
- Posts: 10090
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.jwpv6.2.670 :
Actually, @Resource has no bearing on this. The injected resource can be accessed from any method except the constructor. Whether the method itself is annotated with @Resource is irrelevant.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 8
- Joined: Tue Jan 19, 2016 9:05 pm
- Contact:
Re: About Question enthuware.jwpv6.2.670 :
I am little confused on why the injected resource would not be available in the constructor since we know that the injection occurs before new object of the class is created. So at the time of object creation the injected resource would be readily available (i.e. the resource would be available when the constructor code is executed)
-
- Site Admin
- Posts: 10090
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.jwpv6.2.670 :
How can you inject or do anything with an object before it is created?
-Paul.
-Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 7 guests