* @see org.apache.tapestry5.services.ApplicationInitializerFilter#initializeApplication(org.apache.tapestry5.services.Context, org.apache.tapestry5.services.ApplicationInitializer)
*/
@Override
public void initializeApplication(Context context, ApplicationInitializer initializer) {
// Init boot from boot file path
BootManager bootManager = BootManager.getInstance();
bootManager.setBootFilePath(context.getRealFile("/WEB-INF/boot.properties").getAbsolutePath());
//handle DataInitializer
if (bootManager.isSetup()) {
List<DataInitializer> dataInitializers = new ArrayList<DataInitializer>();
String[] beanNames = _appContext.getBeanNamesForType(DataInitializer.class);
for (String beanName : beanNames) {
dataInitializers.add((DataInitializer) _appContext.getBean(beanName));
}
dataInitializers = sortInitializers(dataInitializers);
for (DataInitializer dataInitializer : dataInitializers) {
try {
dataInitializer.initialize();
} catch (Exception e) {
logger.error("An error ocurred when initilizing entities.", e);
}
}
bootManager.setSetup(false);
bootManager.save();
}
initializer.initializeApplication(context);
}