Top Description Inners Methods
jakarta.enterprise.concurrent

public @Interface ManagedScheduledExecutorDefinition

extends Annotation
Annotations
@Repeatable:List
@Retention:RUNTIME
@Target:TYPE
Static Imports
java.lang.annotation.ElementType.TYPE, .RetentionPolicy.RUNTIME

Defines a ManagedScheduledExecutorService to be registered in JNDI by the container under the JNDI name that is specified in the name() attribute.

Application components can refer to this JNDI name in the lookup attribute of a jakarta.annotation.Resource annotation,

@ManagedScheduledExecutorDefinition(
    name = "java:comp/concurrent/MyScheduledExecutor",
    context = "java:comp/concurrent/MyScheduledExecutorContext",
    hungTaskThreshold = 30000,
    maxAsync = 3)
@ContextServiceDefinition(
    name = "java:comp/concurrent/MyScheduledExecutorContext",
    propagated = APPLICATION)
 public class MyServlet extends HttpServlet {
   @Resource(lookup = "java:comp/concurrent/MyScheduledExecutor",
              name = "java:comp/concurrent/env/MyScheduledExecutorRef")
    ManagedScheduledExecutorService myScheduledExecutor;

Resource environment references in a deployment descriptor can similarly specify the lookup-name,

<resource-env-ref>
   <resource-env-ref-name>java:comp/env/concurrent/MyScheduledExecutorRef</resource-env-ref-name>
   <resource-env-ref-type>jakarta.enterprise.concurrent.ManagedScheduledExecutorService</resource-env-ref-type>
   <lookup-name>java:comp/concurrent/MyScheduledExecutor</lookup-name>
</resource-env-ref>
You can also define a ManagedScheduledExecutorService with the <managed-scheduled-executor> deployment descriptor element. For example,
<managed-scheduled-executor>
   <name>java:module/concurrent/MyExecutor</name>
   <context-service-ref>java:module/concurrent/MyExecutorContext</context-service-ref>
   <hung-task-threshold>120000</hung-task-threshold>
   <max-async>5</max-async>
</managed-scheduled-executor>
If a managed-scheduled-executor and ManagedScheduledExecutorDefinition have the same name, their attributes are merged to define a single ManagedScheduledExecutorService definition, with each attribute that is specified in the managed-scheduled-executor deployment descriptor entry taking precedence over the corresponding attribute of the annotation.
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static @interface
ManagedScheduledExecutorDefinition.List

Enables multiple ManagedScheduledExecutorDefinition annotations on the same type.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

name of the ContextService for capturing and propagating or clearing context.
context
()

The name of a ContextService instance which determines how context is applied to tasks and actions that run on this executor.

public long

Returns:

number of milliseconds after which a task or action is considered hung.
hungTaskThreshold
()

The amount of time in milliseconds that a task or action can execute before it is considered hung.

public int

Returns:

upper limit on asynchronous execution.
maxAsync
()

Upper bound on contextual tasks and actions that this executor will simultaneously execute asynchronously.

public String

Returns:

ManagedScheduledExecutorService JNDI name.
name
()

JNDI name of the ManagedScheduledExecutorService instance.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

contextback to summary
public String context()

The name of a ContextService instance which determines how context is applied to tasks and actions that run on this executor.

The name can be the name of a ContextServiceDefinition or the name of a context-service deployment descriptor element or the JNDI name of the Jakarta EE default ContextService instance, java:comp/DefaultContextService.

The name of the ContextService must be no more granular than the name of this ManagedScheduledExecutorDefinition. For example, if this ManagedScheduledExecutorDefinition has a name in java:app, the ContextService can be in java:app or java:global, but not in java:module which would be ambiguous as to which module's ContextService definition should be used.

The default value, java:comp/DefaultContextService, is the JNDI name of the Jakarta EE default ContextService.

Returns:String

name of the ContextService for capturing and propagating or clearing context.

hungTaskThresholdback to summary
public long hungTaskThreshold()

The amount of time in milliseconds that a task or action can execute before it is considered hung.

The default value of -1 indicates unlimited.

Returns:long

number of milliseconds after which a task or action is considered hung.

maxAsyncback to summary
public int maxAsync()

Upper bound on contextual tasks and actions that this executor will simultaneously execute asynchronously. This constraint does not apply to tasks and actions that the executor runs inline, such as when a thread requests java.util.concurrent.CompletableFuture#join() and the action runs inline if it has not yet started. This constraint also does not apply to tasks that are scheduled via the schedule* methods.

The default value of -1 indicates unbounded, although still subject to resource constraints of the system.

Returns:int

upper limit on asynchronous execution.

nameback to summary
public String name()

JNDI name of the ManagedScheduledExecutorService instance. The JNDI name must be in a valid Jakarta EE namespace, such as,

  • java:comp
  • java:module
  • java:app
  • java:global
Returns:String

ManagedScheduledExecutorService JNDI name.

jakarta.enterprise.concurrent back to summary

public @Interface ManagedScheduledExecutorDefinition.List

extends Annotation
Annotations
@Retention:RUNTIME
@Target:TYPE

Enables multiple ManagedScheduledExecutorDefinition annotations on the same type.

Method Summary

Modifier and TypeMethod and Description
public ManagedScheduledExecutorDefinition[]
Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public ManagedScheduledExecutorDefinition[] value()