Configuring Context Services
Context services are used to create dynamic proxy objects that capture the context of a container and enable applications to run within that context at a later time. The context of the container is propagated to the thread executing the task.
Jakarta Concurrency specifies that certain default resources be made available to applications, and defines specific JNDI names for these default resources. Payara Server makes these names available through the use of logical JNDI names, which map Jakarta EE JNDI names to specific Payara Server resources. For context services, the mapping is as follows: java:comp/DefaultContextService This Jakarta Concurrency standard name is mapped to the concurrent/__defaultContextService resource.
|
Create a Context Service
Context services can be created by using Admin Console or Asadmin commands.
To create a new Context Service in the Admin Console, go to Resources → Concurrent Resources → Context Services → New:
Alternatively, you can use the create-context-service
asadmin command to create a context service resource.
Because all JNDI names are in the java:comp/env
subcontext, when specifying the JNDI name of a context service, use only the concurrent/name
format. For example, concurrent/Context1
.
Creating a context service resource is a dynamic event and typically does not require server restart. Applications can use a resource as soon as it is created. However, if an application tried to use a resource before it was created, and that resource is created later, the application or the server must be restarted. Otherwise, the application will not be able to locate the resource. |
Usage
asadmin> create-context-service [--help] [--enabled={false|true}] [--contextinfoenabled={false|true}] [--contextinfo={Classloader|JNDI|Security|WorkArea}]] [--description description] [--property property] [--target target] jndi_name
- Aim
-
The
create-context-service
asadmin command creates a context service resource.
Command Options
Option | Type | Description | Default | Mandatory |
---|---|---|---|---|
|
Boolean |
Determines whether the resource is enabled at runtime. |
true |
No |
|
Boolean |
Determines whether container contexts are propagated to threads. If set to |
true |
No |
|
String |
Specifies individual container contexts to propagate to threads. Valid values are |
|
No |
|
String |
Descriptive details about the resource. |
- |
No |
|
String |
Optional attribute name/value pairs for configuring the resource. |
- |
No |
|
String |
Specifies the target for which you are creating the resource. Valid targets are: server, domain, cluster_name, instance_name |
server |
No |
List Context Services
The list-context-services
asadmin command can be used to list the existing context service resources.
Update a Context Service
You can change all of the settings for an existing context service resource except its
JNDI name. Use the get
and set
asadmin commands to view and change the values of the context service attributes.
When a resource is updated, the existing resource is shut down and recreated. If an application used the resource prior to the update, the application or the server must be restarted. |
-
View the attributes of a specific context service you wish to update by using the
get
asadmin command.
asadmin> get resources.context-service.{resource-JNDI-name}.*
-
Set an attribute of the context service by using the set asadmin command.
asadmin> set resources.context-service.{resource-JNDI-name}.deployment-order=120