Hi
As per Section 12.1 of the CDI spec, a resource adapter archive can be a
bean archive. This basically means that if a class in the RAR file can be
a CDI managed bean, and if you use that class in a context where
CDI managed beans can be used, it will behave as a CDI managed bean.
This behaviour is just like a class in any library jar file anywhere in
the application as explained in 12.1.
The EE 7 platform clarifies some behaviour with respect to classes that
support DI. Please see sections EE.5.2.5 (especially Table EE.5-1) and
EE.5.24 of the Java EE Platform Public Review Draft at [1]
EE.5-1 talks about component classes that support injection, and EE.5.24
has been recently updated to clarify requirements of the application
server with respect to handling dependency injection with respect to the
CDI SPI.
EE.5.24 now clarifies the behaviour of injecting component classes into
other managed beans.
-- quote --
> Component classes listed in Table EE.5-1 that satisfy the third condition
> above, but neither the first nor the second condition, can also be used as CDI man-
> aged beans if they are annotated with a CDI bean-defining annotation or contained
> in a bean archive for which CDI is enabled. However, if they are used as CDI
> managed beans (e.g., injected into other managed classes), the instances that are
> managed by CDI may not be the instances that are managed by the Java EE con-
> tainer.
-- quote --
Certain classes that are packaged within the resource adapter archive,
whose lifecycle is managed by the connector container, like
ResourceAdapter, ManagedConnectionFactory, AdministeredObject,
ActivationSpec etc would also need to be behave similarly. These classes
are not 'component classes' (ie they are not candidates for Table EE.5-1).
However they should behave as explained in the last line of the quote above.
As an example:
If some class, say Servlet A, tries to inject a resource
adapter class as shown below, it may very well get an instance of that
class, but it won't be the instance that the Connector runtime is using.
Servlet A {
@Inject
com.eis.foo.ResourceAdapter ra;
}
Shall we add this clarification to the Connectors spec (probably in
Chapter 21) so that this behaviour is explicit and expectation among
application component developers is set clearly?
Thanks
--Siva.
[1]
http://java.net/projects/javaee-spec/downloads/download/JavaEE_Platform_Spec_PublicDraft.pdf