Data Access and Conversions

MRules is based on Java reflection and offers a JSTL-like syntax to access data. This syntax is common and is supported for example by the Apache « commons-beanutils » library.

Early versions of MRules were indeed based on this Apache library for data access and conversions.

However, the implementation “commons-beanutils” has some drawbacks:

  • Execution is slow because the code is not optimized
  • There are restrictions on the syntax and data access

For these reasons, a specific implementation of the data access and conversion is provided by MRules. This implementation not only offers better performance (40% gains for data access, 10% for conversions), but also more features. For example :

  • commons-beanutils does not offer access to indexed objects (i.e. Map) by variable key.
    Example :
    myBean.myMap[myKey].myField: « myKey » is treated as a String and cannot vary.
    With
    MRules :
    myBean.myMap[“myKey”].myField: « myKey » is treated as a String and cannot vary.
    myBean.myMap[myKey].myField: « myKey » is treated as an input bean’s field, whose value will be used as the key.
    myBean.myMap[$myKey].myField: « myKey » is treated as variable.
  • commons-beanutils does not accept null “Nested Beans” while reading or writing data.
    This possibility is offered with
    MRules, choosing to instantiate or not “Nested Beans” on the fly.
  • Tables and Collection are managed in a much more powerful way with MRules, for example with the support of several dimensions.
  • Mrules is able to access directly fields and methods, with a specific syntax:
    Example:
    myBean.!mySubBean.myField: “mySubBean” is a field which is accessed directly, not via getters / setters.
    mybean.!myMethod().myField: “myMethod” is the name of a method , which is accessed directly.
  • MRules allows access to all properties, including private ones.
  • Many more conversions are possible with MRules Converters, and it is simple to add specific implementations.

Please note that it is possible to purchase a license only for a library containing data access, conversion and logging utilities.

These utilities are supplied with a connector for use with code based on Apache library.

For more information, please see our How-To on data access framework.