Package org.jboss.dashboard.database

Examples of org.jboss.dashboard.database.InstalledModule


            List<InitialModule> modules = initialModuleRegistry.getInitialModulesRegistered();
            for (final InitialModule module : modules) {
                new HibernateTxFragment(true) {
                    protected void txFragment(Session session) throws Exception {
                        InstalledModule currentVersion = (InstalledModule) session.get(InstalledModule.class, module.getName(), LockOptions.UPGRADE);

                        // The module is not registered => Install it!
                        if (currentVersion == null) {
                            if (module.doTheInstall()) {
                                if (log.isDebugEnabled()) log.debug("Installed module " + module.getName() + " version " + module.getVersion());
                                currentVersion = new InstalledModule(module.getName(), 1);
                                session.save(currentVersion);
                                session.flush();
                            } else {
                                log.warn("Error installing module " + module.getName() + " version " + module.getVersion());
                            }
                        }
                        // The module's version has been increased => Upgrade it!
                        else if (currentVersion.getVersion() < module.getVersion()) {
                            if (module.doTheUpgrade(currentVersion.getVersion())) {
                                if (log.isDebugEnabled()) log.debug("Upgraded module " + module.getName() + " to version " + module.getVersion());
                                currentVersion.setVersion(module.getVersion());
                                session.saveOrUpdate(currentVersion);
                                session.flush();
                            } else {
                                log.warn("Error upgrading module " + module.getName() + " to version " + module.getVersion());
                            }
View Full Code Here


    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());
View Full Code Here

    protected InstalledModule loadAndLockModule(final String moduleName) {
        final InstalledModule[] module = new InstalledModule[1];
        try {
            new HibernateTxFragment() {
                protected void txFragment(Session session) throws Exception {
                    InstalledModule currentVersion = (InstalledModule) session.get(InstalledModule.class, moduleName, LockMode.UPGRADE);
                    if (currentVersion == null) {
                        module[0] = new InstalledModule(moduleName, 0);
                        module[0].setStatus(InstalledModule.STATUS_LOADING);
                        session.save(module[0]);
                    } else if (StringUtils.isEmpty(currentVersion.getStatus())) {
                        currentVersion.setStatus(InstalledModule.STATUS_LOADING);
                        session.update(currentVersion);
                        module[0] = currentVersion;
                    }
                    session.flush();
                }
View Full Code Here

    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 = (InstalledModule) session.get(InstalledModule.class, module.getName(), LockOptions.UPGRADE);

                // The module is not registered => Install it!
                if (currentVersion == null) {
                    if (module.doTheInstall()) {
                        if (log.isDebugEnabled()) log.debug("Installed module " + module.getName() + " version " + module.getVersion());
                        currentVersion = new InstalledModule(module.getName(), 1);
                        session.save(currentVersion);
                        session.flush();
                    } else {
                        log.warn("Error installing module " + module.getName() + " version " + module.getVersion());
                    }
                }
                // The module's version has been increased => Upgrade it!
                else if (currentVersion.getVersion() < module.getVersion()) {
                    if (module.doTheUpgrade(currentVersion.getVersion())) {
                        if (log.isDebugEnabled()) log.debug("Upgraded module " + module.getName() + " to version " + module.getVersion());
                        currentVersion.setVersion(module.getVersion());
                        session.saveOrUpdate(currentVersion);
                        session.flush();
                    } else {
                        log.warn("Error upgrading module " + module.getName() + " to version " + module.getVersion());
                    }
View Full Code Here

    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 = (InstalledModule) session.get(InstalledModule.class, module.getName(), LockOptions.UPGRADE);

                // The module is not registered => Install it!
                if (currentVersion == null) {
                    if (module.doTheInstall()) {
                        if (log.isDebugEnabled()) log.debug("Installed module " + module.getName() + " version " + module.getVersion());
                        currentVersion = new InstalledModule(module.getName(), 1);
                        session.save(currentVersion);
                        session.flush();
                    } else {
                        log.warn("Error installing module " + module.getName() + " version " + module.getVersion());
                    }
                }
                // The module's version has been increased => Upgrade it!
                else if (currentVersion.getVersion() < module.getVersion()) {
                    if (module.doTheUpgrade(currentVersion.getVersion())) {
                        if (log.isDebugEnabled()) log.debug("Upgraded module " + module.getName() + " to version " + module.getVersion());
                        currentVersion.setVersion(module.getVersion());
                        session.saveOrUpdate(currentVersion);
                        session.flush();
                    } else {
                        log.warn("Error upgrading module " + module.getName() + " to version " + module.getVersion());
                    }
View Full Code Here

            List<InitialModule> modules = initialModuleRegistry.getInitialModulesRegistered();
            for (final InitialModule module : modules) {
                new HibernateTxFragment(true) {
                    protected void txFragment(Session session) throws Exception {
                        InstalledModule currentVersion = (InstalledModule) session.get(InstalledModule.class, module.getName(), LockOptions.UPGRADE);

                        // The module is not registered => Install it!
                        if (currentVersion == null) {
                            if (module.doTheInstall()) {
                                if (log.isDebugEnabled()) log.debug("Installed module " + module.getName() + " version " + module.getVersion());
                                currentVersion = new InstalledModule(module.getName(), 1);
                                session.save(currentVersion);
                                session.flush();
                            } else {
                                log.warn("Error installing module " + module.getName() + " version " + module.getVersion());
                            }
                        }
                        // The module's version has been increased => Upgrade it!
                        else if (currentVersion.getVersion() < module.getVersion()) {
                            if (module.doTheUpgrade(currentVersion.getVersion())) {
                                if (log.isDebugEnabled()) log.debug("Upgraded module " + module.getName() + " to version " + module.getVersion());
                                currentVersion.setVersion(module.getVersion());
                                session.saveOrUpdate(currentVersion);
                                session.flush();
                            } else {
                                log.warn("Error upgrading module " + module.getName() + " to version " + module.getVersion());
                            }
View Full Code Here

TOP

Related Classes of org.jboss.dashboard.database.InstalledModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.