/*
(non-Javadoc)
@see org.jboss.arquillian.warp.impl.client.execution.WarpExecutor#execute(org.jboss.arquillian.warp.Activity, org.jboss.arquillian.warp.impl.client.execution.WarpContext)
483691
@Override
    public WarpResult execute(Activity activity, WarpContext warpContext) {
        try {
            setupServerInspection();
            executeActivity(activity);
            awaitServerExecution(warpContext);
            checkActivityFailure();

            return warpContext.getResult();
        } finally {
            cleanup();
        }
    }
248262
public Resolution intercept(ExecutionContext executionContext) throws Exception {
        // Remove expired contexts.
        removeExpired(contexts);
        
        // Get wait context, if any.
        Context context = getContext(executionContext);
        LifecycleStage stage = executionContext.getLifecycleStage();
        
        if (executionContext.getActionBeanContext().getRequest().getRequestURI().contains(THREAD_URL)) {
            // The request we are processing is the one used to invoke event handler in background and to get resolution to send to user when event completes.
            // Since we are going to invoke the real event, the action bean and event must stay the same.
            // Binding and validation must be skipped since they were done in the first request.
            switch (executionContext.getLifecycleStage()) {
                // Use action bean that will process event.
                case ActionBeanResolution:
                    log.trace("injecting ActionBean");
                    // Since session can be lost from original request (Tomcat is a good example), request must be updated with the background request.
                    context.actionBean.setContext(executionContext.getActionBeanContext());
                    executionContext.setActionBean(context.actionBean);
                    // Skip normal action bean resolution.
                    return null;
                // Select event to call.
                case HandlerResolution:
                    log.trace("injecting event handler");
                    executionContext.setHandler(context.eventHandler);
                    // Skip normal handler resolution.
                    return null;
                // No biding or validation, it was done before a background request was created to handle event.
                case BindingAndValidation:
                case CustomValidation:
                    log.trace("skipping binding and validation");
                    // Skip binding and validation.
                    return null;
                // Execute event since we are in the background request.
                case EventHandling:
                    log.trace("executing event handler");
                    // Execute event and save exception if any.
                    try {
                        return executionContext.proceed();
                    }
                    catch (Exception e) {
                        synchronized(context.actionBean)
                        {
                            log.trace("setting exception in context");
                            context.throwable = e;
                            context.status = Context.Status.COMPLETE;
                            context.completeMoment = System.currentTimeMillis();
                            context.actionBean.notifyAll();
                            context.eventFlashScope = FlashScope.getCurrent(context.actionBean.getContext().getRequest(), false);
                        }
                        throw e;
                    }
                // Save resolution to send to user when he will refresh wait page.
                case ResolutionExecution:
                    synchronized(context.actionBean)
                    {
                        log.trace("setting resolution in context");
                        context.resolution = executionContext.getResolution();
                        context.status = Context.Status.COMPLETE;
                        context.completeMoment = System.currentTimeMillis();
                        context.actionBean.notifyAll();
                        context.eventFlashScope = FlashScope.getCurrent(context.actionBean.getContext().getRequest(), false);
                    }
                    
                    // Use a default resolution to prevent processing the one event returned.
                    executionContext.setResolution(new StreamingResolution("text/plain", "thread complete"));
                    return executionContext.proceed();
                case RequestInit:
                case RequestComplete:
                    return executionContext.proceed();
            }
        }
        else {
            if (LifecycleStage.ActionBeanResolution.equals(stage)) {
                if (context != null) {
                    // We are using a wait context for this request. Go to wait page or event's resolution depending on status and skip everything else.
                    return checkStatus(executionContext, context);
                }
            }
            else if (LifecycleStage.EventHandling.equals(stage)) {
                WaitPage annotation = executionContext.getHandler().getAnnotation(WaitPage.class);
                if (annotation != null) {
                    // Event has @WaitPage annotation. Create wait context to invoke event in background and redirect user to wait page.
                    return createContextAndRedirect(executionContext, annotation);
                }
            }
        }
        
        return executionContext.proceed();
    }
1063312
@Override
   public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
       if (context.isNormalServer()) {
           ModelNode operationResult;
           try {
              operationResult = invokeCommand(getEmbeddedCacheManager(context, operation), context, operation);
           } catch (Exception e) {
              throw new OperationFailedException(MESSAGES.failedToInvokeOperation(e.getLocalizedMessage()), e);
           }
           if (operationResult != null) {
              context.getResult().set(operationResult);
           }
       }
   }
344315
@SuppressWarnings("unchecked")
    @Override
    public Boolean execute() {
        try {
            api.createNPC(username, 
                    SmartFoxServer.getInstance()
                        .getZoneManager().getZoneByName(zone), 
                    forceLogin);
        } catch (SFSLoginException e) {
            throw new IllegalStateException(e);
        }
        return Boolean.TRUE;
    }
90610
@Override
    public void execute() throws MojoExecutionException {
        try {
            ensureNotExisting();
            createDirectories();

            if ("blank".equalsIgnoreCase(skel)) {
                createApplicationConfiguration();
                createBlankPomFile();
                createPackageStructure();
                copyDefaultErrorTemplates();
            } else {
                createApplicationConfiguration();
                createPomFile();
                createPackageStructure();
                createDefaultController();
                createTests();
                copyAssets();
                createWelcomeTemplate();
                copyDefaultErrorTemplates();
            }

            printStartGuide();
        } catch (IOException e) {
            throw new MojoExecutionException("Error during project generation", e);
        }
    }
1037738
@Override
  public void execute(final ActivityExecution execution) throws Exception {
    this.executeWithErrorPropagation(execution, new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        getActivityBehaviorInstance(execution).execute(execution);
        return null;
      }
    });
  }
379374
@Override
	public Element execute(Context context) {

		assert (ops.length == 2 || ops.length == 3);

		// Pop the condition from the data stack.
		boolean condition = false;
		try {
			condition = ((BooleanProperty) ops[0].execute(context)).getValue();
		} catch (ClassCastException cce) {
			throw new EvaluationException(MessageUtils
					.format(MSG_INVALID_IF_ELSE_TEST), sourceRange);
		}

		// Choose the correct operation and execute it.
		Operation op = null;
		if (condition) {
			op = ops[1];
		} else if (ops.length > 2) {
			op = ops[2];
		} else {
			op = Undef.VALUE;
		}
		return op.execute(context);
	}
1178511
@Override
    public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

        nameValidator.validate(operation);
        final String newAlias = operation.require(NAME).asString();
        final ModelNode submodel = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel();
        final ModelNode currentValue = submodel.get(CacheContainerResource.ALIASES.getName()).clone();

        ModelNode newValue = addNewAliasToList(currentValue, newAlias) ;

        // now set the new ALIAS attribute
        final ModelNode syntheticOp = new ModelNode();
        syntheticOp.get(CacheContainerResource.ALIASES.getName()).set(newValue);
        CacheContainerResource.ALIASES.validateAndSet(syntheticOp, submodel);

        // since we modified the model, set reload required
        if (requiresRuntime(context)) {
            context.addStep((context1, operation1) -> {
                context1.reloadRequired();
                context1.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
            }, OperationContext.Stage.RUNTIME);
        }
    }
182127
public void execute(AbstractWisdomMojo mojo) throws MojoExecutionException {
        String version = PluginExtractor.getBuildPluginVersion(mojo, MAVEN_COMPILER_PLUGIN);
        if (version == null) {
            version = DEFAULT_VERSION;
        }
        final Plugin plugin = plugin(
                GROUP_ID,
                MAVEN_COMPILER_PLUGIN,
                version
        );

        Xpp3Dom configuration = PluginExtractor.getBuildPluginConfiguration(mojo, MAVEN_COMPILER_PLUGIN, COMPILE_GOAL);
        if (configuration == null) {
            Properties properties = mojo.project.getProperties();
            String source = properties.getProperty("maven.compiler.source", "1.7");
            String target = properties.getProperty("maven.compiler.target", "1.7");
            configuration = configuration(
                    element("compileSourceRoots", "${project.compileSourceRoots}"),
                    element("classpathElements", "${project.compileClasspathElements}"),
                    element("outputDirectory", "${project.build.outputDirectory}"),
                    element("projectArtifact", "${project.artifact}"),
                    element("generatedSourcesDirectory",
                            "${project.build.directory}/generated-sources/annotations"),
                    element("target", source),
                    element("source", target)
            );
        } else {
            mojo.getLog().debug("Loading maven-compiler-plugin configuration:");
            PluginExtractor.extractEligibleConfigurationForGoal(mojo, plugin, COMPILE_GOAL, configuration);
            mojo.getLog().debug(configuration.toString());

        }

        // Compile sources
        executeMojo(
                plugin,
                goal(COMPILE_GOAL),
                configuration,
                executionEnvironment(
                        mojo.project,
                        mojo.session,
                        mojo.pluginManager
                )
        );
    }
476710
public void execute(Context aContext) {
        this.context = aContext;

        context.start();
        Date startTime = new Date();
        context.getFileManager().logInfo(String.format("java4cpp version %s, starting at %s", Context.class.getPackage().getImplementationVersion(), startTime));

        analyzeModels();
        resolveTypeTemplates();
        generateSources();
        finalization();

        context.getFileManager().logInfo(String.format("elapsed time: %.3fs", (new Date().getTime() - startTime.getTime()) / MILLISEC));
        context.stop();
    }
752779
private OperationResponse executeForResult(final OperationExecutionContext executionContext) throws IOException {
        try {
            return execute(executionContext).get();
        } catch(Exception e) {
            throw new IOException(e);
        }
    }
104529
@Override
    public CompletableFuture<RootExecutionResultNode> execute(ExecutionContext context, FieldSubSelection fieldSubSelection) {
        return resolveSubSelection(context, fieldSubSelection)
                .thenApply(RootExecutionResultNode::new);
    }
729959
@Override
	public Vector execute(TypedVector<ActivityInfo> infos) throws ActivityException {

		if(infos != null && !infos.isEmpty()) {
			logger.trace("executing {} activities...", infos.size());
			int i = 0;
			TypedVector<Future<ActivityData>> futures = new TypedVector<Future<ActivityData>>();
			for(ActivityInfo info : infos) {
				ActivityCallable callable = new ActivityCallable(i++, queue, info);
				futures.add(submit(callable));
			}
			return wait(futures);
		} else {
			logger.warn("no activities to execute");
		}
		return null;
	}
458740
public void execute(NodeTaskContext context) {
    NodeTaskReporter taskReporter = new NodeTaskReporter(this);
    taskQueue = new ArrayDeque<>(tasks);
    if (!taskQueue.isEmpty()) {
      NodeTask task = taskQueue.poll();
      task.execute(context, taskReporter);
    }
    else { // if the queue is empty, reports that the pipeline execution was a success
      listener.onSuccess();
    }
  }
745172
@Override
    public void execute() throws TaskExecutionFailedException {
        if (AuditTask.ActionType.CREATE_SPACE.name().equals(task.getAction())) {
            String account = task.getAccount();
            log.info("new space audit task received for account {} received: {}", account, task);
            String storeId = task.getStoreId();
            String spaceId = task.getSpaceId();
            log.warn("New space notification: subdomain: {}, storeId: {}, spaceId: {}: ",
                     account, storeId, spaceId);

            newSpace(account,
                     task.getStoreId(),
                     task.getSpaceId(),
                     task.getDateTime(),
                     task.getUserId());
        } else {
            log.debug("This task {} is not a space creation task: it will be ignored.", task);
        }
    }
1146958
public WorkflowContext execute(WorkflowContext context) throws WorkflowException {
		if (context instanceof MapModelWorkflowContext) {
			MapModelWorkflowContext mmContext = (MapModelWorkflowContext) context;
			FeatureTransaction ft = mmContext.getFeatureTransaction();
			if (ft.getNewFeatures() != null) {
				for (Feature feature : ft.getNewFeatures()) {
					if (!feature.getGeometry().isValid()) {
						throw new WorkflowException(I18nProvider.getGlobal().validationActivityError());
					}
				}
			}
		}
		return context;
	}
782995
protected void executeActions(TestContext context) {
        context.setVariable(indexName, String.valueOf(index));

        for (TestAction action: actions) {
            setActiveAction(action);
            action.execute(context);
        }
    }