Faster application startup (Java)
Several improvements improve the speed at which the application starts, but this does result in some API changes.
Before SDL Digital Experience Accelerator 1.1, a bootstrap process used the file /system/_all.json to serialize all configuration files for all localizations that you specified in cd_dynamic_conf.xml.
As of DXA 1.1, serialization takes place on demand, per localization and per setting type. If your Web application contains a large number of sites or localizations, this leads to a noticeably faster startup of your application.
- The
IStaticFileManager.CreateStaticAssetsmethod is now obsolete. - The
Serializemethod now has aLocalizationparameter.
Similarly, before DXA 1.1, you could rely on the product to populate the ViewModelRegistry, which stores the mapping between a View and the View Model type, for you. This required the View to be compiled and the View Model type to be determined, resulting in slow initial page rendering after application startup.
AreaConfiguration class to populate the registry with all the views in your Area. To achieve this, make your Area Registration class inherit from Sdl.Web.Mvc.Configurations.BaseAreaRegistration and override the RegisterAllViewModels method as follows:
package com.sdl.webapp.main;
import com.sdl.webapp.common.api.model.ViewModelRegistry;
import com.sdl.webapp.common.api.model.entity.*;
import com.sdl.webapp.common.api.model.page.PageModelImpl;
import com.sdl.webapp.common.api.model.region.RegionModelImpl;
import com.sdl.webapp.common.exceptions.DxaException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class CoreInitializer {
private final ViewModelRegistry viewModelRegistry;
@Autowired
public CoreInitializer(ViewModelRegistry viewModelRegistry) {
this.viewModelRegistry = viewModelRegistry;
}
@PostConstruct
public void registerViewModelEntityClasses() {
try {
viewModelRegistry.registerViewEntityClass("Article", Article.class);
viewModelRegistry.registerViewEntityClass("Breadcrumb", NavigationLinks.class);
<code omitted for brevity>
} catch (DxaException e) {
//LOG errors
}
}
}