Difference between Resource-ref & Resource-env-ref

Source: Internet
Author: User

Foreign forums for the difference between Resource-ref and Resource-env-ref, said more clearly, the following is no translation of the discussion.

It was one of those people who had an opinion.

Resource-ref is for "Resource Manager Connection Factory" Objects This can give you connections to a resource manager. The typical example is for javax.sql.DataSource from which to you can get JDBC connections (javax.sql.Connection).
The resource-ref is so and can have a ' logical name ' used in code--this deployer then binds to the *actual* res Ource factory configured into the server. So if you are resource-ref, the programmer ' Made-up/fake name for the datasource. Since The programmer may isn't know, at the "Time of" coding, what the *real* name is going to (and Since the component mod El demands that's name of these things are something that can are configured at Deploy-time without code.)
So ... what ' s the deal with Resource-env-ref?
1 It is new to EJB 2.0
2) It was added because of Message-driven BEANS/JMS
3) It has the worst name, designed, I ' m certain, just to confuse for you.
For example, a Resource Manager connection factory are certainly a entry in the bean ' s environment--so it would to be Perfe ctly logical to assume this resource-env-ref is a appropriate name for what is actually.
But...you have to memorize it differently.

A Resource-env-ref is to "administered objects associated with resources", and the most obvious (and example I T was added) is for JMS destinations. The idea are the same as resource-ref (or security-role-ref) in this it stands for "Programmer's Made-up/fake name", only I Nstead of a name for a resource factory, it's a name for a ' resource '.
The main difference:
Resource-ref:
Things that give to you connections (including URL Connection-javamail connection factory, JDBC connection--DataSource, a ND--For the really confusing one--queueconnectionfactory for obtaining JMS connections.)
Resource-env-ref:
Things that give for you in access to a resource, but which are don't factories you give. In the other words, with the resource-ref you are getting something and you then can-to-a resource, but with resource- Env-ref, you are right to the resource without going through a factory.
The way I it, for the purposes of the exam is:
Resource-ref: "Programmer ' s made-up name for the database driver"
[Just a way to remember, not the exact technically correct way to say it]
Resource-env-ref: "Programmer ' s made-up name for the JMS destination"
From what I ' ve heard, the resource-env-ref really should have just been called jms-resource-ref, but that would have been More limiting. Much clearer, though.
The only resource example used in the "spec is" for JMS destination, and although I ' m sure there I ' am other examples, I ha ve no idea what they might to be.
=======================
So, yes it confusing, but hopefully you can simply "burn-in" the differences between the two. I am The most important thing to remember are that wherever you can be ' ref ' for ' Programmer ' Made-up/looku P Name "

Here's another man's opinion.

I The way it works is this resource-env-ref points to the "exist within the domain of the appli cation server. This is, the AppServer knows the details of the resource because it manages it.

But The resource-ref points to the exist OUTSIDE the domain of the application server. That's, the appserver does not know how to handle that resource. It is managed by somebody else. For example, a data base. The app server can only give the beans a pointer to the guy who manages the resource, which is usually a connection factory (But it could be something else also). Since It is managed by somebody else, it is possible this that this somebody else may require some authorization. Hence the Res-auth tag.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.