JCA 1.6 ResourceAdapter 是否需要 ManagedConnectionFactory?

发布于 2024-10-03 00:39:08 字数 1008 浏览 7 评论 0原文

我之前写过一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼波传意 2024-10-10 00:39:08

“本节概述了连接管理合同的要求。”

仅使用 JCA 1.6 注释来简单地定义 ResourceAdapter 实现(基本上在模块中没有其他内容)是否合法?

是的。这很好。

规范在第 19.2 节中指出,出站资源适配器(这将是)必须{handwave handwave} 使用连接管理,

交易管理和安全管理合同。在所有这三种情况下,我只是想表明——最好是通过省略注释和/或代码——我不支持其中任何一个

如果您不需要出站通信功能,则不必定义它们(连接工厂、托管连接工厂等)

简单地构建一个实现 ResourceAdapter 的 POJO,用 @Connector 对其进行注释,然后从那里开始就足够了吗?

是的。

我可以使用 @Resource 注释将这样的 POJO 注入到我的 EJB 中吗?

我不认为可以使用 @Resource 注释注入“ResourceAdapter”Java Bean。每当部署/启用资源适配器/启动服务器时,

GlassFish 都会引导资源适配器。

"This section outlines requirements for the connection management contract."

Is it legal, using only JCA 1.6 annotations, to simply define a ResourceAdapter implementation with--basically--nothing else in the module?

Yes. this is fine.

The specification indicates in section 19.2 that an outbound resource adapter (which this would be) must {handwave handwave} make use of the connection management,

transaction management and security management contracts. In all three cases, I just want to indicate--preferably by omitting annotations and/or code--that I don't suppo'r't any of them

If you do not need outbound communication capabilities, you do not have to define them (connection-factory, managed-connection-factory etc.,)

Is it sufficient to simply build a POJO that implements ResourceAdapter, annotate it with @Connector, and go from there?

Yes.

Can I then inject such a POJO into my EJB using the @Resource annotation?

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文