二:dubbo中SPI扩展实现

1:RPC协议扩展,封装远程调用细节

扩展接口:

com.alibaba.dubbo.rpc.Protocol

com.alibaba.dubbo.rpc.Exporter

com.alibaba.dubbo.rpc.Invoker

已知扩展:

com.alibaba.dubbo.rpc.injvm.InjvmProtocol

com.alibaba.dubbo.rpc.dubbo.DubboProtocol

com.alibaba.dubbo.rpc.rmi.RmiProtocol

com.alibaba.dubbo.rpc.http.HttpProtocol

com.alibaba.dubbo.rpc.http.hessian.HessianProtocol

2:调用拦截扩展

扩展接口:

com.alibaba.dubbo.rpc.Filter

已知扩展:

com.alibaba.dubbo.rpc.filter.EchoFilter

com.alibaba.dubbo.rpc.filter.GenericFilter

com.alibaba.dubbo.rpc.filter.GenericImplFilter

com.alibaba.dubbo.rpc.filter.TokenFilter

com.alibaba.dubbo.rpc.filter.AccessLogFilter

com.alibaba.dubbo.rpc.filter.CountFilter

com.alibaba.dubbo.rpc.filter.ActiveLimitFilter

com.alibaba.dubbo.rpc.filter.ClassLoaderFilter

com.alibaba.dubbo.rpc.filter.ContextFilter

com.alibaba.dubbo.rpc.filter.ConsumerContextFilter

com.alibaba.dubbo.rpc.filter.ExceptionFilter

com.alibaba.dubbo.rpc.filter.ExecuteLimitFilter

com.alibaba.dubbo.rpc.filter.DeprecatedFilter

3:引用监听扩展

扩展接口:(当有服务引用时,触发该事件)

com.alibaba.dubbo.rpc.InvokerListener

已知扩展:

com.alibaba.dubbo.rpc.listener.DeprecatedInvokerListener

4:暴露监听扩展

扩展接口:当有服务暴露时,触发该事件

com.alibaba.dubbo.rpc.ExporterListener

已知扩展:

com.alibaba.dubbo.registry.directory.RegistryExporterListener

5:集群扩展

扩展接口:(当有多个服务提供方时,将多个服务提供方组织成一个集群,并伪装成一个提供方)

com.alibaba.dubbo.rpc.cluster.Cluster

已知扩展:

com.alibaba.dubbo.rpc.cluster.support.FailoverCluster

com.alibaba.dubbo.rpc.cluster.support.FailfastCluster

com.alibaba.dubbo.rpc.cluster.support.FailsafeCluster

com.alibaba.dubbo.rpc.cluster.support.FailbackCluster

com.alibaba.dubbo.rpc.cluster.support.ForkingCluster

com.alibaba.dubbo.rpc.cluster.support.AvaliableCluster

6:路由扩展

扩展接口:(从多个服务提供者方中选择一个进行调用)

com.alibaba.dubbo.rpc.cluster.RouterFactory

com.alibaba.dubbo.rpc.cluster.Router

已知扩展:

com.alibaba.dubbo.rpc.cluster.router.ScriptRouterFactory

com.alibaba.dubbo.rpc.cluster.router.FileRouterFatory

7:负载均衡的裸站

扩展接口:(从多个服务提供者选择一个进行调用)

com.alibaba.dubbo.rpc.cluster.loadbalance.RandomLoadBalance

com.alibaba.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalance

com.alibaba.dubbo.rpc.cluster.loadbalance.LeastActiveLoadBalance

8:合并结果扩展

扩展接口:(合并返回结果,用于分组聚合)

com.alibaba.dubbo.rpc.cluster.Merger

已知扩展:

com.alibaba.dubbo.rpc.cluster.merger.ArrayMerger

com.alibaba.dubbo.rpc.cluster.merger.ListMerger

com.alibaba.dubbo.rpc.cluster.merger.SetMerger

com.alibaba.dubbo.rpc.cluster.merger.MapMerger

9:注册中心扩展

扩展接口:(负责服务的注册与发现)

com.alibaba.dubbo.registry.RegistryFactory

com.alibaba.dubbo.registry.Registry

已知扩展:

com.alibaba.dubbo.registry.support.dubbo.DubboRegistryFactory

10:监控中心扩展

扩展接口:(负责服务调用次数和调用时间的监控)

com.alibaba.dubbo.monitor.MonitorFactory

com.alibaba.dubbo.monitor.Monitor

已知扩展:

com.alibaba.dubbo.monitor.support.dubbo.DubboMonitorFactory

11:扩展点加载扩展

扩展接口:(扩展点本身的加载容器,可从不同容器加载扩展点)

com.alibaba.dubbo.common.extension.ExtensionFactory

已知扩展:

com.alibaba.dubbo.common.extension.factory.SpiExtensionFactory

com.alibaba.dubbo.common.config.spring.extension.SpringExtensionFactory

12:动态代理扩展

扩展接口:(将Invoker接口转换成业务接口)

com.alibaba.dubbo.rpc.ProxyFactory

已知扩展:

com.alibaba.dubbo.rpc.proxy.JdkProxyFactory

com.alibaba.dubbo.rpc.proxy.JavassistProxyFactory

13:编译器扩展

扩展接口:(JAVA代码编译器,用于动态生成字节码,加速调试)

com.alibaba.dubbo.common.compiler.Compiler

已知扩展:

com.alibaba.dubbo.common.compiler.support.JdkCompiler

com.alibaba.dubbo.common.compiler.support.JavassitCompiler

14:消息派发扩展

扩展接口:(通道信息派发器,用于指定线程池模型)

com.alibaba.dubbo.remoting.Dispatcher

已知扩展:

com.alibaba.dubbo.remoting.transport.dispatcher.all.AllDispatcher

com.alibaba.dubbo.remoting.transport.dispatcher.direct.DirectDispatcher

com.alibaba.dubbo.remoting.transport.dispatcher.message.MessageOnlyDispatcher

com.alibaba.dubbo.remoting.transport.dispatcher.execution.ExecutionDispatcher

com.alibaba.dubbo.remoting.transprot.dispatcher.connection.ConnectionOrderedDispatcher

15:线程池扩展

扩展接口:(服务提供方线程的实现策略,当服务器收到一个请求时,需要在线程池中创建一个线程去执行服务提供方业务逻辑。)

com.alibaba.dubbo.common.threadpool.ThreadPool

已知扩展:

com.alibaba.dubbo.common.threadpool.FixedThreadPool

com.alibaba.dubbo.common.threadpool.CachedThreadPool

16:序列化扩展

扩展接口:(将对象转化成字节流,用于网络传输;以及将字节流转化为对象,用于在收到字节流数据后还原成对象。)

com.alibaba.dubbo.common.serialize.Serialization

com.alibaba.dubbo.common.serialize.ObjectInput

com.alibaba.dubbo.common.serialize.ObjectOutput

已知扩展:

com.alibaba.dubbo.common.serialize.dubbo.DubboSerialization

com.alibaba.dubbo.common.serialize.hessian.Hessian2Serialization

com.alibaba.dubbo.common.serialize.java.JavaSerialization

com.alibaba.dubbo.common.serialize.java.CompactedJavaSerialization

17:网络传输扩展

扩展接口:(远程通讯的服务器及客户端传输的实现)

com.alibaba.dubbo.remoting.Transporter

com.alibaba.dubbo.remoting.Server

com.alibaba.dubbo.remoting.Client

已知扩展:

com.alibaba.dubbo.remoting.transport.transporter.netty.NettyTransporter

com.alibaba.dubbo.remoting.transport.transporter.mina.MinaTransporter

com.alibaba.dubbo.remoting.transport.transporter.grizzly.GrizzlyTransporter

18:信息交换扩展

扩展接口:(基于传输层之上,实现Request-Response信息交换语义。)

com.alibaba.dubbo.remoting.exchange.Exchanger

com.alibaba.dubbo.remoting.exchange.ExchangerServer

com.alibaba.dubbo.remoting.exchange.ExchangerClient

已知扩展:

com.alibaba.dubbo.remoting.exchange.exchanger.HeaderExchanger

19:组网扩展

扩展接口:(对等网络节点组网器)

com.alibaba.dubbo.remoting.p2p.NetWorker

已知扩展:

com.alibaba.dubbo.remoting.p2p.support.MulticastNetworker

com.alibaba.dubbo.remoting.p2p.support.FileNetworker

20:Telnet命令扩展

扩展接口:(所有服务器均支持telnet访问,用于人工干预)

com.alibaba.dubbo.remoting.telnet.TelnetHandler

已知扩展:

com.alibaba.dubbo.remoting.telnet.support.ClearTelnetHandler

com.alibaba.dubbo.remoting.telnet.support.ExitTelnetHandler

com.alibaba.dubbo.remoting.telnet.support.HelpTelnetHandler

com.alibaba.dubbo.remoting.telnet.support.StatusTelnetHandler

com.alibaba.dubbo.rpc.dubbo.telnet.ListTelnetHandler

com.alibaba.dubbo.rpc.dubbo.telnet.ChangeTelnetHandler

com.alibaba.dubbo.rpc.dubbo.telnet.CurrentTelnetHandler

com.alibaba.dubbo.rpc.dubbo.telnet.InvokerTelnetHandler

com.alibaba.dubbo.rpc.dubbo.telnet.TraceTelnetHandler

com.alibaba.dubbo.rpc.dubbo.telnet.CountTelnetHandler

com.alibaba.dubbo.rpc.dubbo.telnet.PortTelnetHandler

21:状态检查扩展

扩展接口:(检查服务依赖各种资源的状态,此状态检查可同时用于telnet的status命令和hosting的status页面。)

com.alibaba.dubbo.common.status.StatusChecker

已知扩展:

com.alibaba.dubbo.common.status.support.MemoryStatusChecker

com.alibaba.dubbo.common.status.support.LoadStatusChecker

com.alibaba.dubbo.rpc.dubbo.status.ServerStatusChecker

com.alibaba.dubbo.rpc.dubbo.status.ThreadPoolStatusChecker

com.alibaba.dubbo.registry.directory.RegistryStatusChecker

com.alibaba.dubbo.rpc.config.spring.status.SpringStatusChecker

com.alibaba.dubbo.rpc.config.spring.status.DataSourceStatusChecker

22:容器扩展

扩展接口:(服务容器扩展,用于自定义加载内容。)

com.alibaba.dubbo.container.Container

已知扩展:

com.alibaba.dubbo.container.spring.SpringContainer

com.alibaba.dubbo.container.spring.JettyContainer

com.alibaba.dubbo.container.spring.Log4jContainer

23:页面扩展

扩展接口:

com.alibaba.dubbo.container.page.PageHandler

已知扩展:

com.alibaba.dubbo.container.page.pages.HomePageHandler

com.abliaba.dubbo.container.page.pages.StatusPageHandler

com.alibaba.dubbo.container.page.pages.LogPageHandler

com.alibaba.dubbo.container.page.pages.SystemPageHandler

24:缓存扩展

扩展接口:(用请求参数作为key,缓存返回结果。)

com.alibaba.dubbo.cache.CacheFactory

已知扩展:

com.alibaba.dubbo.cache.support.lru.LruCacheFactory

com.alibaba.dubbo.cache.support.threadlocal.ThreadLocalCacheFactory

com.alibaba.dubbo.cache.support.jcache.JCacheFactory

25:验证扩展

扩展接口:(参数验证扩展点)

com.alibaba.dubbo.validation.Validation

已知扩展:

com.alibaba.dubbo.validation.support.jvalidation.JValidation

26:日志适配扩展

扩展接口:(日志输出适配扩展点)

com.alibaba.dubbo.common.logger.LoggerAdapter

已知扩展:

com.alibaba.dubbo.common.logger.slf4j.Slf4jLoggerAdapter

com.alibaba.dubbo.common.logger.jcl.JclLoggerAdapter

com.alibaba.dubbo.common.logger.log4j.Log4jLoggerAdapter

com.alibaba.dubbo.common.logger.jdk.JdkLoggerAdapter

推荐阅读更多精彩内容

  • 0 准备 安装注册中心:Zookeeper、Dubbox自带的dubbo-registry-simple;安装Du...
    七寸知架构阅读 13,709评论 0 89
  • 所谓“给觉知留下空间”,就是说在理解自己时,先去好好觉知,充分觉知,要把觉知这件事做到足够。 怎样做会破坏觉知的空...
    Joycty阅读 146评论 0 0
  • 反常识: 知识不需要完全确定后才是有用的——即便某些知识不能预测个体的具体统计情况,但如果能对群体的总体趋势有预测...
    夏达人阅读 552评论 0 0
  • 清代的袁枚在《黄生借书说》中对前来借书的黄允修说:“书非借不能读也”。可知古人借书阅读是求学的一项重要内容,毕竟穷...
    涛涛老师阅读 309评论 0 2
  • 阿尔茨海默症不仅仅是失忆,还伴随各种前兆症状。如果发现自己或周围人有以下10个症状,一定不能忽视,和医生预约一个时...
    许远山阅读 2,902评论 1 0