Service Event Condition Actions

Service Event Condition Actions (SECAs) are a powerful tool used to build complex business processing solutions out of one or more OFBiz Service(s). With SECAs, you may associate one or more Services together to form a chain of processing logic based on defined triggering events and conditions.

There are no limits on the number of SECAs supported by OFBiz, or in the number of Services that may participate within a single SECA.

Getting ready

Writing SECAs is simple. To write a SECA, you will need one or more Services to participate as either the action Service and/or the target Service. Once you have your Services defined:

  1. Find or create a new SECA definition XML document. The SECA definition document must have the following XML line at the top of the file:
    <?xml version="1.0" encoding="UTF-8" ?>
    
  2. Followed by the SECA XML schema declaration:
    <service-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation=
    "http://ofbiz.apache.org/dtds/service-eca.xsd">
    

How to do it...

Once the groundwork is laid, you can write SECAs by following these steps:

  1. Create an ECA definition within a SECA definition file by adding an eca element with a service attribute similar to the following (Note: the following XML declarations are for illustration purposes only. Please substitute real values where appropriate):
    <eca service="eca_service_name" event="required_some_event_name"
    run-on-failure="optional_true_or_false"
    run-on-error="optional_true_or_false"
    type="optional_some_type" format="optional_some_format" >
    
  2. Optionally, add one ore more condition elements:
    <condition field-name="some_name" operator="operator_values"
    value="some_value" type="supported_types" />
    
  3. Optionally, add on or more set elements as input parameters or to format an existing parameter:
    <set field-name="some_field" value="some_value"
    format="some_format" />
    
  4. Add one or more action declarations. Each action declaration calls a Service to perform some action as shown below. The Service called may have the same name as the ECA:
    <action service="some_service_to_call" mode="some_mode"
    run-as-user="optionally_set_to_a_user" />
    
  5. Don't forget to close the eca service element with an end tag.
  6. Close and save the file.
  7. Restart OFBiz to make the SECA(s) configuration effective.

How it works...

When a Service is called, the first thing the OFBiz Service Engine does, even before assigning a Service implementation engine, is to check for any defined ECAs. If one or more ECAs exists for a Service, each ECA is processed before the initial target Service is invoked.

Note

Note: Some ECAs perform actions on the output of a Service. In such cases, while the ECA itself is processed before the call to the Service, actions defined within the ECA may be invoked after the target Service is run.

In this way, it is possible to combine together any number of Services using any combination of conditions and Events, and thus solve complex business problems using one or more discrete OFBiz Services.

How it works...

There's more...

There is no limit to the possible combinations when building SECAs. This makes the tool extremely powerful and potentially dangerous. It is possible, for example, to call Services within Services in a never-ending chain.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.248.162