IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Developing business processes > Create business rules > Create a rule group

Create custom selectors

Selectors can be used to determine dynamically, at run time, between two or more possible invocations. The decision is driven by selection criteria that you can customize to your needs.

Selectors provide a simple way for you to filter the business logic in different directions depending on input criteria. The possible selection criteria include: the location of the customer, whether you are currently offering any discounts or if the customer is making a sufficiently large purchase to qualify for financing. You can use the provided selectors for many circumstances, particularly those involving date-dependent discounts. In other situations you will need to define your own custom selector. The process of creating a custom selector is described briefly below, more in depth information about creating custom selectors can be found in related links.


Procedure

  1. Create the components that will be the target of the selector after the selection has been made. Any IBM BPM component can be used as the outcome of the selector choice. You need as many components as you will have possible outcomes. These components should all share an interface.

  2. Create a CustomSelector Java™ class. This is the class that will make the decision about which component to select.

    1. Open the New Java Class wizard. Select your Module in the Business Integration view, right-click and select New > Other > Java > Class and then click Next.

    2. In the Source Folder field browse to the current module folder.

    3. Enter "com.ibm.customselectors" in the Package field.

    4. Enter an appropriate name for the Java class, for example "CustomSelector".
    5. Open the Implemented interfaces selection panel. Click the Add button.

    6. In the Choose interfaces field of the Implemented interfaces selection panel type "com.ibm.wbiserver.common.selection.S", and choose SelectionAlgorithm in the Matching types field when it appears. Click OK.

    7. Click Finish.

    8. Augment the generated code with new code that will provide the new custom selection logic.

  3. Create a new selector component.

    1. Apply the same interface to the new selector that you used for the target components.

    2. Choose one of the target IBM BPM components as the Default Rule Logic.
    3. Save and close the new selector.
  4. Edit the code of the new selector to replace the default Java class with your custom code.

    1. In the Business Integration view, right click the selector and click Show Files. This opens the Physical Resources view, which displays the generated files for the project.
    2. Right-click the filename.sel file, and select Open With > Text Editor.

    3. Find the line of code: <Selector>com.ibm.wbiservers.common.selection.GenericSelector</Selector> and replace it with <Selector>com.ibm.customselectors. CustomSelector</Selector> where CustomSelector is the name you gave to your Java class.
    4. Save and close the selector file.

  5. Add the selector and all of the target components to the assembly diagram.


Results

The project is ready to build and test.

Create a rule group


Related concepts:
Rule group editor
Use rule set names in a rule group


Related tasks:
Specifying the rule logic for a rule group
Scheduling rules using the rule group editor
Customize algorithms for date and time selection


Related information:

developerWorks article on creating customized selectors.