use of javax.enterprise.concurrent.ManagedTask in project wildfly by wildfly.
the class ControlPointUtils method doWrap.
public static <T> Callable<T> doWrap(Callable<T> callable, ControlPoint controlPoint) {
if (controlPoint == null || callable == null) {
return callable;
}
try {
controlPoint.forceBeginRequest();
final ControlledCallable controlledCallable = new ControlledCallable(callable, controlPoint);
return callable instanceof ManagedTask ? new ControlledManagedCallable(controlledCallable, (ManagedTask) callable) : controlledCallable;
} catch (Exception e) {
throw new RejectedExecutionException(e);
}
}
use of javax.enterprise.concurrent.ManagedTask in project wildfly by wildfly.
the class SecurityIdentityUtils method doIdentityWrap.
static <T> Callable<T> doIdentityWrap(final Callable<T> callable) {
if (callable == null) {
return null;
}
final SecurityIdentity securityIdentity = getSecurityIdentity();
if (securityIdentity == null) {
return callable;
}
Callable<T> securedCallable = () -> securityIdentity.runAs(callable);
return callable instanceof ManagedTask ? new SecuredManagedCallable<T>(securedCallable, (ManagedTask) callable) : securedCallable;
}
use of javax.enterprise.concurrent.ManagedTask in project wildfly by wildfly.
the class ControlPointUtils method doWrap.
public static Runnable doWrap(Runnable runnable, ControlPoint controlPoint) {
if (controlPoint == null || runnable == null) {
return runnable;
}
try {
controlPoint.forceBeginRequest();
final ControlledRunnable controlledRunnable = new ControlledRunnable(runnable, controlPoint);
return runnable instanceof ManagedTask ? new ControlledManagedRunnable(controlledRunnable, (ManagedTask) runnable) : controlledRunnable;
} catch (Exception e) {
throw new RejectedExecutionException(e);
}
}
use of javax.enterprise.concurrent.ManagedTask in project wildfly by wildfly.
the class SecurityIdentityUtils method doIdentityWrap.
static Runnable doIdentityWrap(final Runnable runnable) {
if (runnable == null) {
return null;
}
final SecurityIdentity securityIdentity = getSecurityIdentity();
if (securityIdentity == null) {
return runnable;
}
Runnable securedRunnable = () -> securityIdentity.runAs(runnable);
return runnable instanceof ManagedTask ? new SecuredManagedRunnable(securedRunnable, (ManagedTask) runnable) : securedRunnable;
}
Aggregations