Search in sources :

Example 1 with ThrowingRunnable

use of com.servoy.j2db.util.UIUtils.ThrowingRunnable in project servoy-client by Servoy.

the class RemoteActiveSolutionHandler method loadLoginSolutionAndModules.

@Override
public Solution[] loadLoginSolutionAndModules(final SolutionMetaData mainSolutionDef) throws RepositoryException, RemoteException {
    final SolutionMetaData[] loginSolutionDefinitions = getApplicationServer().getLoginSolutionDefinitions(mainSolutionDef);
    if (loginSolutionDefinitions == null) {
        throw new RepositoryException("Could not load login solution");
    }
    final Solution[] solutions = new Solution[loginSolutionDefinitions.length];
    if (loginSolutionDefinitions.length > 0) {
        ThrowingRunnable<RepositoryException, RemoteException> r = new ThrowingRunnable<RepositoryException, RemoteException>() {

            @Override
            public void run() {
                try {
                    int[] sol_ids = new int[loginSolutionDefinitions.length];
                    for (int i = 0; i < sol_ids.length; i++) {
                        sol_ids[i] = loginSolutionDefinitions[i].getRootObjectId();
                    }
                    long[] asus = getApplicationServer().getActiveRootObjectsLastModified(sol_ids);
                    ConcurrentMap<String, IServer> sps = getRepository().getServerProxies(loginSolutionDefinitions);
                    for (int i = 0; i < loginSolutionDefinitions.length; i++) {
                        Solution s = loadCachedSolution(loginSolutionDefinitions[i], asus[i], sps);
                        if (s == null) {
                            // do full load
                            s = getApplicationServer().getLoginSolution(mainSolutionDef, loginSolutionDefinitions[i]);
                        }
                        if (s != null) {
                            if (s.getRepository() == null) {
                                // transient
                                s.setRepository(getRepository());
                            }
                            loadedActiveSolutionUpdateSequences.put(new Integer(s.getSolutionID()), new Long(asus[i]));
                            s.setServerProxies(sps);
                        }
                        solutions[i] = s;
                    }
                } catch (RepositoryException eo) {
                    e1 = eo;
                } catch (RemoteException et) {
                    e2 = et;
                }
            }
        };
        UIUtils.runWhileDispatchingEvents(r, getServiceProvider());
    }
    return solutions;
}
Also used : IServer(com.servoy.j2db.persistence.IServer) RepositoryException(com.servoy.j2db.persistence.RepositoryException) SolutionMetaData(com.servoy.j2db.persistence.SolutionMetaData) ThrowingRunnable(com.servoy.j2db.util.UIUtils.ThrowingRunnable) RemoteException(java.rmi.RemoteException) Solution(com.servoy.j2db.persistence.Solution)

Example 2 with ThrowingRunnable

use of com.servoy.j2db.util.UIUtils.ThrowingRunnable in project servoy-client by Servoy.

the class RemoteActiveSolutionHandler method loadActiveSolutions.

@Override
public Solution[] loadActiveSolutions(final RootObjectMetaData[] solutionDefs) throws RepositoryException, RemoteException {
    final int[] sol_ids = new int[solutionDefs.length];
    for (int i = 0; i < sol_ids.length; i++) {
        sol_ids[i] = solutionDefs[i].getRootObjectId();
    }
    final Solution[] retval = new Solution[solutionDefs.length];
    ThrowingRunnable<RepositoryException, RemoteException> r = new ThrowingRunnable<RepositoryException, RemoteException>() {

        @Override
        public void run() {
            try {
                long[] asus = getApplicationServer().getActiveRootObjectsLastModified(sol_ids);
                ConcurrentMap<String, IServer> sps = getRepository().getServerProxies(solutionDefs);
                for (int i = 0; i < solutionDefs.length; i++) {
                    Solution s = loadCachedSolution(solutionDefs[i], asus[i], sps);
                    if (s == null) {
                        // do full load
                        s = loadSolution(solutionDefs[i]);
                    }
                    if (s != null) {
                        if (s.getRepository() == null) {
                            // transient
                            s.setRepository(getRepository());
                        }
                        loadedActiveSolutionUpdateSequences.put(new Integer(s.getSolutionID()), new Long(asus[i]));
                        s.setServerProxies(sps);
                    }
                    retval[i] = s;
                }
            } catch (RepositoryException eo) {
                e1 = eo;
            } catch (RemoteException et) {
                e2 = et;
            }
        }
    };
    UIUtils.runWhileDispatchingEvents(r, getServiceProvider());
    return retval;
}
Also used : IServer(com.servoy.j2db.persistence.IServer) RepositoryException(com.servoy.j2db.persistence.RepositoryException) ThrowingRunnable(com.servoy.j2db.util.UIUtils.ThrowingRunnable) RemoteException(java.rmi.RemoteException) Solution(com.servoy.j2db.persistence.Solution)

Aggregations

IServer (com.servoy.j2db.persistence.IServer)2 RepositoryException (com.servoy.j2db.persistence.RepositoryException)2 Solution (com.servoy.j2db.persistence.Solution)2 ThrowingRunnable (com.servoy.j2db.util.UIUtils.ThrowingRunnable)2 RemoteException (java.rmi.RemoteException)2 SolutionMetaData (com.servoy.j2db.persistence.SolutionMetaData)1