Package org.jboss.dashboard.database.hibernate

Examples of org.jboss.dashboard.database.hibernate.HibernateTxFragment


    public boolean doTheUpgrade(final long currentVersion) {
        final boolean [] returnvalue = new boolean[]{false};
        if (installTransactional) {
            try {
                new HibernateTxFragment() {
                    protected void txFragment(Session session) throws Exception {
                        returnvalue[0] = upgrade(currentVersion);
                    }
                }.execute();
            } catch (Exception e) {
View Full Code Here


        else persist(1);
        return isTransient;
    }

    protected void persist(final int op) throws Exception {
        new HibernateTxFragment() {
        protected void txFragment(Session session) throws Exception {
            Object obj = DataSourceEntry.this;
            switch(op) {
                case 0:
                    session.save(obj);
View Full Code Here

                        subscriber.notifyEvent(eventId, eventInfo);
                        break;

                        // Notify to subscriber just before the current transaction completes succesfully.
                        case Subscriber.TXCONTEXT_BEFORE_COMMIT:
                            new HibernateTxFragment(false, true) {
                            protected void beforeCommit() throws Exception {
                                subscriber.notifyEvent(eventId, eventInfo);
                            }}.execute();
                            break;

                    // Notify to subscriber after the current transaction completes succesfully.
                    case Subscriber.TXCONTEXT_AFTER_COMMIT:
                        new HibernateTxFragment(false, true) {
                        protected void afterCommit() throws Exception {
                            subscriber.notifyEvent(eventId, eventInfo);
                        }}.execute();
                        break;

                    // Notify to subscriber within a new transaction launched in a separated thread.
                    case Subscriber.TXCONTEXT_NEW_THREAD:
                        new HibernateTxFragment(false, true) {
                        protected void afterCommit() throws Exception {
                            new Thread(new Runnable() {
                            public void run() {
                                subscriber.notifyEvent(eventId, eventInfo);
                            }}).start();
View Full Code Here

        return null;
    }

    protected void initConnection() {
        try {
            new HibernateTxFragment() {
            protected void txFragment(Session session) throws Exception {
                log.debug("Obtain data source connection: " + name);
                // Bug Fix: under some circumstances, the dataSourceEntry attribute became out of sync with the Hibernate session.
                dataSourceEntry = (DataSourceEntry) session.get(dataSourceEntry.getClass(), dataSourceEntry.getDbid());
                Connection conn = dataSourceEntry.getConnection();
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()) {
View Full Code Here

        }
    }


    protected void unlockModule(final InstalledModule currentVersion) throws Exception {
        HibernateTxFragment fragment = new HibernateTxFragment() {
            public void txFragment(Session session) throws Exception {
                currentVersion.setStatus(null);
                session.update(currentVersion);
                session.flush();
            }
        };
        fragment.execute();
    }
View Full Code Here

        fragment.execute();
    }

    protected void storeModule(final InstalledModule currentVersion, final InitialModule newVersion) {
        try {
            new HibernateTxFragment() {
                protected void txFragment(Session session) throws Exception {
                    currentVersion.setVersion(newVersion.getVersion());
                    session.saveOrUpdate(currentVersion);
                    session.flush();
                }
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);
View Full Code Here

    }

    public Connection getConnection() throws SQLException {
        final Connection[] connection = new Connection[]{null};
        try {
            new HibernateTxFragment() {
                protected void txFragment(Session session) throws Exception {
                    connection[0] = session.connection();
                }
            }.execute();
        } catch (Exception e) {
View Full Code Here

    }

    public synchronized void execute(final SchedulerTask task, boolean onlyIfCommit) {
        try {
            if (onlyIfCommit) {
                new HibernateTxFragment(false, true) {
                protected void beforeCommit() throws Throwable {
                    _schedule(task, null);
                }}.execute();
            } else {
                _schedule(task, null);
View Full Code Here

TOP

Related Classes of org.jboss.dashboard.database.hibernate.HibernateTxFragment

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.