{"id":14879,"date":"2023-12-04T16:38:09","date_gmt":"2023-12-04T08:38:09","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=14879"},"modified":"2023-12-14T14:33:49","modified_gmt":"2023-12-14T06:33:49","slug":"dubbospi-he-java-spi-qu-bie","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/04\/dubbospi-he-java-spi-qu-bie\/","title":{"rendered":"DubboSPI \u548c Java SPI \u533a\u522b\uff1f"},"content":{"rendered":"<p>Dubbo SPI\uff08Service Provider Interface\uff09\u548c Java SPI\uff08Service Provider Interface\uff09\u662f\u4e24\u79cd\u4e0d\u540c\u7684SPI\u673a\u5236\uff0c\u867d\u7136\u5b83\u4eec\u90fd\u7528\u4e8e\u5b9e\u73b0\u670d\u52a1\u53d1\u73b0\u548c\u6269\u5c55\u70b9\u7684\u52a0\u8f7d\uff0c\u4f46\u5728\u5b9e\u73b0\u548c\u4f7f\u7528\u65b9\u5f0f\u4e0a\u5b58\u5728\u4e00\u4e9b\u533a\u522b\u3002<\/p>\n<h3><a id=\"1-java-spi%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>1. Java SPI\uff1a<\/h3>\n<p>Java SPI\u662fJava\u6807\u51c6\u5e93\u63d0\u4f9b\u7684\u4e00\u79cd\u670d\u52a1\u53d1\u73b0\u673a\u5236\uff0c\u4e3b\u8981\u7528\u4e8e\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u53d1\u73b0\u5e76\u52a0\u8f7d\u5177\u4f53\u7684\u5b9e\u73b0\u7c7b\u3002Java SPI\u7684\u4e3b\u8981\u7279\u70b9\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\n<strong>\u7ea6\u5b9a\u76ee\u5f55\uff1a<\/strong> Java SPI\u7ea6\u5b9a\u5728<code>META-INF\/services\/<\/code>\u76ee\u5f55\u4e0b\u63d0\u4f9b\u4e00\u4e2a\u4ee5\u63a5\u53e3\u6216\u62bd\u8c61\u7c7b\u7684\u5168\u9650\u5b9a\u540d\u547d\u540d\u7684\u6587\u4ef6\uff0c\u6587\u4ef6\u5185\u5bb9\u662f\u5177\u4f53\u5b9e\u73b0\u7c7b\u7684\u5168\u9650\u5b9a\u540d\u3002\n<\/li>\n<li>\n<strong>\u52a0\u8f7d\u65b9\u5f0f\uff1a<\/strong> \u4f7f\u7528<code>ServiceLoader<\/code>\u7c7b\u8fdb\u884c\u52a0\u8f7d\uff0c\u901a\u8fc7<code>ServiceLoader<\/code>\u53ef\u4ee5\u83b7\u53d6\u67d0\u4e2a\u63a5\u53e3\u7684\u6240\u6709\u5b9e\u73b0\u7c7b\u7684\u5b9e\u4f8b\u3002\n<\/li>\n<li>\n<strong>\u5ef6\u8fdf\u52a0\u8f7d\uff1a<\/strong> Java SPI\u662f\u4e00\u79cd\u5ef6\u8fdf\u52a0\u8f7d\u673a\u5236\uff0c\u53ea\u6709\u5728\u9700\u8981\u7684\u65f6\u5019\u624d\u4f1a\u53bb\u52a0\u8f7d\u5177\u4f53\u7684\u5b9e\u73b0\u7c7b\u3002\n<\/li>\n<\/ul>\n<h3><a id=\"2-dubbo-spi%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>2. Dubbo SPI\uff1a<\/h3>\n<p>Dubbo SPI\u662fDubbo\u6846\u67b6\u81ea\u5df1\u5b9e\u73b0\u7684\u4e00\u79cdSPI\u673a\u5236\uff0c\u7528\u4e8e\u5b9e\u73b0\u6269\u5c55\u70b9\u7684\u52a0\u8f7d\u548c\u6269\u5c55\u3002Dubbo SPI\u7684\u4e3b\u8981\u7279\u70b9\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\n<strong>\u7ea6\u5b9a\u6587\u4ef6\uff1a<\/strong> Dubbo SPI\u7ea6\u5b9a\u5728<code>META-INF\/dubbo\/<\/code>\u76ee\u5f55\u4e0b\u63d0\u4f9b\u4ee5\u63a5\u53e3\u5168\u9650\u5b9a\u540d\u547d\u540d\u7684\u6587\u4ef6\uff0c\u6587\u4ef6\u5185\u5bb9\u662f\u5177\u4f53\u6269\u5c55\u70b9\u5b9e\u73b0\u7c7b\u7684\u5168\u9650\u5b9a\u540d\u3002\n<\/li>\n<li>\n<strong>\u52a0\u8f7d\u65b9\u5f0f\uff1a<\/strong> \u4f7f\u7528Dubbo\u7684<code>ExtensionLoader<\/code>\u7c7b\u8fdb\u884c\u52a0\u8f7d\uff0c\u901a\u8fc7<code>ExtensionLoader<\/code>\u53ef\u4ee5\u83b7\u53d6\u67d0\u4e2a\u6269\u5c55\u70b9\u7684\u5b9e\u73b0\u7c7b\u7684\u5b9e\u4f8b\u3002\n<\/li>\n<li>\n<strong>\u914d\u7f6e\u5316\uff1a<\/strong> Dubbo SPI\u652f\u6301\u914d\u7f6e\u5316\u7684\u65b9\u5f0f\uff0c\u901a\u8fc7\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6307\u5b9a\u67d0\u4e2a\u6269\u5c55\u70b9\u7684\u5177\u4f53\u5b9e\u73b0\u7c7b\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5728\u4e0d\u4fee\u6539\u4ee3\u7801\u7684\u60c5\u51b5\u4e0b\u66ff\u6362\u5177\u4f53\u5b9e\u73b0\u3002\n<\/li>\n<li>\n<strong>\u81ea\u9002\u5e94\u6269\u5c55\uff1a<\/strong> Dubbo SPI\u652f\u6301\u81ea\u9002\u5e94\u6269\u5c55\u70b9\uff0c\u5728\u63a5\u53e3\u65b9\u6cd5\u4e0a\u4f7f\u7528<code>@Adaptive<\/code>\u6ce8\u89e3\uff0c\u901a\u8fc7\u89e3\u6790URL\u4e2d\u7684\u53c2\u6570\u8fdb\u884c\u81ea\u9002\u5e94\u6269\u5c55\u3002\n<\/li>\n<\/ul>\n<h3><a id=\"%E4%B8%BB%E8%A6%81%E5%8C%BA%E5%88%AB%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u4e3b\u8981\u533a\u522b\uff1a<\/h3>\n<ol>\n<li>\n<strong>\u4f7f\u7528\u65b9\u5f0f\uff1a<\/strong> Java SPI\u4f7f\u7528<code>ServiceLoader<\/code>\uff0c\u800cDubbo SPI\u4f7f\u7528<code>ExtensionLoader<\/code>\u3002\n<\/li>\n<li>\n<strong>\u6587\u4ef6\u7ea6\u5b9a\uff1a<\/strong> Java SPI\u7ea6\u5b9a\u5728<code>META-INF\/services\/<\/code>\u76ee\u5f55\u4e0b\uff0c\u800cDubbo SPI\u7ea6\u5b9a\u5728<code>META-INF\/dubbo\/<\/code>\u76ee\u5f55\u4e0b\u3002\n<\/li>\n<li>\n<strong>\u914d\u7f6e\u65b9\u5f0f\uff1a<\/strong> Dubbo SPI\u652f\u6301\u914d\u7f6e\u5316\u7684\u65b9\u5f0f\uff0c\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u6307\u5b9a\u6269\u5c55\u70b9\u7684\u5b9e\u73b0\u7c7b\uff0c\u800cJava SPI\u9700\u8981\u5728\u6587\u4ef6\u4e2d\u5217\u4e3e\u5b9e\u73b0\u7c7b\u7684\u5168\u9650\u5b9a\u540d\u3002\n<\/li>\n<li>\n<strong>\u81ea\u9002\u5e94\u6269\u5c55\uff1a<\/strong> Dubbo SPI\u652f\u6301\u81ea\u9002\u5e94\u6269\u5c55\u70b9\uff0c\u800cJava SPI\u6ca1\u6709\u539f\u751f\u7684\u81ea\u9002\u5e94\u6269\u5c55\u673a\u5236\u3002\n<\/li>\n<\/ol>\n<p>\u603b\u7684\u6765\u8bf4\uff0cDubbo SPI\u5728Java SPI\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u4e86\u4e00\u4e9b\u6269\u5c55\u548c\u6539\u8fdb\uff0c\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u548c\u529f\u80fd\u4e30\u5bcc\u7684\u6269\u5c55\u70b9\u673a\u5236\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dubbo SPI\uff08Service Provider Interface\uff09\u548c Java SPI\uff08Service [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[123],"tags":[],"class_list":["post-14879","post","type-post","status-publish","format-standard","hentry","category-dubbo"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/14879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=14879"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/14879\/revisions"}],"predecessor-version":[{"id":48130,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/14879\/revisions\/48130"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=14879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=14879"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=14879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}