@Override public void run() { try { if (environmentFactories != null) { for (EnvironmentFactory environmentFactory : environmentFactories.values()) { if (environmentFactory != null) { environmentFactory.close(); } } environmentFactories.clear(); } } catch (final Exception ee) { LOG.severe(Misc.getStackTraceFrom(ee)); } } }
protected static SessionFactoryImplementor getSessionFactory(final String domain, final String sessionFactoryName) throws Exception { final SessionFactory sessionFactory = (SessionFactory) GlobalEnvironmentFactory.getEnvironmentFactory(domain).get( sessionFactoryName); if (sessionFactory instanceof SessionFactoryImplementor) { return (SessionFactoryImplementor) sessionFactory; } return null; }
public <T> T execute(Command<T> command) { Environment environment = environmentFactory.openEnvironment(); try { return next.execute(command); } finally { environment.close(); } }
private static void updateJobsAndJobLocks(final String domain) throws Exception { final EnvironmentFactory envFactory = GlobalEnvironmentFactory.getEnvironmentFactory(domain); final Environment environment = envFactory.openEnvironment(); try { DomainOwner.setDomain(domain); final CommandService commandService = envFactory.get(CommandService.class); //create job locks for process definition and root process instances final UpdateJobLocksCommand creteJobLockscommand = new UpdateJobLocksCommand(); commandService.execute(creteJobLockscommand); //update jobs by setting the procesUUID where it's currently null final UpdateJobsCommand updateJobsCommand = new UpdateJobsCommand(); commandService.execute(updateJobsCommand); } finally { DomainOwner.setDomain(null); environment.close(); } }
public static void dropDb(final String domain, final String configurationName) throws Exception { final EventExecutor eventExecutor = GlobalEnvironmentFactory.getEnvironmentFactory(BonitaConstants.DEFAULT_DOMAIN) .get(EventExecutor.class); eventExecutor.stop(); final Configuration configuration = getConfiguration(domain, configurationName); final SchemaExport schemaExport = getSchemaExport(configuration); schemaExport.drop(false, true); final String indexesDirecoryPath = SearchUtil.getIndexesDirectoryPath(configuration); if (indexesDirecoryPath != null) { Misc.deleteDir(new File(indexesDirecoryPath)); } }
try { environmentFactory = GlobalEnvironmentFactory.getEnvironmentFactory(domain); environment = environmentFactory.openEnvironment(); } catch (Exception e) { if(LOG.isLoggable(Level.SEVERE)) {
@Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { if (Environment.getCurrent() != null) { return new RESTServerAPIInterceptorCommand(method, args, api) .execute(Environment.getCurrent()); } // If no environment: use directly the command Service with interceptors final EnvironmentFactory envFactory = GlobalEnvironmentFactory .getEnvironmentFactory(DomainOwner.getDomain()); try { return envFactory.get(CommandService.class).execute( new RESTServerAPIInterceptorCommand(method, args, api)); } catch (final BonitaWrapperException e) { throw e.getCause(); } catch (final BonitaRuntimeException e) { if (DefaultCommandService.class.getName().equals(e.getWrappedBy()) || UnRollbackableException.class.getName().equals(e.getWrappedBy())) { throw e.getCause(); } else { throw e; } } }
protected static Configuration getConfiguration(final String domain, final String configurationName) throws Exception { final EnvironmentFactory envFactory = GlobalEnvironmentFactory.getEnvironmentFactory(domain); if (envFactory == null) { final String message = ExceptionManager.getInstance().getFullMessage("bh_DBT_1"); throw new BonitaRuntimeException(message); } final Configuration config = (Configuration) envFactory.get(configurationName); if (config == null) { final String message = ExceptionManager.getInstance().getFullMessage("bh_DBT_2", configurationName); throw new BonitaRuntimeException(message); } return config; }
return envFactory.get(CommandService.class).execute(new APIInterceptorCommand(method, args, false)); } catch (final BonitaRuntimeException e) { final Throwable cause = e.getCause();