2.4. Deployment Descriptors

Processes and rules within Red Hat JBoss BPM Suite 6 onwards are stored in Apache Maven based packaging, and are known as knowledge archives or kjar. The rules, processes, assets, etc. are part of a jar file built and managed by Maven. A file kept inside the META-INF directory of the kjar called kmodule.xml can be used to define the knowledge bases and sessions. This kmodule.xml file, by default, is empty.
Whenever a runtime component such as Business Central is about to process the kjar, it looks up kmodule.xml to build the runtime representation.
Deployment Descriptors, a new feature introduced in the 6.1 branch of Red Hat JBoss BPM Suite, allows you fine grained control over your deployment and supplements the kmodule.xml file. The presence of these descriptors is optional and your deployment will proceed successfully without them. The properties that you can set using these descriptors are purely technical in nature and include meta values like persistence, auditing and runtime strategy.
These descriptors allow you to configure the execution server on multiple levels (server level default, different deployment descriptor per kjar and so on). This allows you to make simple customizations to the execution server's out-of-the-box configuration (possibly per kjar).
You define these descriptors in a file called kie-deployment-descriptor.xml and place this file next to your kmodule.xml file in the META-INF folder. You can change this default location (and the filename) by specifying it as a system parameter:
-Dorg.kie.deployment.desc.location=file:/path/to/file/company-deployment-descriptor.xml

2.4.1. Deployment Descriptor Configuration

Deployment descriptors allow the user to configure the execution server on multiple levels:
  • server level: the main level and the one that applies to all kjars deployed on the server.
  • kjar level: this allows you to configure descriptors on a per kjar basis.
  • deploy time level: descriptors that apply while a kjar is being deployed.
The granular configuration items specified by the deployment descriptors take precedence over the server level ones, except in case of configuration items that are collection based, which are merged. The hierarchy works like this: deploy time configuration > kjar configuration > server configuration.

Note

The deploy time configuration applies to deployments done via the REST API.
For example, if the persistence mode (one of the items you can configure) defined at the server level is NONE but the same mode is specified as JPA at the kjar level, the actual mode will be JPA for that kjar. If nothing is specified for the persistence mode in the deployment descriptor for that kjar (or if there is no deployment descriptor), it will fall back to the server level configuration, which in this case is NONE (or to JPA if there is no server level deployment descriptor).

Can you override this hierarchal merge mode behavior?

Yes. In the default way, if there are deployment descriptors present at multiple levels, the configuration properties are merged with the granular ones overriding the coarse values, and with missing configuration items at the granular level being supplied with those values from the higher levels. The end result is a merged Deployment Descriptor configuration. This default merge mode is called the MERGE_COLLECTIONS mode. But you can change it (Section 2.4.2, “Managing Deployment Descriptors”) if it doesn't suit your environment to one of the following modes:
  • KEEP_ALL: in this mode, all higher level values override all lower level values (server level values replace kjar level values)
  • OVERRIDE_ALL: in this mode, all lower level values override all higher level values (kjar values replace server level values)
  • OVERRIDE_EMPTY: in this mode, all non empty configuration items from lower levels replace those at higher levels, including items that are represented as collections.
  • MERGE_COLLECTIONS (DEFAULT): in this mode, all non empty configuration items from lower level replace those from higher levels (like in OVERRIDE_EMPTY), but collection properties are merged (combined).
Deployment Descriptors from dependent kjars are placed lower than the actual kjar being deployed, but they still have higher hierarchy than the server level.

Do I need to provide a full Deployment Descriptor for all kjars?

No. And this is where the beauty of the merge between different files can help you. Providing partial Deployment Descriptors is possible and recommended. For example, if you want to only override the audit mode in a kjar, then you just need to provide that and the rest of the values will be merged from server level or higher level kjars.
It is worth noting that when using OVERRIDE_ALL merge mode, all configuration items should be specified since the relevant kjar will always use them and will not merge with any other deployment descriptor in the hierarchy.

What can you configure?

High level technical configuration details can be configured via deployment descriptors. The following table lists these along with the permissible and default values for each.

Table 2.1. Deployment Descriptors

