public void run() throws E { consumer.accept(param1, param2); }
public static <T, U, E extends Exception> void acceptWithInterruptHandler(InterruptHandler interruptHandler, ExceptionBiConsumer<T, U, E> function, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (thread == null) { function.accept(param1, param2); return; } else { final InterruptHandler old = thread.interruptHandler; thread.interruptHandler = interruptHandler; try { function.accept(param1, param2); return; } finally { thread.interruptHandler = old; } } }
public <T, U, E extends Exception> void performConsumer(ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E, SystemException { final ContextTransactionManager tm = ContextTransactionManager.INSTANCE; if (Objects.equals(tm.getStateRef().get().transaction, this)) { consumer.accept(param1, param2); return; } try (SysExTry ignored = whileSuspended()) { try (SysExTry ignored2 = whileResumed(this)) { consumer.accept(param1, param2); } } }
public static <T, U, E extends Exception> void acceptInterruptResumedEx(final ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { consumer.accept(param1, param2); } finally { registerDeferral(thread); } else { // already resumed consumer.accept(param1, param2); } }
public static <T, U, E extends Exception> void acceptInterruptDeferredEx(final ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { consumer.accept(param1, param2); } finally { unregisterDeferral(thread); } else { // already deferred consumer.accept(param1, param2); } }
public <T, U, E extends Exception> void runAsConsumerEx(final ExceptionBiConsumer<T, U, E> action, final T parameter1, final U parameter2) throws E { final Supplier<SecurityIdentity> old = securityDomain.getAndSetCurrentSecurityIdentity(this); try { action.accept(parameter1, parameter2); } finally { securityDomain.setCurrentSecurityIdentity(old); } }
default ExceptionConsumer<T, E> andThen(ExceptionBiConsumer<? super T, ? super R, ? extends E> after) { Assert.checkNotNullParam("after", after); return t -> after.accept(t, apply(t)); }
/** * Accept security event to be processed by audit endpoints. * * @param event security event to be processed */ @Override public void accept(SecurityEvent event) { try { EventPriority priority = priorityMapper.apply(event); if (priority == EventPriority.OFF) return; String formatted = messageFormatter.apply(event); try { auditEndpoint.accept(priority, formatted); } catch (Throwable throwable) { audit.endpointUnavaiable(priority.toString(), formatted, throwable); } } catch (Throwable throwable) { audit.unableToAcceptEvent(throwable); } }
<E extends Exception> void emit(final ResolveContext<E> context, final ExceptionBiConsumer<ResolveContext<E>, StringBuilder, E> resolveFunction) throws E { ExpressionNode oldCurrent = context.setCurrent(this); try { resolveFunction.accept(context, context.getStringBuilder()); } finally { context.setCurrent(oldCurrent); } }
default ExceptionRunnable<E> compose(ExceptionSupplier<? extends T, ? extends E> before1, ExceptionSupplier<? extends U, ? extends E> before2) { Assert.checkNotNullParam("before1", before1); Assert.checkNotNullParam("before2", before2); return () -> accept(before1.get(), before2.get()); } }
/** * Run the given task with this contextual object selected. * * @param consumer the task to run (must not be {@code null}) * @param param1 the first parameter to pass to the task * @param param2 the second parameter to pass to the task * @param <T> the first parameter type * @param <U> the second parameter type * @param <E> the exception type * @throws E if an exception occurs in the task */ default <T, U, E extends Exception> void runExBiConsumer(ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E { final ContextManager<C> contextManager = getInstanceContextManager(); final C old = contextManager.getAndSetCurrent(this); try { consumer.accept(param1, param2); } finally { contextManager.restoreCurrent(old); } }
/** * Run an action under this identity. * * @param parameter1 the first parameter to pass to the action * @param parameter2 the second parameter to pass to the action * @param action the action to run * @param <T> the action first parameter type * @param <U> the action second parameter type * @param <E> the action exception type * @throws E if the action throws this exception */ public <T, U, E extends Exception> void runAsConsumerEx(ExceptionBiConsumer<T, U, E> action, T parameter1, U parameter2) throws E { if (action == null) return; final Supplier<SecurityIdentity>[] oldWithIdentities = establishIdentities(); final Supplier<SecurityIdentity> oldIdentity = securityDomain.getAndSetCurrentSecurityIdentity(this); try { action.accept(parameter1, parameter2); } finally { securityDomain.setCurrentSecurityIdentity(oldIdentity); restoreIdentities(oldWithIdentities); } }
public <T, U, E extends Exception> void performConsumer(ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E, SystemException { final ContextTransactionManager tm = ContextTransactionManager.INSTANCE; if (Objects.equals(tm.getStateRef().get().transaction, this)) { consumer.accept(param1, param2); return; } try (SysExTry ignored = whileSuspended()) { try (SysExTry ignored2 = whileResumed(this)) { consumer.accept(param1, param2); } } }
public static <T, U, E extends Exception> void acceptInterruptDeferredEx(final ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { consumer.accept(param1, param2); } finally { unregisterDeferral(thread); } else { // already deferred consumer.accept(param1, param2); } }
public <T, U, E extends Exception> void runAsConsumerEx(final ExceptionBiConsumer<T, U, E> action, final T parameter1, final U parameter2) throws E { final Supplier<SecurityIdentity> old = securityDomain.getAndSetCurrentSecurityIdentity(this); try { action.accept(parameter1, parameter2); } finally { securityDomain.setCurrentSecurityIdentity(old); } }
public <T, U, E extends Exception> void runAsConsumerEx(final ExceptionBiConsumer<T, U, E> action, final T parameter1, final U parameter2) throws E { final Supplier<SecurityIdentity> old = securityDomain.getAndSetCurrentSecurityIdentity(this); try { action.accept(parameter1, parameter2); } finally { securityDomain.setCurrentSecurityIdentity(old); } }
<E extends Exception> void emit(final ResolveContext<E> context, final ExceptionBiConsumer<ResolveContext<E>, StringBuilder, E> resolveFunction) throws E { ExpressionNode oldCurrent = context.setCurrent(this); try { resolveFunction.accept(context, context.getStringBuilder()); } finally { context.setCurrent(oldCurrent); } }