Language and Page Formatting Options
9.5. Service Repository
Domain-specific services can be added to a repository to make them available to other users.
Services are added to a service repository by creating a configuration file that contains all the necessary information and links to the required files. Note, the configuration file is an extended version of a normal work definition configuration file as shown in Section 9.2, “Define a Work Item”.
Example 9.4. Service Repository Configuration File
import org.drools.process.core.datatype.impl.type.StringDataType; [ [ "name" : "Twitter", "description" : "Send a twitter message", "parameters" : [ "Message" : new StringDataType() ], "displayName" : "Twitter", "eclipse:customEditor" : "org.drools.eclipse.flow.common.editor.editpart.work.SampleCustomEditor", "icon" : "twitter.gif", "category" : "Communication", "defaultHandler" : "org.jbpm.process.workitem.twitter.TwitterHandler", "documentation" : "index.html", "dependencies" : [ "file:./lib/jbpm-twitter.jar", "file:./lib/twitter4j-core-2.2.2.jar" ] ] ]
- The icon property should refer to a file with the given file name in the same folder as the extended configuration file (so it can be downloaded by the import wizard and used in the process diagrams). Icons should be 16x16 GIF files.
- The category property defines the category this service should be placed under when browsing the repository.
- The defaultHandler property defines the default handler implementation (i.e. the Java class that implements the
WorkItemHandlerinterface and can be used to execute the service). This can automatically be registered as the handler for that service when importing the service from the repository.
- The documentation property defines a documentation file that describes what the service does and how it works. This property should refer to a HTML file with the given name in the same folder as the extended configuration file (so it can be shown by the import wizard when browsing the repository).
- The dependencies property defines additional dependencies that are necessary to execute this service. This usually includes the handler implementation jar but could also include additional external dependencies. These dependencies should also be located on the repository on the given location (relative to the folder where the extended configuration file is located), so they can be downloaded by the import wizard when importing the service.
The root of the repository should also contain an
index.conffile that references all the folders that should be processed when searching for services in the repository. Each of those folders should then contain:
- An extended configuration file with the same name as the folder (e.g.
Twitter.conf) that defines the service task
- The icon as references in the configuration file
- The documentation as references in the configuration file
- The dependencies as references in the configuration file (for example in a lib folder)
Include an additional
index.confin each sub-directory of the repository that can be used to scan additional sub-folders. Note that the hierarchical structure of the repository is not shown when browsing the repository using the import wizard, as the category property in the configuration file is used for that.
The example below explains how to import resources from the service repository when working with JBoss Developer Studio.
Procedure 9.1. Import Resources From the Service Repository
- Right click the project and select Import....
- Select the source of the resources to import. i.e., Guvnor → Resources from Guvnor and click Next.
- Navigate to the resources. i.e., select the package where the resource is located in Guvnor and highlight the resources. Click Menu.
- Select the destination location for the resources and click Finish.