JBoss.orgCommunity Documentation

Chapter 7. Packaging

7.1. Packaging
7.2. Imports and Globals
7.2.1. Basic View
7.2.2. Advanced View
7.3. Category rules
7.4. Building
7.5. Selectors
7.5.1. Built-in Selector
7.5.2. Custom Selector
7.6. Snapshots
7.7. Advanced configuration

Packaging is the process of assembling required assets into a single deployable unit, called a package, and configuring the package as necessary.

Some aspects of the configuration are also critical for authoring assets, such as the import of model classes and the definition of global variables. For example, you may add a model which has a class called com.something.Hello, you would then add import com.something.Hello in your package configuration and save the change.

The package configuration screen is reached by clicking on the required package in the "Package Explorer" and then selecting the "Edit" tab.




The "imports" section of the package configuration screen allows you to import Java classes needed by your assets.

When a POJO Model file is uploaded it is scanned for classes and imports are automatically created.

Globals are DRL Global variables that can be accessed by rules. Please consult the Drools Expert documentation for details.


Category Rules allow you to set 'parent rules' for a category of rules. Any rules appearing in the given category will 'extend' the rule specified - i.e. inherit the conditions/left-hand-side.

To be able to take advantage of Category Rules you first need to define one or more categories. See the section relating to Categories for additional information.

Category Rules are defined on the Package screen.

You can build a package by clicking on the button Build package. Any building errors (such as compilation errors) are shown, failing the build. You can chose to build the whole package or a subset of it (see next sections).


Warning

In cases of a large number of rules, all these operations can take some time.

If the build was successful, you can download the binary package as a pkg file. Also you will have the option to create a snapshot for deployment. You can also view the DRL that this package results in by clicking on the package source link.

Note

If you wish to rebuild all packages in bulk, you can do that faster with the left menu Knowledge Bases, menu Create New, menu item Rebuild all packages binaries.

When building packages using the "Packages" feature you have the option to use a "selector". This selector will filter the list of rules that are built into the package.

URLs are central to how built packages are provided. Guvnor provides packages via URLs (for download and use by the Knowledge Agent). These URLs take the form of:

http://<server>/guvnor-webapp/org.drools.guvnor.Guvnor/package/<packageName>/<packageVersion>

<packageName> is the name you gave the package. <packageVersion> is either the name of a snapshot, or "LATEST" (if its LATEST, then it will be the latest built version from the main package, not a snapshot). You can use these in the Knowledge Agent, or you can paste them into your browser and it will download them as a file.

Refer to the section on the Knowledge Agent for details on how you can use these URLs (and binary downloads) in your application, and how rules can be updated on the fly.


The above shows the Package Snapshots view. On the left there is a list of packages. Clicking on a specific package will show you a list of snapshots for that package (if any). From there you can copy, remove or view the assets contained within the snapshot. You can also compare one snapshot to another. Each snapshot is available for download or access via a URL for deployment.

As drools supports various configuration options for a package (such as adding functions for "accumulate" etc), this can be done by adding a X.package or X.conf file to the package - files which contain name/value pairs in the "properties" style. These will then be automatically added to the package configuration. See the main drools documentation for all the things you can do.