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
PersistenceUtils.doWithSLDPersistence(() -> {
final TitleModel title = modelService.create(TitleModel.class);
title.setCode("foo");
modelService.save(title);
return title;
});
Limitations
-
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.
<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: