Page 1 of 1
About Question enthuware.jwpv6.2.670 :
Posted: Wed Aug 07, 2013 4:12 am
by alex
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.
Re: About Question enthuware.jwpv6.2.670 :
Posted: Fri Aug 09, 2013 7:09 am
by admin
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.
Re: About Question enthuware.jwpv6.2.670 :
Posted: Tue Feb 09, 2016 11:19 pm
by webdeveloper
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)
Re: About Question enthuware.jwpv6.2.670 :
Posted: Wed Feb 10, 2016 9:21 am
by admin
How can you inject or do anything with an object before it is created?
-Paul.