A stub class is a class that implements an interface, but every method after implementation is empty. Its role is: if an interface has many methods, if you want to implement this interface, you need to implement all the methods. However, a class may only need one or two methods for the business. If you implement this interface directly, in addition to the required methods, you must implement all other irrelevant methods. If the interface is implemented by inheriting the stub class, the interface in the user logon session in omco2.6 is eliminated.
package com.utstar.omco.jnti.inc; public interface ITBusStub extends IEngineHandle { ITAclInterface getAclInterface(); void setName(String name); String getUUID(); int generateSID(); int getSessionCount(); ITServerSession getSession(int sid); ITServerSession[] getAllSession(); int delSession(int sid, ITableRegChange ic); int _onRecvResult(Msg.MsgInfo msg); Msg.MsgInfo _onNeedExec(); int _onRecvFromSession(ITServerSession s, Msg.MsgInfo msg); int _onRegister(Msg.ReguestRegister reg, ITableRegChange ic); void _onUpdateRegInfo(String src, ITableRegChange ic); int _onAddSession(ITServerSession s); }
The above class ITBusStub is a stub class, which is mainly used to inherit an interface class, and its implementation class only needs to implement this interface, the method to be called. BusStub is its implementation class.
public class BusStub extends AbsEngineHandle implements ITBusStub,IMonitor { public static interface MsgPriorityStrategy { public int onRecvResultPriority(Msg.MsgInfo msg); public int onRecvFromSessionPriority(ITServerSession s, Msg.MsgInfo msg); } public static class ResultPriorMsgPriorityStrategy implements MsgPriorityStrategy { public int onRecvResultPriority(Msg.MsgInfo msg) { return DefaultEngine.PRIO_HIGH; } public int onRecvFromSessionPriority(ITServerSession s, Msg.MsgInfo msg) { return DefaultEngine.PRIO_DEFAULT; } } AtomicInteger m_curSessionIdx = new AtomicInteger(1); IMsgQueue<Msg.MsgInfo> m_cmdQue = new MsgQueue<Msg.MsgInfo>("cmd"); IMsgQueue<Msg.MsgInfo> m_resultQue = new MsgQueue<Msg.MsgInfo>("result"); ConcurrentHashMap<Integer, ITServerSession> m_svc = new ConcurrentHashMap<Integer, ITServerSession>(); NotifyReg m_reg = new NotifyReg(); ITDispatch m_dispatch; ITAclInterface m_acl = ITAclInterface.s_defaultAcl; String m_uuid = UUID.randomUUID().toString(); String m_name; MsgPriorityStrategy m_msgPriorityStrategy; LongStatPrp sp_cmdnum = new LongStatPrp("recv cmd",0); LongStatPrp sp_resultnum = new LongStatPrp("send result",0); LongStatPrp sp_notifynum = new LongStatPrp("send notify",0); private static final Log logger = LogFactory.getLog("comm"); public BusStub(String name) { this(name, null); } public BusStub(String name, MsgPriorityStrategy msgPriorityStrategy) { m_name = name; m_msgPriorityStrategy = msgPriorityStrategy; } public String getName() { return m_name; } public void setName(String name) { m_name = name; } public String getUUID() { return m_uuid; }