存根类(stub) 是什么意思?有什么作用?
来源:互联网 发布:unity3d场景视频教程 编辑:程序博客网 时间:2024/04/29 05:04
存根类是一个类,它实现了一个接口,但是实现后的每个方法都是空的。
它的作用是:如果一个接口有很多方法,如果要实现这个接口,就要实现所有的方法。但是一个类从业务来说,可能只需要其中一两个方法。如果直接去实现这个接口,除了实现所需的方法,还要实现其他所有的无关方法。而如果通过继承存根类就实现接口,就免去了这种麻烦
这个在omco2.6版本中用户登录的session中的接口就有体现。
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);}
上面的类ITBusStub,就是一个stub类,它的作用主要是用于继承一个接口类,然后它的实现类只需要通过实现它这个接口就可以,
实现需要调用的方法。BusStub是它的实现类。
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;}
- 存根类(stub) 是什么意思?有什么作用?
- 存根类STUB
- 存根类 Stub详解
- stub存根类
- 什么是存根类 Stub
- Oracle 中的SID是什么意思?有什么作用?
- android 编程中"<<"是什么意思?有什么作用?
- Oracle 中的SID是什么意思?有什么作用?
- Oracle 中的SID是什么意思?有什么作用?
- unity3d中烘焙是什么意思?有什么作用?
- Java中static是什么意思,有什么作用?
- sfc /scannow是什么意思,有什么作用?
- 什么是stub? JAVA 存根
- stub,存根是什么?
- JAVA父类引用指向子类的对象是什么意思?有什么作用?
- css 中的background:transparent到底是什么意思有什么作用
- css 中的background:transparent到底是什么意思有什么作用
- css 中的background:transparent到底是什么意思有什么作用
- WiFiDog Captive Portal
- CF_353D (queue)
- ARM处理器CPSR标志位和条件符之间的关系
- AS3 扇形绘制
- linux下tomcat无法启动
- 存根类(stub) 是什么意思?有什么作用?
- JDBC 进阶版
- php base64 图片
- 二、Makefile的文件名
- getopt与getopt_long
- Linux VPS多线程高速下载百度网盘资源的方...
- PostgreSQL 操作问题
- 使用coreData会引起crash解决方法
- SQL 语句及关键字的用法