public static EnvironmentFactory getEnvironmentFactory(final String domain) throws Exception { synchronized (LOCK) { if (environmentFactories.get(domain) == null) { String environmentResource = getEnvironmentResource(domain); URL url = null; final File file = new File(environmentResource); setEnvironmentFactory(domain, factory); Runtime.getRuntime().addShutdownHook(new BonitaShutdownHook());
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; }
setEnvironmentFactory(factory); Runtime.getRuntime().addShutdownHook(new BonitaShutdownHook());
setEnvironmentFactory(factory); Runtime.getRuntime().addShutdownHook(new BonitaShutdownHook());
if(domain != null){ try { environmentFactory = GlobalEnvironmentFactory.getEnvironmentFactory(domain); environment = environmentFactory.openEnvironment(); } catch (Exception e) {
public static Context getFromEnvironment() { final EnvironmentFactory envFactory = GlobalEnvironmentFactory.getEnvironmentFactory(); final APIConfig apiConfig = envFactory.get(APIConfig.class); Context context = null;
private static SchemaExport getSchemaExport(String configurationName) { EnvironmentFactory envFactory = GlobalEnvironmentFactory.getEnvironmentFactory(); if (envFactory == null) { throw new BonitaRuntimeException("Unable to find EnvironmentFactory."); } Configuration config = (Configuration) envFactory.get(configurationName); if (config == null) { throw new BonitaRuntimeException("Unable to find a hibernate configuration '" + configurationName + "' in the EnvironmentFactory."); } return new SchemaExport(config, config.buildSettings()); }
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)); } }
@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; }
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 Object invoke(final Object proxy, final Method method, final Object[] args) throws BonitaException { try { // If already in environment: use the same environment to execute the // command directly if (Environment.getCurrent() != null) { return new APIInterceptorCommand(method, args, true).execute(Environment.getCurrent()); } // If no environment: use directly the command Service with interceptors final EnvironmentFactory envFactory = GlobalEnvironmentFactory.getEnvironmentFactory(); return envFactory.get(CommandService.class).execute(new APIInterceptorCommand(method, args, false)); } catch (final PvmException e) { final Throwable cause = e.getCause(); if (cause instanceof BonitaException) { throw (BonitaException) cause; } throw e; } catch (final BonitaException e) { throw e; } catch (final InvalidEnvironmentException e) { // Don't throw BonitaInternalException if Environment parsing failed. // This is a configuration problem, not an engine bug. throw e; } catch (final BonitaWrapperException e) { throw (RuntimeException) e.getCause(); } catch (final RuntimeException e) { throw BonitaInternalException.build(e); } catch (final Exception t) { throw new BonitaInternalException("Ouch! Unexpected error: " + t, t); } }
final EnvironmentFactory envFactory = GlobalEnvironmentFactory.getEnvironmentFactory(DomainOwner.getDomain()); return envFactory.get(CommandService.class).execute(new APIInterceptorCommand(method, args, false)); } catch (final BonitaRuntimeException e) {