About Question enthuware.jwpv6.2.670 :

Moderator: admin

Post Reply
alex
Posts: 42
Joined: Tue Feb 12, 2013 4:35 pm
Contact:

About Question enthuware.jwpv6.2.670 :

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

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.670 :

Post 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.
If you like our products and services, please help us by posting your review here.

webdeveloper
Posts: 8
Joined: Tue Jan 19, 2016 9:05 pm
Contact:

Re: About Question enthuware.jwpv6.2.670 :

Post 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)

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.670 :

Post by admin »

How can you inject or do anything with an object before it is created?
-Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests