private void closeEnvironment(Environment environment) { try { if(environment != null) { environment.close(); } } catch(Exception e) { if(LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Impossible to open environment: ", e); } } }
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(); } }