[weld-dev] injecting EJBs when using Weld Servlet

Pete Muir pmuir at bleepbleep.org.uk
Sun Oct 10 11:55:28 EDT 2010


On 10 Oct 2010, at 07:07, Dan Allen wrote:

> I recognize this is an edge case, but I can see value in having @EJB injection capability when using Weld Servlet in a pre-Java EE 6 container. You could go about it at least two ways:
> 
> 1. provide a portable extension that satisfies the @EJB annotation on a managed bean field
> 2. implement Weld's EjbServices

This would be a much easier approach IMO, and like you say gives much more complete management.

NB You will also need code in the BDA to register classes as EJBs not managed beans. I would suggest we just support annotation EJB definition for now.

> 
> #1 would be a great demo of a portable extension, but the shortcoming is that it's only a connector between a managed bean and an EJB. You would have to do quite a lot of work to give the EJB CDI services.
> 
> #2 would be pretty easy since you could off-load all the work of #1 back to Weld. The problem is that the Weld Listener doesn't provide any hooks (that I can see) to register services before it starts the Weld container. I was imagining something like a service-provider approach so you can shove the EjbServices implementation (+ family) into the deployment classpath. Can we add that feature?

It would be better to do this using subclassing IMO. You're going to need custom code for each container anyway to actually impl EjbServices. We can easily redesign the Listener class to support this.

BTW I doubt it's possible to fully implement EJB integration in pre EE6 environments as (at least in JBoss AS and GlassFish) some of the hooks (specifically the hooks to remove EJBs on demand) are missing.

File a feature request, and send a pull request when done.


More information about the weld-dev mailing list