com.logicbus.service.ServiceList Maven / Gradle / Ivy
package com.logicbus.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import com.anysoft.util.Settings;
import com.logicbus.backend.AbstractServant;
import com.logicbus.backend.Context;
import com.logicbus.backend.ServantFactory;
import com.logicbus.backend.ServantRegistry;
import com.logicbus.backend.message.JsonMessage;
import com.logicbus.backend.message.XMLMessage;
import com.logicbus.models.catalog.CatalogNode;
import com.logicbus.models.servant.ServantCatalog;
import com.logicbus.models.servant.ServantCatalogNode;
import com.logicbus.models.servant.ServiceDescription;
/**
* 查询服务列表
*
* @author duanyy
* @since 1.6.4.4
* @version 1.6.7.20
* - 改造ServantManager模型,增加服务配置监控机制
*/
public class ServiceList extends AbstractServant {
@Override
protected void onDestroy() {
// nothing to do
}
@Override
protected void onCreate(ServiceDescription sd){
// nothing to do
}
protected int onXml(Context ctx){
XMLMessage msg = (XMLMessage)ctx.asMessage(XMLMessage.class);
Element root = msg.getRoot();
Document doc = root.getOwnerDocument();
Settings settings = Settings.get();
ServantFactory sf = (ServantFactory)settings.get("servantFactory");
ServantRegistry sm = sf.getServantRegistry();
ServantCatalog [] catalog = sm.getServantCatalog();
Element services = doc.createElement("service"); // NOSONAR
for (int i = 0 ; i < catalog.length ; i ++){
ServantCatalogNode node = (ServantCatalogNode) catalog[i].getRoot();
if (node != null){
outputCatalog(catalog[i],node,services);
}
}
root.appendChild(services);
return 0;
}
protected int onJson(Context ctx){
JsonMessage msg = (JsonMessage)ctx.asMessage(JsonMessage.class);
Settings settings = Settings.get();
ServantFactory sf = (ServantFactory)settings.get("servantFactory");
ServantRegistry sm = sf.getServantRegistry();
ServantCatalog [] catalog = sm.getServantCatalog();
List