本文整理了Java中com.evolveum.midpoint.task.api.TaskManager.switchToBackground()
方法的一些代码示例,展示了TaskManager.switchToBackground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TaskManager.switchToBackground()
方法的具体详情如下:
包路径:com.evolveum.midpoint.task.api.TaskManager
类名称:TaskManager
方法名:switchToBackground
[英]Switches the provided task to background, making it asynchronous. The provided task will be "released" to other nodes to execute. There is no guarantee that the task will execute on the same node that called the switchToBackground() method.
[中]将提供的任务切换到后台,使其异步。提供的任务将“释放”给其他节点执行。无法保证任务将在调用switchToBackground()方法的同一节点上执行。
代码示例来源:origin: Evolveum/midpoint
public void evaluateExpressionInBackground(ExecuteScriptType executeScriptCommand, Task task, OperationResult parentResult) throws SchemaException {
if (!task.isTransient()) {
throw new IllegalStateException("Task must be transient");
}
if (task.getHandlerUri() != null) {
throw new IllegalStateException("Task must not have a handler");
}
OperationResult result = parentResult.createSubresult(DOT_CLASS + "evaluateExpressionInBackground");
task.setExtensionPropertyValue(SchemaConstants.SE_EXECUTE_SCRIPT, executeScriptCommand);
task.setHandlerUri(ModelPublicConstants.SCRIPT_EXECUTION_TASK_HANDLER_URI);
taskManager.switchToBackground(task, result);
result.computeStatus();
}
代码示例来源:origin: Evolveum/midpoint
private Task submitTask(WfTaskCreationInstruction instruction, Task parentTask, WfConfigurationType wfConfigurationType, String channelOverride, OperationResult result) throws SchemaException, ObjectNotFoundException {
Task wfTask = instruction.createTask(this, parentTask, wfConfigurationType);
if (channelOverride != null) {
wfTask.setChannel(channelOverride);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Switching workflow root or child task to background:\n{}", wfTask.debugDump());
}
taskManager.switchToBackground(wfTask, result);
return wfTask;
}
代码示例来源:origin: Evolveum/midpoint
taskManager.switchToBackground(task, result);
result.setBackgroundTaskOid(task.getOid());
代码示例来源:origin: Evolveum/midpoint
/**
* Creates and starts task with proper handler, also adds necessary information to task
* (like ReportType reference and so on).
*
* @param object
* @param task
* @param parentResult describes report which has to be created
*/
@Override
public void runReport(PrismObject<ReportType> object, PrismContainer<ReportParameterType> paramContainer, Task task, OperationResult parentResult) {
task.setHandlerUri(ReportCreateTaskHandler.REPORT_CREATE_TASK_URI);
task.setObjectRef(object.getOid(), ReportType.COMPLEX_TYPE);
try {
if (paramContainer != null && !paramContainer.isEmpty()){
task.setExtensionContainer(paramContainer);
}
} catch (SchemaException e) {
throw new SystemException(e);
}
task.setThreadStopAction(ThreadStopActionType.CLOSE);
task.makeSingle();
taskManager.switchToBackground(task, parentResult);
parentResult.setBackgroundTaskOid(task.getOid());
}
/**
代码示例来源:origin: Evolveum/midpoint
taskManager.switchToBackground(task, result);
result.setBackgroundTaskOid(task.getOid());
result.computeStatus("Reconciliation launch failed");
代码示例来源:origin: Evolveum/midpoint
taskManager.switchToBackground(task, result);
result.setBackgroundTaskOid(task.getOid());
result.computeStatus("Import launch failed");
代码示例来源:origin: Evolveum/midpoint
public void launch(AccessCertificationCampaignType campaign, OperationResult parentResult) throws SchemaException, ObjectNotFoundException {
LOGGER.debug("Launching closing task handler for campaign {} as asynchronous task", toShortString(campaign));
OperationResult result = parentResult.createSubresult(CLASS_DOT + "launch");
result.addParam("campaignOid", campaign.getOid());
Task task = taskManager.createTaskInstance();
task.setHandlerUri(HANDLER_URI);
task.setName(new PolyStringType("Closing " + campaign.getName()));
task.setObjectRef(ObjectTypeUtil.createObjectRef(campaign, prismContext));
task.setOwner(repositoryService.getObject(UserType.class, SystemObjectsType.USER_ADMINISTRATOR.value(), null, result));
taskManager.switchToBackground(task, result);
result.setBackgroundTaskOid(task.getOid());
if (result.isInProgress()) {
result.recordStatus(OperationResultStatus.IN_PROGRESS, "Closing task "+task+" was successfully started, please use Server Tasks to see its status.");
}
LOGGER.trace("Closing task for {} switched to background, control thread returning with task {}", toShortString(campaign), task);
}
代码示例来源:origin: Evolveum/midpoint
public void launch(AccessCertificationCampaignType campaign, OperationResult parentResult) throws SchemaException, ObjectNotFoundException {
LOGGER.info("Launching remediation task handler for campaign {} as asynchronous task", ObjectTypeUtil.toShortString(campaign));
OperationResult result = parentResult.createSubresult(CLASS_DOT + "launch");
result.addParam("campaignOid", campaign.getOid());
Task task = taskManager.createTaskInstance();
// Set handler URI so we will be called back
task.setHandlerUri(HANDLER_URI);
// Readable task name
PolyStringType polyString = new PolyStringType("Remediation for " + campaign.getName());
task.setName(polyString);
// Set reference to the resource
task.setObjectRef(ObjectTypeUtil.createObjectRef(campaign, prismContext));
task.setOwner(repositoryService.getObject(UserType.class, SystemObjectsType.USER_ADMINISTRATOR.value(), null, result));
taskManager.switchToBackground(task, result);
result.setBackgroundTaskOid(task.getOid());
if (result.isInProgress()) {
result.recordStatus(OperationResultStatus.IN_PROGRESS, "Remediation task "+task+" was successfully started, please use Server Tasks to see its status.");
}
LOGGER.trace("Remediation for {} switched to background, control thread returning with task {}", ObjectTypeUtil.toShortString(campaign), task);
}
代码示例来源:origin: Evolveum/midpoint
reconTask.setHandlerUri(RecomputeTaskHandler.HANDLER_URI);
reconTask.setCategory(TaskCategory.RECOMPUTATION);
taskManager.switchToBackground(reconTask, result);
result.setBackgroundTaskOid(reconTask.getOid());
result.recordStatus(OperationResultStatus.IN_PROGRESS, "Reconciliation task switched to background");
代码示例来源:origin: Evolveum/midpoint
@Test
public void test507ScriptingUsersInBackgroundAssign() throws Exception {
final String TEST_NAME = "test507ScriptingUsersInBackgroundAssign";
TestUtil.displayTestTitle(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
task.setOwner(getUser(USER_ADMINISTRATOR_OID));
OperationResult result = task.getResult();
ExecuteScriptType exec = prismContext.parserFor(SCRIPTING_USERS_IN_BACKGROUND_ASSIGN_FILE).parseRealValue();
// WHEN
task.setExtensionPropertyValue(SchemaConstants.SE_EXECUTE_SCRIPT, exec);
task.setHandlerUri(ModelPublicConstants.SCRIPT_EXECUTION_TASK_HANDLER_URI);
dummyTransport.clearMessages();
boolean notificationsDisabled = notificationManager.isDisabled();
notificationManager.setDisabled(false);
taskManager.switchToBackground(task, result);
waitForTaskFinish(task.getOid(), false);
task.refresh(result);
// THEN
display(task.getResult());
TestUtil.assertSuccess(task.getResult());
PrismObject<UserType> admin = getUser(USER_ADMINISTRATOR_OID);
display("admin after operation", admin);
assertAssignedRole(admin, ROLE_EMPTY_OID);
display("dummy transport", dummyTransport);
notificationManager.setDisabled(notificationsDisabled);
assertEquals("Wrong # of messages in dummy transport", 1,
emptyIfNull(dummyTransport.getMessages("dummy:simpleUserNotifier")).size());
}
代码示例来源:origin: Evolveum/midpoint
notificationManager.setDisabled(false);
taskManager.switchToBackground(task, result);
内容来源于网络,如有侵权,请联系作者删除!