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

com.logicbus.service.AreYouAlive Maven / Gradle / Ivy

There is a newer version: 1.6.16
Show newest version
package com.logicbus.service;

import java.util.Map;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
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;

/**
 * Are you alive?
 * 
 * 
* 一个小小的测试服务,定义在/com/logicbus/service/servant.xml中,具体配置如下:
* * {@code * * } * *
* 如果配置在服务器中,访问地址为:
* {@code * http://[host]:[port]/[webcontext]/services/demo/logicbus/AreYouAlive * } * * @author duanyy * @version 1.4.0 [20141117 duanyy]
* - 将MessageDoc和Context进行合并整合
* * @version 1.6.3.27 [20150623 duanyy]
* - 增加XML和JSON双协议支持 * */ public class AreYouAlive extends AbstractServant { @Override protected void onDestroy() { } @Override protected void onCreate(ServiceDescription sd) { } protected int onXml(Context ctx) { XMLMessage msg = (XMLMessage)ctx.asMessage(XMLMessage.class); Element root = msg.getRoot(); Document doc = root.getOwnerDocument(); root.appendChild(doc.createTextNode("Ok,i am alive.")); return 0; } protected int onJson(Context ctx){ JsonMessage msg = (JsonMessage)ctx.asMessage(JsonMessage.class); Map root = msg.getRoot(); root.put("msg", "Ok,i am alive."); return 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy