What are the default-bindings in the ee subsystem in JBoss EAP 7.
Environment
Red Hat JBoss Enterprise Application Platform (EAP) 7
Issue
- What are the default-bindings in the ee subsystem in JBoss EAP 7.
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
<concurrent>
<context-services>
<context-service name="default" jndi-name="java:jboss/ee/concurrency/context/default" use-transaction-setup-provider="true"/>
</context-services>
<managed-thread-factories>
<managed-thread-factory name="default" jndi-name="java:jboss/ee/concurrency/factory/default" context-service="default"/>
</managed-thread-factories>
<managed-executor-services>
<managed-executor-service name="default" jndi-name="java:jboss/ee/concurrency/executor/default" context-service="default" hung-task-threshold="60000" keepalive-time="5000"/>
</managed-executor-services>
<managed-scheduled-executor-services>
<managed-scheduled-executor-service name="default" jndi-name="java:jboss/ee/concurrency/scheduler/default" context-service="default" hung-task-threshold="60000" keepalive-time="3000"/>
</managed-scheduled-executor-services>
</concurrent>
<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/ExampleDS" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>
</subsystem>
Resolution
JavaEE 7+ includes concurrency utilities as shown in [1] which are these managed-thread-* defined below, these are for applications to use. JBoss does not use them.
The default-bindings are just default JNDI bindings, that that you can define a default datasource that all applications can see for example, below @Resource injects a datasource the thread factories, etc. The default-bindings specifies which one will be injected. If you remove the default-bindings for the datasource, then there would be no datasource to inject below.
Normally instead of just @Resource, you would need @Resouce(lookup="java:jboss/datasources/ExampleDS") as an example. But the default-bindings allow you to define a default for these services listed below.
@Startup
@Singleton
public class TestSingleton {
@Resource
private DataSource dataSource;
@Resource
private ManagedThreadFactory managedThreadFactory;
@Resource
private ManagedExecutorService managedExecutorService;
@Resource
private ManagedScheduledExecutorService scheduledExecutorService;
@Resource
private ContextService contextService;
}
Related Solutions
Java EE 7 Concurrency Utilities Example (managed thread executor) in JBoss EAP 7
[1] Content from docs.oracle.com is not included.Content from docs.oracle.com is not included.https://docs.oracle.com/javaee/7/api/javax/enterprise/concurrent/ContextService.html
[2] https://access.redhat.com/solutions/2969681
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.