package chat.server.call;
|
|
import java.lang.reflect.Method;
|
|
import org.apache.log4j.Logger;
|
|
import chat.server.im.DataPool;
|
import chat.server.im.ResultPool;
|
import chat.user.Session;
|
import chat.user.User;
|
|
|
public abstract class CallObject extends MethodPublisher {
|
|
protected static Logger logger;
|
protected Session session;
|
protected User user;
|
protected DataPool dataPool;
|
protected ResultPool resultPool;
|
|
static {
|
logger = Logger.getLogger(CallObject.class);
|
}
|
|
public CallObject() {
|
|
}
|
|
public void exec(Session session, Operator operator, DataPool dataPool, ResultPool resultPool) {
|
try {
|
Method method = getOneMethod(operator.getMethod());
|
|
if (method == null) {
|
method = methodMap.get("call");
|
}
|
|
if (method != null) {
|
this.session = session;
|
|
if (session != null) {
|
this.user = session.getUser();
|
}
|
|
this.dataPool = dataPool;
|
this.resultPool = resultPool;
|
|
try {
|
method.invoke(this);
|
}
|
catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
else {
|
resultPool.error(ResultCode.Error_Path_NotExists);
|
}
|
}
|
catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
protected void onError(Exception e) throws Exception {
|
logger.error(e);
|
|
if (logger.isTraceEnabled()) {
|
e.printStackTrace();
|
}
|
}
|
|
}
|