当前位置: 首页>>代码示例>>Java>>正文


Java TriggerInfo.setRepeatCount方法代码示例

本文整理汇总了Java中org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo.setRepeatCount方法的典型用法代码示例。如果您正苦于以下问题:Java TriggerInfo.setRepeatCount方法的具体用法?Java TriggerInfo.setRepeatCount怎么用?Java TriggerInfo.setRepeatCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo的用法示例。


在下文中一共展示了TriggerInfo.setRepeatCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入方法依赖的package包/类
public static TaskInfo convert(DSTaskInfo dsTaskInfo) {
	TriggerInfo triggerInfo = new TriggerInfo();
	triggerInfo.setCronExpression(dsTaskInfo.getCronExpression());
	if (dsTaskInfo.getStartTime() != null) {
	    triggerInfo.setStartTime(dsTaskInfo.getStartTime().getTime());
	}
	if (dsTaskInfo.getEndTime() != null) {
	    triggerInfo.setEndTime(dsTaskInfo.getEndTime().getTime());
	}
	triggerInfo.setIntervalMillis(dsTaskInfo.getTaskInterval());
	triggerInfo.setRepeatCount(dsTaskInfo.getTaskCount());
	Map<String, String> props = new HashMap<String, String>();
	if (dsTaskInfo.getDataTaskClassName() != null) {
	    props.put(DSTaskConstants.DATA_TASK_CLASS_NAME, dsTaskInfo.getDataTaskClassName());
           props.put(DSTaskConstants.TASK_NAME, dsTaskInfo.getName());
	    triggerInfo.setDisallowConcurrentExecution(true);
	    return new TaskInfo(
				dsTaskInfo.getName(), DSTaskExt.class.getName(), props, triggerInfo);
	} else {
	    props.put(DSTaskConstants.DATA_SERVICE_NAME, dsTaskInfo.getServiceName());
	    props.put(DSTaskConstants.DATA_SERVICE_OPERATION_NAME, dsTaskInfo.getOperationName());
	    props.put(WebServiceCallTask.SERVICE_ACTION, "urn:" + dsTaskInfo.getOperationName());
        return new TaskInfo(dsTaskInfo.getName(), DSTask.class.getName(), props, triggerInfo);
	}
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:26,代码来源:DSTaskUtils.java

示例2: updateTask

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入方法依赖的package包/类
@Override
public void updateTask(int monitoringFrequency) throws PolicyMonitoringTaskException {
    int tenantId = getTenantId();
    try {
        String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + String.valueOf(tenantId);
        TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService();
        TaskManager taskManager = taskService.getTaskManager(PolicyManagementConstants.MONITORING_TASK_TYPE);

        if (taskManager.isTaskScheduled(taskName)) {

            taskManager.deleteTask(taskName);
            TriggerInfo triggerInfo = new TriggerInfo();
            triggerInfo.setIntervalMillis(monitoringFrequency);
            triggerInfo.setRepeatCount(-1);

            Map<String, String> properties = new HashMap<>();
            properties.put("tenantId", String.valueOf(tenantId));

            TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.MONITORING_TASK_CLAZZ, properties,
                    triggerInfo);

            taskManager.registerTask(taskInfo);
            taskManager.rescheduleTask(taskInfo.getName());
        } else {
            throw new PolicyMonitoringTaskException("Monitoring task has not been started for this tenant " +
                    tenantId + ". Please start the task first.");
        }

    } catch (TaskException e) {
        throw new PolicyMonitoringTaskException("Error occurred while updating the task for tenant " + tenantId, e);
    }

}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:34,代码来源:TaskScheduleServiceImpl.java

示例3: startTask

import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; //导入方法依赖的package包/类
@Override
public void startTask(int monitoringFrequency) throws PolicyMonitoringTaskException {
    int tenantId = getTenantId();
    if (policyConfiguration.getMonitoringEnable()) {

        if (monitoringFrequency <= 0) {
            throw new PolicyMonitoringTaskException("Time interval cannot be 0 or less than 0.");
        }
        try {
            TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService();
            taskService.registerTaskType(PolicyManagementConstants.MONITORING_TASK_TYPE);

            if (log.isDebugEnabled()) {
                log.debug("Monitoring task is started for the tenant id " + tenantId);
            }

            TaskManager taskManager = taskService.getTaskManager(PolicyManagementConstants.MONITORING_TASK_TYPE);

            TriggerInfo triggerInfo = new TriggerInfo();
            triggerInfo.setIntervalMillis(monitoringFrequency);
            triggerInfo.setRepeatCount(-1);

            Map<String, String> properties = new HashMap<>();
            properties.put(PolicyManagementConstants.TENANT_ID, String.valueOf(tenantId));

            String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + String.valueOf(tenantId);

            if (!taskManager.isTaskScheduled(taskName)) {

                TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.MONITORING_TASK_CLAZZ,
                        properties, triggerInfo);

                taskManager.registerTask(taskInfo);
                taskManager.rescheduleTask(taskInfo.getName());
            } else {
                throw new PolicyMonitoringTaskException("Monitoring task is already started for this tenant " +
                        tenantId);
            }


        } catch (TaskException e) {
            throw new PolicyMonitoringTaskException("Error occurred while creating the task for tenant " +
                                                    tenantId, e);
        }
    } else {
        throw new PolicyMonitoringTaskException("Policy monitoring is not enabled in the cdm-config.xml.");
    }

}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:50,代码来源:TaskScheduleServiceImpl.java


注:本文中的org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo.setRepeatCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。