@Override public OperationResponse apply(DomainModelControllerService controllerService) { return InVmAccess.runInVm((PrivilegedAction<OperationResponse>) () -> controllerService.internalExecute(operation, handler, control, step)); } };
@Override public boolean isInVmCall() { return InVmAccess.isInVmCall(); } };
/** * Is the current call an in-vm call? * * @return {@code true} if the current call is an in-vm call, {@code false} otherwise. */ public static boolean isInVmCall() { checkPermission(GET_IN_VM_CALL_STATE); return IN_VM_CALL.get(); }
/** * Is the current call an in-vm call? * * @return {@code true} if the current call is an in-vm call, {@code false} otherwise. */ public static boolean isInVmCall() { checkPermission(GET_IN_VM_CALL_STATE); return IN_VM_CALL.get(); }
@Override public OperationResponse apply(DomainModelControllerService controllerService) { return InVmAccess.runInVm((PrivilegedAction<OperationResponse>) () -> controllerService.internalExecute(operation, handler, control, step, true)); } };
@Override public boolean isInVmCall() { return InVmAccess.isInVmCall(); } };
/** * Run an action as an in-vm action. * * @param action the action to run * @param <T> the action return type * @return the action result (may be {@code null}) */ public static <T> T runInVm(PrivilegedAction<T> action) { checkPermission(PERFORM_IN_VM_CALL); if (action == null) return null; Boolean originalValue = IN_VM_CALL.get(); try { IN_VM_CALL.set(Boolean.TRUE); return action.run(); } finally { IN_VM_CALL.set(originalValue); } }
@Override public OperationResponse apply(DomainModelControllerService controllerService) { return InVmAccess.runInVm((PrivilegedAction<OperationResponse>) () -> controllerService.internalExecute(operation, handler, control, step)); } };
@Override public boolean isInVmCall() { return InVmAccess.isInVmCall(); } };
/** * Run an action as an in-vm action. * * @param action the action to run * @param <T> the action return type * @return the action result (may be {@code null}) */ public static <T> T runInVm(PrivilegedAction<T> action) { checkPermission(PERFORM_IN_VM_CALL); if (action == null) return null; Boolean originalValue = IN_VM_CALL.get(); try { IN_VM_CALL.set(Boolean.TRUE); return action.run(); } finally { IN_VM_CALL.set(originalValue); } }
@Override public ModelNode apply(DomainModelControllerService controllerService) { return InVmAccess.runInVm((PrivilegedAction<ModelNode>) () -> controllerService.executeReadOnlyOperation(operation, handler, control, step, permit)); } };
@Override public boolean isInVmCall() { return InVmAccess.isInVmCall(); } };
/** * Run an action as an in-vm action. * * @param action the action to run * @param <T> the action return type * @return the action result (may be {@code null}) * @throws PrivilegedActionException if the action fails */ public static <T> T runInVm(PrivilegedExceptionAction<T> action) throws PrivilegedActionException { checkPermission(PERFORM_IN_VM_CALL); if (action == null) return null; Boolean originalValue = IN_VM_CALL.get(); try { IN_VM_CALL.set(Boolean.TRUE); return action.run(); } catch (RuntimeException | PrivilegedActionException e) { throw e; } catch (Exception e) { throw new PrivilegedActionException(e); } finally { IN_VM_CALL.set(originalValue); } }
@Override public ModelNode apply(DomainModelControllerService controllerService) { return InVmAccess.runInVm((PrivilegedAction<ModelNode>) () -> controllerService.executeReadOnlyOperation(operation, control, handler)); } };
@Override public <T extends Operation> AsyncFuture<OperationResponse> execute(TransactionalOperationListener<T> listener, T operation) throws IOException { AccessAuditContext accessAuditContext = WildFlySecurityManager.isChecking() ? doPrivileged((PrivilegedAction<AccessAuditContext>) AccessAuditContext::currentAccessAuditContext) : AccessAuditContext.currentAccessAuditContext(); final ExecuteRequestContext context = new ExecuteRequestContext(new OperationWrapper<>(listener, operation), accessAuditContext != null ? accessAuditContext.getSecurityIdentity() : null, accessAuditContext != null ? accessAuditContext.getRemoteAddress() : null, tempDir, InVmAccess.isInVmCall()); final ActiveOperation<OperationResponse, ExecuteRequestContext> op = channelAssociation.initializeOperation(context, context); final AtomicBoolean cancelSent = new AtomicBoolean(); final AsyncFuture<OperationResponse> result = new AbstractDelegatingAsyncFuture<OperationResponse>(op.getResult()) { @Override public synchronized void asyncCancel(boolean interruptionDesired) { if (!cancelSent.get()) { try { // Execute channelAssociation.executeRequest(op, new CompleteTxRequest(ModelControllerProtocol.PARAM_ROLLBACK, channelAssociation)); cancelSent.set(true); } catch (IOException e) { throw new RuntimeException(e); } } } }; context.initialize(result); channelAssociation.executeRequest(op, new ExecuteRequest()); return result; }
/** * Run an action as an in-vm action. * * @param action the action to run * @param <T> the action return type * @return the action result (may be {@code null}) * @throws PrivilegedActionException if the action fails */ public static <T> T runInVm(PrivilegedExceptionAction<T> action) throws PrivilegedActionException { checkPermission(PERFORM_IN_VM_CALL); if (action == null) return null; Boolean originalValue = IN_VM_CALL.get(); try { IN_VM_CALL.set(Boolean.TRUE); return action.run(); } catch (RuntimeException | PrivilegedActionException e) { throw e; } catch (Exception e) { throw new PrivilegedActionException(e); } finally { IN_VM_CALL.set(originalValue); } }
@Override public OperationResponse apply(DomainModelControllerService controllerService) { return InVmAccess.runInVm((PrivilegedAction<OperationResponse>) () -> controllerService.internalExecute(operation, OperationMessageHandler.logging, OperationTransactionControl.COMMIT, stepHandler, false, true)); } };
@Override public <T extends Operation> AsyncFuture<OperationResponse> execute(TransactionalOperationListener<T> listener, T operation) throws IOException { AccessAuditContext accessAuditContext = WildFlySecurityManager.isChecking() ? doPrivileged((PrivilegedAction<AccessAuditContext>) AccessAuditContext::currentAccessAuditContext) : AccessAuditContext.currentAccessAuditContext(); final ExecuteRequestContext context = new ExecuteRequestContext(new OperationWrapper<>(listener, operation), accessAuditContext != null ? accessAuditContext.getSecurityIdentity() : null, accessAuditContext != null ? accessAuditContext.getRemoteAddress() : null, tempDir, InVmAccess.isInVmCall()); final ActiveOperation<OperationResponse, ExecuteRequestContext> op = channelAssociation.initializeOperation(context, context); final AtomicBoolean cancelSent = new AtomicBoolean(); final AsyncFuture<OperationResponse> result = new AbstractDelegatingAsyncFuture<OperationResponse>(op.getResult()) { @Override public synchronized void asyncCancel(boolean interruptionDesired) { if (!cancelSent.get()) { try { // Execute channelAssociation.executeRequest(op, new CompleteTxRequest(ModelControllerProtocol.PARAM_ROLLBACK, channelAssociation)); cancelSent.set(true); } catch (IOException e) { throw new RuntimeException(e); } } } }; context.initialize(result); channelAssociation.executeRequest(op, new ExecuteRequest()); return result; }
@Override public ModelNode apply(DomainModelControllerService controllerService) { return InVmAccess.runInVm((PrivilegedAction<ModelNode>) () -> controllerService.executeReadOnlyOperation(operation, model, control, handler)); } };
@Override public ModelNode apply(DomainModelControllerService controllerService) { return InVmAccess.runInVm((PrivilegedAction<ModelNode>) () -> controllerService.executeReadOnlyOperation(operation, model, control, handler)); } };