Search in sources :

Example 1 with ManagedTask

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);
    }
}
Also used : RejectedExecutionException(java.util.concurrent.RejectedExecutionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ManagedTask(javax.enterprise.concurrent.ManagedTask)

Example 2 with ManagedTask

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;
}
Also used : SecurityIdentity(org.wildfly.security.auth.server.SecurityIdentity) ManagedTask(javax.enterprise.concurrent.ManagedTask)

Example 3 with ManagedTask

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);
    }
}
Also used : RejectedExecutionException(java.util.concurrent.RejectedExecutionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ManagedTask(javax.enterprise.concurrent.ManagedTask)

Example 4 with ManagedTask

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;
}
Also used : SecurityIdentity(org.wildfly.security.auth.server.SecurityIdentity) ManagedTask(javax.enterprise.concurrent.ManagedTask)

Aggregations

ManagedTask (javax.enterprise.concurrent.ManagedTask)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 SecurityIdentity (org.wildfly.security.auth.server.SecurityIdentity)2