Configuration XML Entry Permissible Values Default Value
Persistence unit name for runtime data persistence-unit Any valid persistence package name org.jbpm.domain
Persistence unit name for audit data audit-persistence-unit Any valid persistence package name org.jbpm.domain
Persistence mode persistence-mode JPA, NONE JPA
Audit mode audit-mode JPA, JMS or NONE JPA
Runtime Strategy runtime-strategy SINGLETON, PER_REQUEST or PER_PROCESS_INSTANCE SINGLETON
List of Event Listeners to be registered event-listeners Valid listener class names as ObjectModel No default value
List of Task Event Listeners to be registered task-event-listeners Valid listener class names as ObjectModel No default value
List of Work Item Handlers to be registered work-item-handlers Valid Work Item Handler classes given as NamedObjectHandler No default value
List of Globals to be registered globals Valid Global variables given as NamedObjectModel No default value
Marshalling strategies to be registered (for pluggable variable persistence) marshalling-strategies Valid ObjectModel classes No default value
Required Roles to be granted access to the resources of the kjar required-roles String role names No default value
Additional Environment Entries for Knowledge Session environment-entries Valid NamedObjectModel No default value
Additional configuration options of Knowledge Session configurations Valid NamedObjectModel No default value

How do you provide values for collections based configuration items?

In the table of valid configuration items earlier, you would have noticed that the valid values for the collection based items are either ObjectModel or NamedObjectModel. Both are similar and provide a definition of the object to be built or created at runtime, with the exception that the NamedObjectModel object details name the object to be looked. Both these types are defined using an identifier, optional parameters and resolver (to resolve the object).
  • identifier - defines all the information about the object, such as fully qualified class name, Spring bean id or an MVEL expression.
  • parameters - optional parameters that should be used while creating instances of objects from this model.
  • resolver - identifier of the resolver that will be used to create object instances from the model - (reflection, mvel or Spring).
As an example, if you have built a custom marshaling strategy and want your deployments to use that strategy instead of the default, you will need to provide that strategy as an ObjectModel, with the identifier being com.mycompany.MyStrategy, resolver being reflection (the easiest and the default) and any parameters that are required for your strategy to work. Reflection will then be used to create an instance of this strategy using the fully qualified class name that you have provided as the identifier.
<marshalling-strategy> 
 <resolver>reflection</resolver> 
 <identifier>com.myCompany.MyStrategy</identifier> 
 <parameters>
    <parameter xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      param
    </parameter>
  </parameters> 
</marshalling-strategy>
In case reflection based on resolver is not enough (as demonstrated in the previous example), you can use a resolver based on MVEL expression as the identifier of the object model. While evaluating expressions, you can substitute out-of-the-box parameters. As an example:
<marshalling-strategy> 
  <resolver>mvel</resolver> 
  <identifier>new com.myCompany.CustomStrategy(runtimeManager)</identifier> 
</marshalling-strategy>
The Spring based resolver allows you to look up a bean by its identifier from a Spring application context. Whenever JBoss BPM Suite is used with Spring, this resolver helps in deploying kjars into the runtime. As an example (note that the identifier in this case is a named bean in the Spring context):
<marshalling-strategy>
 <resolver>spring</resolver> 
 <identifier>customStrategy</identifier> 
</marshalling-strategy>

2.4.2. Managing Deployment Descriptors

Deployment Descriptors can be edited via the Business Central in one of two ways. Either graphically (by clicking on AuthoringProject Authoring and then selecting ToolsDeployment Descriptor) or by clicking on AuthoringAdministration menu and then clicking through to the META-INF folder in the File Explorer. Click on the kie-deployment-descriptor.xml file to edit it manually.
Every time a project is created, a stock kie-deployment-descriptor.xml file is generated with default values as described earlier.

Overriding Hierarchical Merge Mode Behavior

To change the default mode of MERGE_COLLECTIONS to one of KEEP_ALL, OVERRIDE_ALL or OVERRIDE_EMPTY you can use the following methods, depending on the requirement.
  • Set the system property org.kie.dd.mergemode to one of these values. This merge mode will become default for all kjars deployed in the system, unless you override it at a kjar level via the next method.
  • When deploying a new deployment unit via Business Central (DeployDeployments) you can select what merge mode should be used for that particular kjar.
  • When deploying via the REST API, you can add mergemode query parameter to the command URL to one of these modes to set the merge mode for that deployment.

Restricting access to the Runtime Engine

One of the configuration items discussed earlier, required-roles, can be edited via the Deployment Descriptors. This property restricts access to the runtime engine on a per kjar or per server level by ensuring that access to certain processes is only granted to users that belong to groups defined by this property.
The security role can be used to restrict access to process definitions or restrict access at runtime.
The default behavior is to add required roles to this property based on repository restrictions. You can of course, edit these properties manually if required, as described above by providing roles that match actual roles defined in the security realm.