ContextService

The last interesting API of the EE concurrency utilities is ContextService. It allows you to create proxies, based on interfaces, inheriting from the context propagation of the Managed* API. You can see it as a way of using managed thread pool features in the standalone thread pools that you don't control:

Runnable wrappedTask = contextService.createContextualProxy(myTask, Runnable.class);framework.execute(wrappedTask);

Here, we wrap our task in a contextual proxy and we submit the wrapped task through a framework that we don't control. However, the execution will still be done in the EE context of the caller (same JNDI context, for instance), and using another framework is not much affecting.

This ContextService is limited ...

Get Java EE 8 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.