I've run smack into a serious problem in AS6.
JAX-RS has injection annotations and I need to:
1) Inject into a JAX-RS managed POJO
2) Inject into an EJB instance
3) Inject into CDI bean instance
4) Inject into a Managed Bean instance
5) I'd also like to support Java EE annotation injection (like @EJB and
@Resource) into a JAX-RS managed POJO
While the VDF does allow me to find out if which of these components are
deployed within a WAR so that I easily find out which classes have
JAX-RS annotations, I have to have different integration with each layer
for injections.
I am not alone. EJB has EJB specific injection annotations. Java EE
has common injection annotations, JAX-WS has annotations as well.
Servlet? There's also a multitude of component layers that need to
support these annotations: Managed Beans, EJB instances, servlets,
filters, listeners, JMX Beans, JAX-WS pojos, more?
It would be cool if we had some common facility in which I could do:
Object obj = InjectionFacility.createAndInject(Class<?> someClass)
InjectionFacility.inject(someArbitraryInstance)
InjectionFacility.registerInjector(someJAXRSAnnnotationInjector)
CDI manages a lot (all?) of this. Unfortunately, I've been told that I
cannot leverage CDI unless it has been enabled for the deployment.
Also, I've been told that CDI needs to do a lot of scanning and metadata
building and it would be counter-productive to do this for each
deployment. So....
1) Can we find a way to use CDI as our injection facility? Maybe
turning off CDI scanning, but enabling its plugin and callback APIs and
SPIs?
or
2) Can we develop a common facility that all component layers can use
*INCLUDING* CDI so we don't have to re-invent injection for each and
every framework?
I sincerely hope I don't have to escalate this problem to higher levels.
I would much rather have this be a bottom-up lead effort instead of a
top-down enforced directive.
Bill
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com