Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 6. Creating a self-contained Red Hat Decision Manager Spring Boot JAR file
You can create a single self-contained Red Hat Decision Manager Spring Boot JAR file that contains a complete service, including KIE Server and one or more KJAR files. The Red Hat Decision Manager Spring Boot JAR file does not depend on any KJAR files loading at runtime.
If necessary, the Red Hat Decision Manager Spring Boot JAR file can contain multiple versions of the same KJAR file, including modules. These KJAR files can have the same artifactID and groupID attribute values, but have different version values.
The included KJAR files are separated from any JAR files in the BOOT-INF/lib directory to avoid class loader collisions. Each KJAR classpath container file is isolated from other KJAR classpath container files and does not rely on the Spring Boot class loader.
Prerequisites
- You have an existing Red Hat Decision Manager Spring Boot project.
- You have completed development of one or more KJAR files for the project.
Procedure
Build all KJAR files for the project. In the default business application, the KJAR source is contained in the
<BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-kjardirectory, whereBUSINESS-APPLICATIONis the name of the business application. Your project might include other KJAR source directories.To build the KJAR files, for every KJAR source directory, complete the following steps:
- Change to the KJAR source directory.
Enter the following command:
mvn install
mvn installCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command builds the KJAR file and places it into the local Maven repository. By default, this repository is located in the
~/.m2/repodirectory.
In the
<BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service/src/main/resourcesdirectory, add the following property to your Spring Boot applicationapplication.propertiesfile:kieserver.classPathContainer=true
kieserver.classPathContainer=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow When this property is set to
true, KIE Server uses the class loader used by the container to load KJAR files and their dependencies.Complete one of the following actions to ensure that KIE Server loads the necessary KJAR modules:
To configure KIE Server to scans and deploy all KJAR modules available in the Spring Boot application, add the following property to the
application.propertiesfile:kieserver.autoScanDeployments=true
kieserver.autoScanDeployments=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow When this property is set to
true, KIE Server deploys all KJAR modules available in the application, whether they are declared programmatically or through the Maven plug-in.This option is the simplest method to include all KJAR modules. However, it has two drawbacks:
- The application sets all container IDs and aliases automatically, based on the group, artifact, and version (GAV) of every KJAR module. You cannot set a custom container ID or alias for a KJAR module.
- At startup time, the application scans the JAR file and the class path for KJAR modules. Therefore, the duration of startup might be increased.
To avoid these drawbacks, you can configure every KJAR module individually using the
application.propertiesfile or using Java source code, as described in one of the following options.To configure every KJAR module individually using the
application.propertiesfile, for each of the KJAR modules that you want to include in the service, add the following properties to theapplication.propertiesfile:kieserver.deployments[<n>].containerId=<container> kieserver.deployments[<n>].alias=<alias> kieserver.deployments[<n>].artifactId=<artifact> kieserver.deployments[<n>].groupId=<group> kieserver.deployments[<n>].version=<version>
kieserver.deployments[<n>].containerId=<container> kieserver.deployments[<n>].alias=<alias> kieserver.deployments[<n>].artifactId=<artifact> kieserver.deployments[<n>].groupId=<group> kieserver.deployments[<n>].version=<version>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the following values:
-
<n>: A sequential number:0for the first KJAR module,1for the second module, and so on -
<container>: The container ID for the KJAR module -
<alias>: The alias for the KJAR module -
<artifact>: The artifact ID for the KJAR module -
<group>: The group ID for the KJAR module -
<version>: The version ID for the KJAR module
The following example configures two versions of the
EvaluationKJAR module:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
To configure every KJAR module individually using Java source code, create a class in your business application service, similar to the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For every KJAR module that you want to include, create a
KieContainerResourcebean in this class. The name of the bean is the container name, the first parameter ofKieContainerResource()is the alias name, and the parameters ofReleaseId()are the group ID, artifact ID, and version ID of the KJAR module.
In the
<BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-servicedirectory, add the following Maven plug-in in the Spring Bootservice/pom.xmlfile where<GROUP_ID>,<ARTIFACT_ID>, and<VERSION>are the group, artifact, and version (GAV) of a KJAR artifact that your project uses. You can find these values in thepom.xmlfile that is located in the KJAR source directory.NoteYou can add more than one version of an artifact.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The artifacts required to run the KJAR will be resolved at build time.
The following example adds two version of the
Evaluationartifact:Copy to Clipboard Copied! Toggle word wrap Toggle overflow To build the self-contained Spring Boot image, enter the following command in the
<BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-servicedirectory:mvn install
mvn installCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: to run the self-contained Spring Boot image, locate the JAR file in the
targetsubdirectory and enter the following command:java -jar <FILENAME>.jar
java -jar <FILENAME>.jarCopy to Clipboard Copied! Toggle word wrap Toggle overflow In this command, replace
<FILENAME>with the name of the JAR file.