Skip to main content
The capabilities in KIE Server are determined by plug-in extensions that you can enable, disable, or further extend to meet your business needs. KIE Server supports the following default capabilities and extensions: Table: KIE Server capabilities and extensions To view the supported extensions of a running KIE Server instance, send a GET request to the following REST API endpoint and review the XML or JSON server response:
Base URL for GET request for KIE Server information
Example JSON response with KIE Server information
To enable or disable KIE Server extensions, configure the related *.server.ext.disabled KIE Server system property. For example, to disable the BRM capability, set the system property org.drools.server.ext.disabled=true. For all KIE Server system properties, see KIE Server system properties. By default, KIE Server extensions are exposed through REST or JMS data transports and use predefined client APIs. You can extend existing KIE Server capabilities with additional REST endpoints, extend supported transport methods beyond REST or JMS, or extend functionality in the KIE Server client. This flexibility in KIE Server functionality enables you to adapt your KIE Server instances to your business needs, instead of adapting your business needs to the default KIE Server capabilities.

Extending an existing KIE Server capability with a custom REST API endpoint

The KIE Server REST API enables you to interact with your KIE containers and business assets (such as business rules, processes, and solvers) in jBPM without using the Business Central user interface. The available REST endpoints are determined by the capabilities enabled in your KIE Server system properties (for example, org.drools.server.ext.disabled=false for the BRM capability). You can extend an existing KIE Server capability with a custom REST API endpoint to further adapt the KIE Server REST API to your business needs. As an example, this procedure extends the Drools KIE Server extension (for the BRM capability) with the following custom REST API endpoint:
Example custom REST API endpoint
This example custom endpoint accepts a list of facts to be inserted into the working memory of the Drools engine, automatically executes all rules, and retrieves all objects from the KIE session in the specified KIE container. Procedure
  1. Create an empty Maven project and define the following packaging type and dependencies in the pom.xml file for the project:
    Example pom.xml file in the sample project
  2. Implement the org.kie.server.services.api.KieServerApplicationComponentsService interface in a Java class in your project, as shown in the following example:
    Sample implementation of the KieServerApplicationComponentsService interface
    1. Delivers REST endpoints to the KIE Server infrastructure that is deployed when the application starts.
    2. Specifies the extension that you are extending, such as the Drools extension in this example.
    3. Returns all resources that the REST container must deploy. Each extension that is enabled in your KIE Server instance calls the getAppComponents method, so the if ( !OWNER_EXTENSION.equals(extension) ) call returns an empty collection for any extensions other than the specified OWNER_EXTENSION extension.
    4. Lists the services from the specified extension that you want to use, such as the RulesExecutionService and KieServerRegistry services from the Drools extension in this example.
    5. Specifies the transport type for the extension, either REST or JMS (REST in this example), and the CustomResource class that returns the resource as part of the components list.
  3. Implement the CustomResource class that KIE Server can use to provide the additional functionality for the new REST resource, as shown in the following example:
    Sample implementation of the CustomResource class
    In this example, the CustomResource class for the custom endpoint specifies the following data and behavior:
    • Uses the base endpoint server/containers/instances/{containerId}/ksession
    • Uses the POST HTTP method
    • Expects the following data to be given in REST requests:
      • The containerId as a path argument
      • The ksessionId as a path argument
      • List of facts as a message payload
    • Supports all KIE Server data formats:
      • XML (JAXB, XStream)
      • JSON
    • Unmarshals the payload into a List<?> collection and, for each item in the list, creates an InsertCommand instance followed by FireAllRules and GetObject commands.
    • Adds all commands to the BatchExecutionCommand instance that calls to the Drools engine.
  4. To make the new endpoint discoverable for KIE Server, create a META-INF/services/org.kie.server.services.api.KieServerApplicationComponentsService file in your Maven project and add the fully qualified class name of the KieServerApplicationComponentsService implementation class within the file. For this example, the file contains the single line org.kie.server.ext.drools.rest.CustomDroolsKieServerApplicationComponentsService.
  5. Build your project and copy the resulting JAR file into the ~/kie-server.war/WEB-INF/lib directory of your project.
  6. Start KIE Server and deploy the built project to the running KIE Server. You can deploy the project using either the Business Central interface or the KIE Server REST API (a PUT request to http://SERVER:PORT/kie-server/services/rest/server/containers/{containerId}). After your project is deployed on a running KIE Server, you can start interacting with your new REST endpoint. For this example, you can use the following information to invoke the new endpoint:
    • Example request URL: http://localhost:8080/kie-server/services/rest/server/containers/instances/demo/ksession/defaultKieSession
    • HTTP method: POST
    • HTTP headers:
      • Content-Type: application/json
      • Accept: application/json
    • Example message payload:
    • Example server response: 200 (success)
    • Example server log output:

Extending KIE Server to use a custom data transport

By default, KIE Server extensions are exposed through REST or JMS data transports. You can extend KIE Server to support a custom data transport to adapt KIE Server transport protocols to your business needs. As an example, this procedure adds a custom data transport to KIE Server that uses the Drools extension and that is based on Apache MINA, an open-source Java network-application framework. The example custom MINA transport exchanges string-based data that relies on existing marshalling operations and supports only JSON format. Procedure
  1. Create an empty Maven project and define the following packaging type and dependencies in the pom.xml file for the project:
    Example pom.xml file in the sample project
  2. Implement the org.kie.server.services.api.KieServerExtension interface in a Java class in your project, as shown in the following example:
    Sample implementation of the KieServerExtension interface
    The KieServerExtension interface is the main extension interface that KIE Server can use to provide the additional functionality for the new MINA transport. The interface consists of the following components:
    Overview of the KieServerExtension interface
    1. Specifies the capability that is covered by this extension. The capability must be unique within KIE Server.
    2. Defines a human-readable name for the extension.
    3. Determines when the specified extension should be started. For extensions that have dependencies on other extensions, this setting must not conflict with the parent setting. For example, in this case, this custom extension depends on the Drools extension, which has StartOrder set to 0, so this custom add-on extension must have a start order greater than 0 (set to 20 in the sample implementation).
    In the previous MinaDroolsKieServerExtension sample implementation of this interface, the init method is the main element for collecting services from the Drools extension and for bootstrapping the MINA server. All other methods in the KieServerExtension interface can remain with the standard implementation to fulfill interface requirements. The TextBasedIoHandlerAdapter class is the handler on the MINA server that reacts to incoming requests.
  3. Implement the TextBasedIoHandlerAdapter handler for the MINA server, as shown in the following example:
    Sample implementation of the TextBasedIoHandlerAdapter handler
    In this example, the handler class receives text messages and executes them in the Drools service. Consider the following handler requirements and behavior when you use the TextBasedIoHandlerAdapter handler implementation:
    • Anything that you submit to the handler must be a single line because each incoming transport request is a single line.
    • You must pass a KIE container ID in this single line so that the handler expects the format containerID|payload.
    • You can set a response in the way that it is produced by the marshaller. The response can be multiple lines.
    • The handler supports a stream mode that enables you to send commands without disconnecting from a KIE Server session. To end a KIE Server session in stream mode, send either an exit or quit command to the server.
  4. To make the new data transport discoverable for KIE Server, create a META-INF/services/org.kie.server.services.api.KieServerExtension file in your Maven project and add the fully qualified class name of the KieServerExtension implementation class within the file. For this example, the file contains the single line org.kie.server.ext.mina.MinaDroolsKieServerExtension.
  5. Build your project and copy the resulting JAR file and the mina-core-2.0.9.jar file (which the extension depends on in this example) into the ~/kie-server.war/WEB-INF/lib directory of your project.
  6. Start the KIE Server and deploy the built project to the running KIE Server. You can deploy the project using either the Business Central interface or the KIE Server REST API (a PUT request to http://SERVER:PORT/kie-server/services/rest/server/containers/{containerId}). After your project is deployed on a running KIE Server, you can view the status of the new data transport in your KIE Server log and start using your new data transport:
    New data transport in the server log
    For this example, you can use Telnet to interact with the new MINA-based data transport in KIE Server:
    Starting Telnet and connecting to KIE Server on port 9123 in a command terminal
    Example interactions with KIE Server in a command terminal
    Example server log output

Extending the KIE Server client with a custom client API

KIE Server uses predefined client APIs that you can interact with to use KIE Server services. You can extend the KIE Server client with a custom client API to adapt KIE Server services to your business needs. As an example, this procedure adds a custom client API to KIE Server to accommodate a custom data transport (configured previously for this scenario) that is based on Apache MINA, an open-source Java network-application framework. Procedure
  1. Create an empty Maven project and define the following packaging type and dependencies in the pom.xml file for the project:
    Example pom.xml file in the sample project
  2. Implement the relevant ServicesClient interface in a Java class in your project, as shown in the following example:
    Sample RulesMinaServicesClient interface
    A specific interface is required because you must register client implementations based on the interface, and you can have only one implementation for a given interface. For this example, the custom MINA-based data transport uses the Drools extension, so this example RulesMinaServicesClient interface extends the existing RuleServicesClient client API from the Drools extension.
  3. Implement the RulesMinaServicesClient interface that KIE Server can use to provide the additional client functionality for the new MINA transport, as shown in the following example:
    Sample implementation of the RulesMinaServicesClient interface
    This example implementation specifies the following data and behavior:
    • Uses socket-based communication for simplicity
    • Relies on default configurations from the KIE Server client and uses ServerUrl for providing the host and port of the MINA server
    • Specifies JSON as the marshalling format
    • Requires received messages to be JSON objects that start with an open bracket {
    • Uses direct socket communication with a blocking API while waiting for the first line of the response and then reads all lines that are available
    • Does not use stream mode and therefore disconnects the KIE Server session after invoking a command
  4. Implement the org.kie.server.client.helper.KieServicesClientBuilder interface in a Java class in your project, as shown in the following example:
    Sample implementation of the KieServicesClientBuilder interface
    1. Enables you to provide additional client APIs to the generic KIE Server client infrastructure
    2. Defines the KIE Server capability (extension) that the client uses
    3. Provides a map of the client implementations, where the key is the interface and the value is the fully initialized implementation
  5. To make the new client API discoverable for the KIE Server client, create a META-INF/services/org.kie.server.client.helper.KieServicesClientBuilder file in your Maven project and add the fully qualified class name of the KieServicesClientBuilder implementation class within the file. For this example, the file contains the single line org.kie.server.ext.mina.client.MinaClientBuilderImpl.
  6. Build your project and copy the resulting JAR file into the ~/kie-server.war/WEB-INF/lib directory of your project.
  7. Start KIE Server and deploy the built project to the running KIE Server. You can deploy the project using either the Business Central interface or the KIE Server REST API (a PUT request to http://SERVER:PORT/kie-server/services/rest/server/containers/{containerId}). After your project is deployed on a running KIE Server, you can start interacting with your new KIE Server client. You use your new client in the same way as the standard KIE Server client, by creating the client configuration and client instance, retrieving the service client by type, and invoking client methods. For this example, you can create a RulesMinaServiceClient client instance and invoke operations on KIE Server through the MINA transport:
    Sample implementation to create the RulesMinaServiceClient client
    Sample configuration to invoke operations on KIE Server through the MINA transport