Does a JCA 1.6 ResourceAdapter need a ManagedConnectionFactory?
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 communicat开发者_如何学运维ion 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.
"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.
精彩评论