Skip to main content

ExecutorService: injectable via CDI?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
ljnelson
Offline
Joined: 2003-08-04

From a specification compliance standpoint, could one inject an instance of java.util.concurrent.ExecutorService inside a stateless EJB?

An EJB is not allowed to manage threads using synchronization primitives, directly or indirectly.  That means I can't just do new Thread() or just use one of the values returned by java.util.concurrent.Executors.

But would injecting such an ExecutorService using CDI get me off the hook here?

Or am I looking at writing a resource adapter to submit work to the container?

As always, apologies for any double posting that occurs--java.net's forums occasionally double post my submissions after a significant delay.

Thanks,
Laird