All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alogic.timer.service.SchedulerReport Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.alogic.timer.service;

import java.util.HashMap;
import java.util.Map;

import com.logicbus.backend.message.YamlMessage;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.alogic.timer.core.Scheduler;
import com.alogic.timer.core.SchedulerFactory;
import com.logicbus.backend.AbstractServant;
import com.logicbus.backend.Context;
import com.logicbus.backend.ServantException;
import com.logicbus.backend.message.JsonMessage;
import com.logicbus.backend.message.XMLMessage;
import com.logicbus.models.servant.ServiceDescription;

/**
 * 调度者报告
 * 
 * @author duanyy
 * @since 1.6.3.37
 *
 * @version 1.6.12.27 [20190403 duanyy] 
* - 增加对yaml的支持
*/ public class SchedulerReport extends AbstractServant { @Override protected void onDestroy() { } @Override protected void onCreate(ServiceDescription sd) { } protected int onXml(Context ctx) { XMLMessage msg = (XMLMessage) ctx.asMessage(XMLMessage.class); Scheduler scheduler = SchedulerFactory.get(); if (scheduler == null){ throw new ServantException("core.e1003","Can not find a valid scheduler"); } Document doc = msg.getDocument(); Element _scheduler = doc.createElement("scheduler"); scheduler.report(_scheduler); msg.getRoot().appendChild(_scheduler); return 0; } protected int onJson(Context ctx) { JsonMessage msg = (JsonMessage)ctx.asMessage(JsonMessage.class); Scheduler scheduler = SchedulerFactory.get(); if (scheduler == null){ throw new ServantException("core.e1003","Can not find a valid scheduler"); } Map _scheduler = new HashMap(); scheduler.report(_scheduler); msg.getRoot().put("scheduler", _scheduler); return 0; } protected int onYaml(Context ctx) { YamlMessage msg = (YamlMessage)ctx.asMessage(YamlMessage.class); Scheduler scheduler = SchedulerFactory.get(); if (scheduler == null){ throw new ServantException("core.e1003","Can not find a valid scheduler"); } Map _scheduler = new HashMap(); scheduler.report(_scheduler); msg.getRoot().put("scheduler", _scheduler); return 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy