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.
1 package com.utstar.omco.jnti.inc; 2 3 4 public interface ITBusStub extends IEngineHandle 5 { 6 ITAclInterface getAclInterface(); 7 void setName(String name); 8 String getUUID(); 9 int generateSID(); 10 int getSessionCount(); 11 ITServerSession getSession(int sid); 12 ITServerSession[] getAllSession(); 13 int delSession(int sid, ITableRegChange ic); 14 int _onRecvResult(Msg.MsgInfo msg); 15 Msg.MsgInfo _onNeedExec(); 16 int _onRecvFromSession(ITServerSession s, Msg.MsgInfo msg); 17 int _onRegister(Msg.ReguestRegister reg, ITableRegChange ic); 18 void _onUpdateRegInfo(String src, ITableRegChange ic); 19 int _onAddSession(ITServerSession s); 20 }
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.
1 public class BusStub extends AbsEngineHandle implements ITBusStub,IMonitor 2 { 3 public static interface MsgPriorityStrategy 4 { 5 public int onRecvResultPriority(Msg.MsgInfo msg); 6 public int onRecvFromSessionPriority(ITServerSession s, Msg.MsgInfo msg); 7 } 8 9 public static class ResultPriorMsgPriorityStrategy implements MsgPriorityStrategy 10 { 11 public int onRecvResultPriority(Msg.MsgInfo msg) 12 { 13 return DefaultEngine.PRIO_HIGH; 14 } 15 16 public int onRecvFromSessionPriority(ITServerSession s, Msg.MsgInfo msg) 17 { 18 return DefaultEngine.PRIO_DEFAULT; 19 } 20 } 21 22 AtomicInteger m_curSessionIdx = new AtomicInteger(1); 23 24 IMsgQueue<Msg.MsgInfo> m_cmdQue = new MsgQueue<Msg.MsgInfo>("cmd"); 25 IMsgQueue<Msg.MsgInfo> m_resultQue = new MsgQueue<Msg.MsgInfo>("result"); 26 27 ConcurrentHashMap<Integer, ITServerSession> m_svc = new ConcurrentHashMap<Integer, ITServerSession>(); 28 29 NotifyReg m_reg = new NotifyReg(); 30 31 ITDispatch m_dispatch; 32 33 ITAclInterface m_acl = ITAclInterface.s_defaultAcl; 34 String m_uuid = UUID.randomUUID().toString(); 35 String m_name; 36 37 MsgPriorityStrategy m_msgPriorityStrategy; 38 39 LongStatPrp sp_cmdnum = new LongStatPrp("recv cmd",0); 40 LongStatPrp sp_resultnum = new LongStatPrp("send result",0); 41 LongStatPrp sp_notifynum = new LongStatPrp("send notify",0); 42 43 private static final Log logger = LogFactory.getLog("comm"); 44 45 public BusStub(String name) 46 { 47 this(name, null); 48 } 49 50 public BusStub(String name, MsgPriorityStrategy msgPriorityStrategy) 51 { 52 m_name = name; 53 m_msgPriorityStrategy = msgPriorityStrategy; 54 } 55 56 57 public String getName() 58 { 59 return m_name; 60 } 61 public void setName(String name) 62 { 63 m_name = name; 64 } 65 66 public String getUUID() 67 { 68 return m_uuid; 69 }
Address: http://www.2cto.com/kf/201310/249266.html