java - JCA 1.6 ResourceAdapter 是否需要 ManagedConnectionFactory?

标签 java jakarta-ee java-ee-6 jca

我写了一个JCA resource adapter before .

但是,现在我发现自己不得不写一个来访问 BootstrapContext 及其相关联的 WorkManager,而且没有其他原因。

如果我正确阅读规范——这是我的问题——看起来如果我希望有人能够以符合规范的方式使用我的资源适配器,我仍然需要实现 ManagedConnectionFactory,因为看起来只有 ManagedConnectionFactory 实现提供的用户连接工厂才有资格通过 @Resource 注释进行注入(inject)。

继续,再读一遍;我会等。 :-)

在一个完美的世界中,我想编写我的 ResourceAdapter 实现,用 @Connector 注释它,指定所有 @ConfigProperty位,将其打包成一个.rar文件,然后就完成了。

但是,在我看来,规范实际上要求消费者(在我的例子中是无状态 EJB)和资源适配器模块之间的所有通信都应该通过用户连接工厂来完成。

例如,第 6.10.1 节说:

A resource adapter must provide implementations of the following interfaces:

  • javax.resource.spi.ManagedConnectionFactory
  • javax.resource.spi.ManagedConnection
  • javax.resource.spi.ManagedConnectionMetaData

但第 18 节——关于注释的部分——似乎并没有以任何有意义的方式强制执行这一点。

真的是这样吗?我想肯定是这样,但我很想听听那些组装了 1.6 资源适配器的人的意见。

最佳答案

“本节概述了连接管理契约(Contract)的要求。”

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

是的。这很好。

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

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

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

是的。

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

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

GlassFish 将引导资源适配器。

关于java - JCA 1.6 ResourceAdapter 是否需要 ManagedConnectionFactory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4199146/

相关文章:

java - 诠释主要(); C - java等价物

java.io.IOException : Unable to open "..." as class path, 文件名或 URL

java - 向要存储在数据库中的字符串键(行键)添加前缀的推荐方法

EJB 3.1 通用 DAO

Java EE 6 @javax.annotation.ManagedBean 与 @javax.inject.Named 与 @javax.faces.ManagedBean

java - 为什么 Java API 要求非静态访问 setDefaultUseCaches?

java - Spring-XD spring应用程序用于大数据

java - 与 map 比较时获取重复值

java - hibernate session 工厂

deployment - Java-EE6 : How to auto-redeploy Glassfish 3 application from inside the server component?