ServiceLayer Direct

ServiceLayer Direct allows you to read and persist data in the database and completely skip the Jalo layer. With ServiceLayer Direct in place, you still use ModelService to manage models.

Configuration

To enable ServiceLayer Direct globally, set the persistence.legacy.mode property to false. This setting enables writing and reading operations through the new layer. You can enable ServiceLayer Direct just for a current session context, but have it disabled globally. See the implementation example:
PersistenceUtils.doWithSLDPersistence(() -> {
    final TitleModel title = modelService.create(TitleModel.class);
    title.setCode("foo");
    modelService.save(title);
 
    return title;
});

Limitations

Because some code may still have business logic in the old Jalo classes in place (especially in Jalo attributes), we don't recommend switching on ServiceLayer Direct. In the following cases, you cannot use ServiceLayer Direct:
  • Item attribute is configured as Jalo in items.xml. It means there is a business logic in a Jalo class (Item or Manager) for a getter or setter.

  • Item attribute is configured as a property in items.xml but it has an overridden getter or setter in a Jalo class

  • Item has a custom logic in createItem(...) protected method (usually for validation or preparation purposes)

There is an easy way to migrate such a code and make it ServiceLayer Direct enabled. However, treat each case individually. There isn't one correct way to migrate. Migration would usually consist in changing Jalo attributes into dynamic attributes, and moving the original logic into a dynamic attribute handler, or creating proper interceptors (prepare, validation, or remove interceptors).

If for some reason it is not possible to migrate Jalo logic, mark an appropriate method or type with the ForceJALO annotation. Such an annotated type is always persisted and read using the Jalo layer. Such annotations have informational value and help you quickly locate a problematic code for further migration.

There is also the SLDSafe annotation that has an opposite meaning to ForceJALO. Use SLDSafe to provide a hint that an item is fully migrated and is safe to persist and read through ServiceLayer Direct.

Another way to force a particular type through the Jalo layer is to mark it directly in items.xml as follows:
<itemtype code="Foo">
    <custom-properties>
        <property name="legacyPersistence">
            <value>java.lang.Boolean.TRUE</value>
        </property>
    </custom-properties>
 
...
</itemtype>

Architecture Diagrams

Here is a comparison of write operations in ServiceLayer Direct and Jalo:

Here is a comparison of read operations in ServiceLayer Direct and Jalo: