What does stub mean? What is the function?

Source: Internet
Author: User

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;      }  

 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.