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

com.alogic.blob.service.BlobReport Maven / Gradle / Ivy

package com.alogic.blob.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.blob.BlobManager;
import com.alogic.blob.naming.BlobManagerFactory;
import com.logicbus.backend.AbstractServant;
import com.logicbus.backend.Context;
import com.logicbus.backend.message.JsonMessage;
import com.logicbus.backend.message.XMLMessage;
import com.logicbus.models.servant.ServiceDescription;

/**
 * BlobReport,生成Blob使用情况报告
 * 
 * @author duanyy
 * @since 1.6.3.28
 * 
 * @version 1.6.4.18 [duanyy 20151218] 
* - 增加自动图标集
* * @version 1.6.12.27 [20190403 duanyy]
* - 增加对yaml的支持
*/ public class BlobReport extends AbstractServant { @Override protected void onDestroy() { // Nothing to do } @Override protected void onCreate(ServiceDescription sd) { // Nothing to do } @Override protected int onXml(Context ctx){ XMLMessage msg = (XMLMessage) ctx.asMessage(XMLMessage.class); Element root = msg.getRoot(); Document doc = msg.getDocument(); String id = getArgument("id","all", ctx); if (id == null || id.length() <= 0 || "all".equals(id)){ Element source = doc.createElement("source"); BlobManagerFactory f = BlobManagerFactory.get(); f.report(source); root.appendChild(source); }else{ Element blob = doc.createElement("blob"); BlobManager manager = BlobManagerFactory.get(id); if (manager != null){ manager.report(blob); } root.appendChild(blob); } return 0; } @Override protected int onJson(Context ctx) { JsonMessage msg = (JsonMessage) ctx.asMessage(JsonMessage.class); Map root = msg.getRoot(); String id = getArgument("id","all", ctx); if (id == null || id.length() <= 0 || "all".equals(id)){ Map source = new HashMap(); // NOSONAR BlobManagerFactory f = BlobManagerFactory.get(); f.report(source); root.put("source", source); }else{ Map blob = new HashMap(); // NOSONAR BlobManager manager = BlobManagerFactory.get(id); if (manager != null){ manager.report(blob); } root.put("blob", blob); } return 0; } @Override protected int onYaml(Context ctx) { YamlMessage msg = (YamlMessage) ctx.asMessage(YamlMessage.class); Map root = msg.getRoot(); String id = getArgument("id","all", ctx); if (id == null || id.length() <= 0 || "all".equals(id)){ Map source = new HashMap(); // NOSONAR BlobManagerFactory f = BlobManagerFactory.get(); f.report(source); root.put("source", source); }else{ Map blob = new HashMap(); // NOSONAR BlobManager manager = BlobManagerFactory.get(id); if (manager != null){ manager.report(blob); } root.put("blob", blob); } return 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy