Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

In rev. 1298461 and 1298908 Recently a series of enhancements to the Groovy service engine and event handling integration has been introduced to let the system inject a base class for all the Groovy scripts. The classname is configurable in the serviceenginegroovy.xml fileproperties file (located in in the framework/base/conf/ folder): the base class currently available provides an implementation of an OFBiz DSL (Domain Specific Language) based on Groovy specialized in the implementation of business logic (services, events and data preparation scripts).

Main goal: make available to all Groovy services and events a DSL , events, data preparation scripts and scriptles the same DSL, specific for OFBiz, and focused on simplifying common tasks like calling other services, performing entity operations, logging and returning messages, error handling. The end result is that Groovy services and events can all the business logic in OFBiz can now be implemented following a programming style very similar to the one provided by Minilang but leveraging all the features of a complete programming language.

Info

As mentioned above, the DSL for services and events is available out-of-the-box. In order to enable the DSL also for data preparation scripts you'll have to apply the patch that is attached to this page (groovy-dsl-for-data-prep.patch); this work is still experimental and will be committed to the trunk once we will be sure that it doesn't affect the performance of script executionThe complete support for the OFBiz DSL is available since r. 1636346, committed to trunk in early November.

Example

In the following two sections we will compare examples of business logic implemented as a Minilang service and as a Java event to the equivalent version implemented with the Groovy DSL.

...