Description: Limited to code executed during application startup, such as scope registry in N4. It is non-fatal, which means that N4 logs any errors and the server initializes regardless of any failures, unless a code extension of this type corrupts any vital system components.
You use a SERVER_LIFECYCLE code extension to register new custom entities at a scope other than global. By default, all data model extensions are global in scope. For a field to appear at every scope level, you need to create a separate custom field for each. For more information on scoping, see Scoped objects in N4 (on page 1).
N4 calls an extension of this type once per JVM.
Abstract Base Class: AbstractServerLifecycle
Method: onInitialization()
Interface: EServerLifcycle
Module: Framework
Version Added: 2.2
Requires Code Extension Name or Name Pattern: No
Code Extension Name or Name Pattern: N/A
Where to Specify Code Extensions of this Type: Not needed. N4 automatically calls all code extensions of this type.
System-Seeded Code Extensions Using this Type: None
The following code implements a code extension of type SERVER_LIFECYCLE.
import com.navis.argo.business.model.N4EntityScoper
import com.navis.external.framework.server.AbstractServerLifecycle
import com.navis.framework.business.Roastery
import com.navis.framework.metafields.MetafieldId
import com.navis.framework.metafields.MetafieldIdFactory
class DynamicEntityRegister extends AbstractServerLifecycle {
public void onInitialization() {
N4EntityScoper scoper = (N4EntityScoper) Roastery.getBean(N4EntityScoper.BEAN_ID);
scoper.registerCriteria(CUSTOM_TEST_ENTITY, FCY, null, null);
}
private static final MetafieldId FCY = MetafieldIdFactory.valueOf("customEntityFields.customscopeFcy");
private static final String CUSTOM_TEST_ENTITY = "com.navis.extension.test.CustomTestScope";
}