methodsMap.put(key, m);
}
}
}
final JsonHelper jsh = new JsonHelper();
InvocationHandler ih = new InvocationHandler() {
//private Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
AjaxContext actx = (AjaxContext)args[0];
try {
String key = buildKey(method.getName(), args.length);
Method target = methodsMap.get(key);
if (target == null) {
//TODO
return null;
}
Context ctx = scf.getContext(actx.getRequest().getUserId(),
actx.getRequest().getSessionId(), actx.getRequest().getReqId(),
actx.getRequest().getLang(), actx.getResponseHandler());
Object[] serviceArgs = new Object[args.length];
serviceArgs[0] = ctx;
for (int ii=1; ii<args.length;ii++)
serviceArgs[ii] = args[ii];
JsonServiceRequest jsr = (JsonServiceRequest)ctx.getRequest();
String sargs = jsh.serialize(serviceArgs);
//logger.info("calling service {} with args {}", method.getName(), sargs);
jsr.setService(method.getName());
jsr.setServiceArgsJson(sargs);
return target.invoke(serviceCaller, serviceArgs);