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.
About this task
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
- Create the components that will be the target of the selector
after the selection has been made.
Any IBM® Business Automation
Workflow 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.
- Create a CustomSelector Java™ class.
This is the class that will make the decision about which component
to select.
- Open the New Java Class wizard.
Select your Module in the Business Integration view, right-click
and select and
then click Next.
- In the Source Folder field browse
to the current module folder.
- Enter
com.ibm.customselectors
in the Package field.
- Enter an appropriate name for the Java class, for example
CustomSelector
.
- Open the Implemented interfaces selection panel.
Click the Add button.
- 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.
- Click Finish.
- Augment the generated code with new code that will provide
the new custom selection logic.
- Create a new selector component.
- Apply the same interface to the new selector that you
used for the target components.
- Choose one of the target IBM Business Automation
Workflow components
as the Default Rule Logic.
- Save and close the new selector.
- Edit the code of the new selector to replace the default Java class with your custom code.
- 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.
- Right-click the filename.sel file,
and select Open With > Text Editor.
- 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.
- Save and close the selector file.
- Add the selector and all of the target components to the
assembly diagram.
Results
The project is ready to build and test.
This topic only applies to BAW, and is located in the BAW repository. Last updated on 2025-03-13 12:15