@Override public void execute(ThrowingRunnable runnable, boolean transactional) throws Exception { if (transactional) { context.execute(datasetContext -> runnable.run()); } else { context.execute(runnable); } }
@Override public void execute(ThrowingRunnable runnable, boolean transactional) throws Exception { if (transactional) { context.execute(datasetContext -> runnable.run()); } else { context.execute(runnable); } }
/** * Run some code with the context class loader combined from the program class loader and the system class loader. */ public void execute(ThrowingRunnable runnable) throws Exception { ClassLoader oldClassLoader = ClassLoaders.setContextClassLoader(getProgramInvocationClassLoader()); try { runnable.run(); } finally { ClassLoaders.setContextClassLoader(oldClassLoader); } }
/** * Run some code with the context class loader combined from the program class loader and the system class loader. */ public void execute(ThrowingRunnable runnable) throws Exception { ClassLoader oldClassLoader = ClassLoaders.setContextClassLoader(getProgramInvocationClassLoader()); try { runnable.run(); } finally { ClassLoaders.setContextClassLoader(oldClassLoader); } }
/** * Executes the given {@link ThrowingRunnable} by setting the {@link SecurityRequestContext} based on the given * {@link Principal}. */ private void runWithPrincipal(Principal principal, ThrowingRunnable runnable) throws Exception { String oldUserId = SecurityRequestContext.getUserId(); try { SecurityRequestContext.setUserId(principal.getName()); runnable.run(); } finally { SecurityRequestContext.setUserId(oldUserId); } } }
/** * Executes the given {@link ThrowingRunnable} by setting the {@link SecurityRequestContext} based on the given * {@link Principal}. */ private void runWithPrincipal(Principal principal, ThrowingRunnable runnable) throws Exception { String oldUserId = SecurityRequestContext.getUserId(); try { SecurityRequestContext.setUserId(principal.getName()); runnable.run(); } finally { SecurityRequestContext.setUserId(oldUserId); } } }