The Difference between <resource-ref> and <resource-env-ref>,the title should be long...
来源:互联网 发布:seo搜索引擎优化公司 编辑:程序博客网 时间:2024/05/20 15:12
Howdy
Good question (and one you should know for the exam)
resource-ref is for "resource manager connection factory" objects that can give you connections to a resource manager. The typical example is for javax.sql.DataSource from which you can get JDBC connections (javax.sql.Connection).
The resource-ref is so that you can have a 'logical name' used in code -- that the deployer then binds to the *actual* resource factory configured into the server. So when you think of resource-ref, think of "Programmer's made-up/fake name for the datasource." Since the programmer may not know, at the time of coding, what the *real* name is going to be (and since the component model demands that the name of these things is something that can be configured at deploy-time without changing 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 you.
For example, a resource manager connection factory is certainly an entry in the bean's environment -- so it would be perfectly logical to assume that resource-env-ref is an appropriate name for what is actually resource-ref.
But...you have to memorize it differently.
A resource-env-ref is for "administered objects associated with resources", and the most obvious example (and the reason it was added) was for JMS destinations. The idea is the same as resource-ref (or security-role-ref) in that it stands for "programmer's made-up/fake name", only instead of a name for a resource factory, it is a name for a 'resource'.
The main difference:
resource-ref:
things that give you CONNECTIONS (including URL connection - JavaMail connection factory, JDBC connection --DataSource, and -- for the really confusing one -- QueueConnectionFactory for obtaining JMS connections.)
resource-env-ref:
things that give you access to a resource, but which are NOT factories that give you connections. In other words, with resource-ref you are getting something that you then can use to GET to a resource, but with resource-env-ref, you get right to the resource without going through a factory.
The way I think of 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 may be other examples, I have no idea what they might be.
=======================
So, yes its confusing, but hopefully you can simply "burn-in" the differences between the two. I think the most important thing to remember is that wherever you see 'ref' you can think of "Programmer's made-up / lookup name"
cheers,
Kath
Good question (and one you should know for the exam)
resource-ref is for "resource manager connection factory" objects that can give you connections to a resource manager. The typical example is for javax.sql.DataSource from which you can get JDBC connections (javax.sql.Connection).
The resource-ref is so that you can have a 'logical name' used in code -- that the deployer then binds to the *actual* resource factory configured into the server. So when you think of resource-ref, think of "Programmer's made-up/fake name for the datasource." Since the programmer may not know, at the time of coding, what the *real* name is going to be (and since the component model demands that the name of these things is something that can be configured at deploy-time without changing 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 you.
For example, a resource manager connection factory is certainly an entry in the bean's environment -- so it would be perfectly logical to assume that resource-env-ref is an appropriate name for what is actually resource-ref.
But...you have to memorize it differently.
A resource-env-ref is for "administered objects associated with resources", and the most obvious example (and the reason it was added) was for JMS destinations. The idea is the same as resource-ref (or security-role-ref) in that it stands for "programmer's made-up/fake name", only instead of a name for a resource factory, it is a name for a 'resource'.
The main difference:
resource-ref:
things that give you CONNECTIONS (including URL connection - JavaMail connection factory, JDBC connection --DataSource, and -- for the really confusing one -- QueueConnectionFactory for obtaining JMS connections.)
resource-env-ref:
things that give you access to a resource, but which are NOT factories that give you connections. In other words, with resource-ref you are getting something that you then can use to GET to a resource, but with resource-env-ref, you get right to the resource without going through a factory.
The way I think of 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 may be other examples, I have no idea what they might be.
=======================
So, yes its confusing, but hopefully you can simply "burn-in" the differences between the two. I think the most important thing to remember is that wherever you see 'ref' you can think of "Programmer's made-up / lookup name"
cheers,
Kath
- The Difference between <resource-ref> and <resource-env-ref>,the title should be long...
- Difference between resource-ref & resource-env-ref
- resource-ref和resource-env-ref
- Underlining the differences between Resource Leveling and Resource Smoothing?
- mapped-name/lookup/jndi-name and any ResourceProvider could’t process resource-env-ref named
- The difference between (()) and ().
- web.xml之资源管理对象配置 resource-env-ref
- web.xml之资源管理对象配置 resource-env-ref
- JS advice: Be careful the difference between Undefined and ‘ ’
- the difference between "./" and "sh"
- the difference between the SOURCELIBS and TARGETLIBS
- web.xml 之 resource-ref
- The difference between Const and ReadOnly
- The difference between Failure and Success
- The difference between Process and Procedure
- The difference between GetDC and GetWindowDC
- The difference between Chinese and American
- The difference between J2ee and Ruby
- oracle中字符串比较
- C++ Virtual详解
- 基于MTD的NAND驱动开发
- SQL语句中一个查询结果集作为另一个查询的范围
- SAX解析xml文件实例
- The Difference between <resource-ref> and <resource-env-ref>,the title should be long...
- Linux 常用命令使用方法大搜刮
- ComboBox用法
- oracle 隐式游标,显示游标,游标循环,动态SELECT语句和动态游标,异常处理,自定义异常,
- Oracle中两个日期处理函数总结
- AJAX请求原理
- word不能复制粘贴,提示激活宏
- 字符串不同存储形式代表的不同数据类型 及 返回值为引用要十分注意
- Android学习笔记之AndroidManifest.xml文件解析