From Jakarta EE ManagedExecutorService to MicroProfile ManagedExecutor 📎
@Resource
annotation:
import javax.enterprise.concurrent.ManagedExecutorService;
public class EventSource {
@Resource
ManagedExecutorService threadPool;
(...)
}
[code from: Java EE 8: Sending asynchronous CDI 2.0 events with ManagedExecutorService]
In pure MicroProfile environments these API is not available but can be replaced with ManagedExecutor from MicroProfile Context Propagation:
import org.eclipse.microprofile.context.ManagedExecutor;
public class EventSource {
@Inject
ManagedExecutor executor;
}
Both injected instances are inheriting from ExecutorService.
Migration from javax.enterprise.concurrent.ManagedExecutorService
to org.eclipse.microprofile.context.ManagedExecutor
should be matter of replacing @Resource
with @Inject
, renaming the injected classes and fixing the imports.