public void start() throws Exception {
List<InitialModule> modules = initialModuleRegistry.getInitialModulesRegistered();
for (final InitialModule module : modules) {
new HibernateTxFragment(true) {
protected void txFragment(Session session) throws Exception {
InstalledModule currentVersion = loadAndLockModule(module.getName());
if (currentVersion != null) {
try {
if (currentVersion.getVersion() == module.getVersion()) {
if (log.isDebugEnabled())
log.debug("Module " + module.getName() + " version " + module.getVersion() + "is already installed.");
} else if (currentVersion.getVersion() == 0) {
if (module.doTheInstall()) {
if (log.isDebugEnabled())
log.debug("Installed module " + module.getName() + " version " + module.getVersion());
storeModule(currentVersion, module);
} else {
log.warn("Error installing module " + module.getName() + " version " + module.getVersion());
}
} else if (module.doTheUpgrade(currentVersion.getVersion())) {
if (log.isDebugEnabled())
log.debug("Upgraded module " + module.getName() + " to version " + module.getVersion());
storeModule(currentVersion, module);
} else
log.warn("Error upgrading module " + module.getName() + " to version " + module.getVersion());