JCA 1.6 ResourceAdapter 是否需要 ManagedConnectionFactory?
我之前写过一个JCA 资源适配器。
然而,现在我发现自己必须编写一个程序来访问 BootstrapContext
及其关联的 WorkManager
,而且没有其他原因。
如果我正确地阅读了规范——这就是我的问题——看起来如果我希望有人能够以符合规范的方式使用我的资源适配器,我仍然需要实现ManagedConnectionFactory
,因为看起来只有 ManagedConnectionFactory
实现提供的用户连接工厂才有资格通过 @Resource
注释进行注入。
来吧,再读一遍;我会等待。 :-)
在完美的世界中,我想编写我的 ResourceAdapter
实现,用 @Connector
注释它,指定所有 @ConfigProperty
位,将其打包到 .rar
文件中,然后就可以完成了。
然而,在我看来,该规范有效地要求消费者(在我的例子中是无状态 EJB)和资源适配器模块之间的所有通信都应该通过用户连接工厂来完成。
例如,第 6.10.1 节说:
资源适配器必须提供以下接口的实现:
- javax.resource.spi.ManagedConnectionFactory
- javax.resource.spi.ManagedConnection
- javax.resource.spi.ManagedConnectionMetaData
但是第 18 节(有关注释的部分)似乎没有提供以任何有意义的方式强制执行这一点。
情况确实如此吗?我想一定是这样,但我很想听听那些组装了 1.6 资源适配器的人的意见。
I have written a JCA resource adapter before.
However, now I find myself in a position of having to write one solely to get access to the BootstrapContext
and its associated WorkManager
, and effectively for no other reason.
If I'm reading the specification correctly--and that's my question--it looks like if I want someone to be able to use my resource adapter in a spec-compliant fashion, I still need to implement ManagedConnectionFactory
, because it would appear that only user connection factories vended by ManagedConnectionFactory
implementations are eligible for injection via the @Resource
annotation.
Go ahead, read it again; I'll wait. :-)
In a perfect world, I'd like to write my ResourceAdapter
implementation, annotate it with @Connector
, specify all the @ConfigProperty
bits, pack it up in a .rar
file, and be done with it.
However, it looks to me like the specification effectively mandates that all communication between the consumer (a stateless EJB in my case) and the resource adapter module is supposed to be accomplished through a user connection factory.
For example, section 6.10.1 says:
A resource adapter must provide implementations of the following interfaces:
- javax.resource.spi.ManagedConnectionFactory
- javax.resource.spi.ManagedConnection
- javax.resource.spi.ManagedConnectionMetaData
But section 18--the section on annotations--doesn't seem to provide for enforcing this in any meaningful way.
Is this indeed the case? I suppose it must be, but I'd be curious to hear from people who have put together a 1.6 resource adapter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“本节概述了连接管理合同的要求。”
是的。这很好。
如果您不需要出站通信功能,则不必定义它们(连接工厂、托管连接工厂等)
是的。
我不认为可以使用 @Resource 注释注入“ResourceAdapter”Java Bean。每当部署/启用资源适配器/启动服务器时,
GlassFish 都会引导资源适配器。
"This section outlines requirements for the connection management contract."
Yes. this is fine.
If you do not need outbound communication capabilities, you do not have to define them (connection-factory, managed-connection-factory etc.,)
Yes.
I do not think "ResourceAdapter" Java Bean can be injected using @Resource annotation. Whenever the resource-adapter is deployed / enabled / server is started,
GlassFish will bootstrap the resource-adapter.