Atitit.wrmi web rmi框架新特性
1. V1d 新特性1
1.1. 增加了精确参数1
1.2. 增加了req参数,命名参数模式。。1
1.3. 增加了globale 传递隐含参数req resp等1
1.4. Cs bs两个版本的实现1
2. V2 新特性2
2.1. $req对象预定义参数的支持2
2.2. 动态ioc IocXq2142
2.3. end4
增加了对req参数的处理
var mp=$("form").serialize();
mp=mp+"&$method=com.attilax.bet.BetService.bet&$callback=get_posts_callback¶m1=$req";
作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙, EMAIL:[email protected]
转载请注明来源: http://www.cnblogs.com/attilax/
package com.attilax.wrmi;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.reflect.ConstructorUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
//import com.attilaax.encode.EncodeX; sould recomm q229 ati
import com.attilax.core;
import com.attilax.ioc.IocXq214;
import com.attilax.lang.Global;
import com.attilax.lang.ParamX;
import com.attilax.ref.refx;
import com.attilax.web.ReqX;
import com.google.common.collect.Maps;
/**
* $method=com.attilax.jsna.test.add
* @author Administrator
*
*/
public class Wrmi {
/**
* def output raw type ..if list map object use json fmt
*
* @param req
* @return
*/
@SuppressWarnings("all")
public String exe(Map m) {
//Map m=Maps.newLinkedHashMap();
//if(req2 instanceof String) //cs envi
// m = new ParamX().urlParams2Map((String) req2);
//
Object[] params_objArr = getParamsArr(m);
String meth = (String) m.get("$method");
String classname = refx.getClassName(meth);
String meth_name = refx.getMethodName(meth);
Object o;
try {
// String apptype=System.getProperty("apptype");
o = IocXq214.getBean(classname);
Object invokeMethod_ret = com.attilax.reflect.MethodUtils.invokeMethod(o, meth_name,
params_objArr);
String ret = "";
if (invokeMethod_ret instanceof String)
ret = (String) invokeMethod_ret;
if (invokeMethod_ret instanceof Integer || invokeMethod_ret instanceof Double)
ret = invokeMethod_ret.toString();
else
ret = core.toJsonStrO88(invokeMethod_ret);
return ret;
} catch (Throwable e) {
e.printStackTrace();
return core.toJsonStrO88(e);
}
}
private Object[] getParamsArr(Map m) {
List paras_li = new ArrayList();
//m.get("param")
if (m.get("param") != null)
paras_li.add(convertReqObjParams( m.get("param")));
for (int i = 0; i < 7; i++) {
String param_index = "param" + String.valueOf(i);
if (m.get(param_index) != null)
paras_li.add(convertReqObjParams(m.get(param_index)));
}
Object[] params_objArr = paras_li.toArray();
return params_objArr;
}
private Object convertReqObjParams(Object object) {
if(object.toString().trim().equals("$req"))
return Global.req.get();
return object;
}
}