📄 ecappserverhandler.java
字号:
/****************************************************************************
* Package : com.ecSolutions.ecAppServer.server.handler
* File : EcAppServerHandler.java
* Create Date : 2007-7-20
* Author : Steven Chen
*
* Copyright(C) 2006 ecSolutions(shanghai) Co.,Limited.All Rights Reserved.
*
***************************************************************************/
package com.ecSolutions.ecAppServer.server.handler;
import org.apache.log4j.Logger;
import com.ecSolutions.ecAppServer.appSession.ExecFunctionFailException;
import com.ecSolutions.ecAppServer.appSession.LoginResponse;
import com.ecSolutions.ecAppServer.appSession.UserLoginFailException;
import com.ecSolutions.ecAppServer.business.ExecuteFunction;
import com.ecSolutions.ecAppServer.business.SignOffService;
import com.ecSolutions.ecAppServer.business.SignOnService;
import com.ecSolutions.ecAppServer.server.Session;
import com.ecSolutions.ecAppServer.server.SessionHandlerAdapter;
/**
*
* @author Steven Chen
* @version $Id: EcAppServerHandler.java,v 1.10 2007/07/26 03:26:14 stevenchen Exp $
*
*/
public class EcAppServerHandler extends SessionHandlerAdapter {
private static Logger log = Logger.getLogger("EcAppServerHandler");
public void objectReceived(Session session, Object obj) {
/*
log.debug("-->>" + obj.getClass().getName());
log.debug("-->>" + obj.toString());
DefaultPacket p = (DefaultPacket)obj;
log.debug(p.getContent().dump());
ByteBuffer b = null;
if(p.getContent() instanceof ByteArrayBuffer){
b = ((ByteArrayBuffer) p.getContent()).asByteBuffer();
}else if(p.getContent() instanceof ByteBufferBuffer){
b=((ByteBufferBuffer) p.getContent()).asByteBuffer();
}else if(p.getContent() instanceof LinkedBuffer){
b=((LinkedBuffer) p.getContent()).asByteBuffer();
}else if(p.getContent() instanceof DelegateBuffer){
b=((DelegateBuffer) p.getContent()).asByteBuffer();
}
log.debug("--XXX: " + p.getContent().toString());
String charBuffers = Charset.forName("ISO-8859-1").decode(b).toString();
log.debug("--getbuffer: " + charBuffers);
String type=charBuffers.substring(4,8);
*/
String msg = (String) obj;
String type=msg.substring(4,8);
log.debug("--msg: " + msg);
if(type.equals("SSGN")){
SignOnService so = new SignOnService(msg);
LoginResponse loginResponse ;
try {
loginResponse = so.signOn();
} catch (UserLoginFailException e) {
loginResponse = new LoginResponse("0060","HFAL",e.getMessage());
}
log.info("------------》》》" + loginResponse.getResponse());
session.send(loginResponse.getResponse());
}else if(type.equals("SSOF")){
SignOffService soff=new SignOffService(msg);
soff.signOff();
}else if(type.equals("EXEC")){
ExecuteFunction execFuncation = new ExecuteFunction(msg);
try {
execFuncation.execFunc();
} catch (ExecFunctionFailException e) {
e.printStackTrace();
log.error("Execute Function Fail.........");
}
}
}
public void sessionStarted(Session session) throws Exception {
}
public void sessionClosed(Session session) throws Exception {
}
public void sessionTimeout(Session session) throws Exception {
session.close();
}
public void objectSent(Session session, Object obj) throws Exception {
}
public void exceptionCaught(Session session, Throwable cause) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -