This is an automated email from the ASF dual-hosted git repository. huxing pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git
The following commit(s) were added to refs/heads/asf-site by this push: new ab52c2c Fix wrong class name (#256) ab52c2c is described below commit ab52c2c2b584504a534cc00eb4bc0a25f76cd89b Author: mimihom <llmimi...@gmail.com> AuthorDate: Wed Jan 23 09:18:39 2019 +0800 Fix wrong class name (#256) * fix wrong class name * fix punctuation * Update docs/en-us/dev/SPI.md --- docs/en-us/dev/SPI.md | 82 +++++++++++++++++++++++++-------------------------- docs/zh-cn/dev/SPI.md | 2 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/docs/en-us/dev/SPI.md b/docs/en-us/dev/SPI.md index 547e6a6..0213237 100644 --- a/docs/en-us/dev/SPI.md +++ b/docs/en-us/dev/SPI.md @@ -2,29 +2,29 @@ ## SPI Config -### Source: +### Source: Dubbo SPI is inherited from standard JDK SPI(Service Provider Interface) and makes it more powerful. -Dubbo fixed below issues of the standard JDK SPI: +Dubbo fixed below issues of the standard JDK SPI: -* the standard JDK SPI will load and instantize all implementation at once. It will be a waste of resources if the implementation is timecosted ,but never be used. -* We cann't accquire the SPI name,if loading the SPI implementation is failed.For example:standard JDK ScriptEngine,get script type by invoking method getName(). RubyScriptEngine class will load failed if the depenency jar jruby.jar is missing,and the real error info will be lost. When user executes ruby scripts , program throws exception , telling not support ruby, but it is not the real cause. -* Enhance the SPI functionality by supporting IoC and AOP ,one SPI can be easily injected by another SPI simply using setter. +* The standard JDK SPI will load and instantize all the implementations at once. It will be a waste of resources if one implementation is timecosted, but never be used. +* We can't accquire the SPI name, if loading the SPI implementation is failed.For example: standard JDK ScriptEngine, get script type by invoking method getName(). RubyScriptEngine class will load failed if the depenency jar jruby.jar is missing, and the real error info will be lost. When user executes ruby scripts, the program throws exception that doesn't support ruby, but it is not the real cause. +* Enhance the SPI functionality by supporting IoC and AOP, one SPI can be easily injected by another SPI simply using setter. -### Appointment: +### Appointment: -In the jar file containing extension class [^1],places a config file `META-INF/dubbo/full interface name`,file content pattern:`SPI name=the fully qualified name for the extension class`,use new line seperator for multiple implementation. +In the jar file containing extension class [^1], places a config file `META-INF/dubbo/full interface name`, file content pattern: `SPI name=the fully qualified name for the extension class`, use new line seperator for multiple implementation. -### Example: +### Example: -To extend Dubbo Protocol,placee a text file in the extension jar file:`META-INF/dubbo/org.apache.dubbo.rpc.Protocol`,content: +To extend Dubbo Protocol, placee a text file in the extension jar file: `META-INF/dubbo/org.apache.dubbo.rpc.Protocol`, content: ```properties xxx=com.alibaba.xxx.XxxProtocol ``` -content of the implementation [^2]: +content of the implementation [^2]: ```java package com.alibaba.xxx; @@ -38,7 +38,7 @@ public class XxxProtocol implements Protocol { ### Configuration in config module -In Dubbo config module,all SPI points have related attributes or labels,we can choose the specific SPI implementation by using its name. Like: +In Dubbo config module, all SPI points have related attributes or labels, we can choose the specific SPI implementation by using its name. Like: ```xml <dubbo:protocol name="xxx" /> @@ -48,9 +48,9 @@ In Dubbo config module,all SPI points have related attributes or labels,we c ### SPI Auto Wrap -Auto wrap the SPI's Wrapper class。`ExtensionLoader` loads the SPI implementation,if the SPI has a copy instructor ,it will be regarded as the SPI's Wrapper class。 +Auto wrap the SPI's Wrapper class. `ExtensionLoader` loads the SPI implementation, if the SPI has a copy instructor, it will be regarded as the SPI's Wrapper class. -Wrapper class content: +Wrapper class content: ```java package com.alibaba.xxx; @@ -62,7 +62,7 @@ public class XxxProtocolWrapper implements Protocol { public XxxProtocolWrapper(Protocol protocol) { impl = protocol; } - //after interface method is executed,the method in extension will be executed + //after interface method is executed, the method in extension will be executed public void refer() { //... some operation impl.refer(); @@ -73,19 +73,19 @@ public class XxxProtocolWrapper implements Protocol { } ``` -Wrapper class also implements the same SPI interface,but Wrapper is not the real implementation。It is used for wrap the real implementation returned from the `ExtensionLoader` 。The real returned instance by `ExtensionLoader` is the Wrapper class instance,Wrapper holder the real SPI implementation class。 +Wrapper class also implements the same SPI interface, but Wrapper is not the real implementation. It is used for wrap the real implementation returned from the `ExtensionLoader`. The real returned instance by `ExtensionLoader` is the Wrapper class instance, Wrapper holder the real SPI implementation class. -There can be many Wrapper for one spi, simply add one if you need。 +There can be many Wrapper for one spi, simply add one if you need. -By Wrapper class,you will be able move same logics into Wrapper for all SPIs。Newly added Wrapper class add external logics for all spis, looks like AOP, Wrapper acts as a proxy for SPI. +With Wrapper class, you will be able to move same logics into Wrapper for all SPIs. Newly added Wrapper class add external logics for all SPIs, looks like AOP, Wrapper acts as a proxy for SPI. ### SPI Auto Load -when loading the SPI,Dubbo will auto load the depency SPI. When one SPI implementation contains attribute which is also an SPI of another type,`ExtensionLoader` will automatically load the depency SPI.`ExtensionLoader` knows all the members of the specific SPI by scanning the setter method of all implementation class. +when loading the SPI, Dubbo will auto load the depency SPI. When one SPI implementation contains attribute which is also an SPI of another type,`ExtensionLoader` will automatically load the depency SPI. `ExtensionLoader` knows all the members of the specific SPI by scanning the setter method of all implementation class. -Demo:two SPI `CarMaker`(car maker)、`WheelMaker` (wheel maker) +Demo: two SPI `CarMaker`(car maker)、`WheelMaker` (wheel maker) -Intefaces look like: +Intefaces look like: ```java public interface CarMaker { @@ -97,7 +97,7 @@ public interface WheelMaker { } ``` -`CarMaker` implementation: +`CarMaker`'s implementation: ```java public class RaceCarMaker implements CarMaker { @@ -116,25 +116,25 @@ public class RaceCarMaker implements CarMaker { } ``` -when`ExtensionLoader` loading `CarMaker` implementation `RaceCar` ,`setWheelMaker` needs paramType `WheelMaker` which is also an SPI, It will be automatically loaded . +when `ExtensionLoader` loads `CarMaker`'s implementation `RaceCarMaker`, the method `setWheelMaker` needs paramType `WheelMaker` which is also a SPI, It will be automatically loaded. -This brings a new question:How `ExtensionLoader` determines which implementation to use when load the injected SPI。As for this demo, when existing multi `WheelMaker` implementation, which one should the `ExtensionLoader` chooses. +This brings a new question:How `ExtensionLoader` determines which implementation to use when load the injected SPI. As for this demo, when existing multi `WheelMaker` implementation, which one should the `ExtensionLoader` chooses. -Good question ,we will explain it in the following chapter: SPI Auto Adaptive. +Good question, we will explain it in the following chapter: SPI Auto Adaptive. ### SPI Auto Adaptive -The depency SPI that `ExtensionLoader` injects is an instance of `Adaptive`,the real spi implementation is known until the adaptive instance is be executed. +The depency SPI that `ExtensionLoader` injects is an instance of `Adaptive`, the real spi implementation is known until the adaptive instance is executed. -Dubbo use URL (containing Key-Value) to pass the configuration. +Dubbo use URL (containing Key-Value) to pass the configuration. The SPI method invocation has the URL parameter(Or Entity that has URL attribute) -In this way depended SPI can get configuration from URL,after config all SPI key needed, configuration information will be passed from outer by URL.URL act as a bus when pass the config information. +In this way depended SPI can get configuration from URL, after config all SPI key needed, configuration information will be passed from outer by URL. URL acts as a bus when passing the config information. -Demo:two SPI `CarMaker`、`WheelMaker` +Demo: two SPI `CarMaker`、`WheelMaker` -interface looks like: +interface looks like: ```java public interface CarMaker { @@ -146,7 +146,7 @@ public interface WheelMaker { } ``` -`CarMaker` implementation: +`CarMaker`'s implementation: ```java public class RaceCarMaker implements CarMaker { @@ -173,11 +173,11 @@ Wheel wheel = wheelMaker.makeWheel(url); // ... ``` -,the injected `Adaptive` object determine which `WheelMaker` 's `makeWheel` method will be executed by predefined Key.。Such as `wheel.type`, key `url.get("wheel.type")` will determine `WheelMake` implementation。The logic of`Adaptive` instance of fixed,getting the predefined Key of the URL,dynamically creating the real implementation and execute it. +, the injected `Adaptive` object determine which `WheelMaker`'s `makeWheel` method will be executed by predefined Key. Such as `wheel.type`, key `url.get("wheel.type")` will determine `WheelMake` implementation. The logic of`Adaptive` instance of fixed, getting the predefined Key of the URL, dynamically creating the real implementation and execute it. -For Dubbo , the SPI `Adaptive` implementation in `ExtensionLoader` is dynamically created when dubbo is loading the SPI。Get the Key from URL, the Key will be provided through `@Adaptive` annotation for the interface method definition. +For Dubbo, the SPI `Adaptive` implementation in `ExtensionLoader` is dynamically created when dubbo is loading the SPI. Get the Key from URL, the Key will be provided through `@Adaptive` annotation for the interface method definition. -Below is Dubbo Transporter SPI codes: +Below is Dubbo Transporter SPI codes: ```java public interface Transporter { @@ -189,12 +189,12 @@ public interface Transporter { } ``` -for the method bind(),Adaptive will firstly search `server` key,if no Key were founded then will search `transport` key ,to determine the implementation that the proxy represent for. +for the method bind(), Adaptive will firstly search `server` key, if no Key were founded then will search `transport` key, to determine the implementation that the proxy represent for. ### SPI Auto Activation -As for Collections SPI, such as:`Filter`, `InvokerListener`, `ExportListener`, `TelnetHandler`, `StatusChecker` etc,multi implementations can be loaded at one time. User can simplify configuration by using auto activation,Like: +As for Collections SPI, such as: `Filter`, `InvokerListener`, `ExportListener`, `TelnetHandler`, `StatusChecker` etc, multi implementations can be loaded at one time. User can simplify configuration by using auto activation, Like: ```java import org.apache.dubbo.common.extension.Activate; @@ -206,32 +206,32 @@ public class XxxFilter implements Filter { } ``` -Or: +Or: ```java import org.apache.dubbo.common.extension.Activate; import org.apache.dubbo.rpc.Filter; -@Activate("xxx") // when configed xxx parameter and the parameter has a valid value,the SPI is activated,for example configed cache="lru",auto acitivate CacheFilter。 +@Activate("xxx") // when configed xxx parameter and the parameter has a valid value,the SPI is activated, for example configed cache="lru", auto acitivate CacheFilter. public class XxxFilter implements Filter { // ... } ``` -Or: +Or: ```java import org.apache.dubbo.common.extension.Activate; import org.apache.dubbo.rpc.Filter; -@Activate(group = "provider", value = "xxx") // only activate for provider,group can be "provider" or "consumer" +@Activate(group = "provider", value = "xxx") // only activate for provider, group can be "provider" or "consumer" public class XxxFilter implements Filter { // ... } ``` -[^1]: Note:The config file here is in you own jar file,not in dubbo release jar file,Dubbo will scan all jar files for the same filename in ClassPath and merge together then -[^2]: Note:SPI will be loaded in singleton pattern(Please ensure thread safety ),cached in `ExtensionLoader` +[^1]: Note: The config file here is in you own jar file, not in dubbo release jar file, Dubbo will scan all jar files with the same filename in classpath and then merge them together +[^2]: Note: SPI will be loaded in singleton pattern(Please ensure thread safety), cached in `ExtensionLoader` diff --git a/docs/zh-cn/dev/SPI.md b/docs/zh-cn/dev/SPI.md index c14943c..4f3927b 100644 --- a/docs/zh-cn/dev/SPI.md +++ b/docs/zh-cn/dev/SPI.md @@ -116,7 +116,7 @@ public class RaceCarMaker implements CarMaker { } ``` -`ExtensionLoader` 加载 `CarMaker` 的扩展点实现 `RaceCar` 时,`setWheelMaker` 方法的 `WheelMaker` 也是扩展点则会注入 `WheelMaker` 的实现。 +`ExtensionLoader` 加载 `CarMaker` 的扩展点实现 `RaceCarMaker` 时,`setWheelMaker` 方法的 `WheelMaker` 也是扩展点则会注入 `WheelMaker` 的实现。 这里带来另一个问题,`ExtensionLoader` 要注入依赖扩展点时,如何决定要注入依赖扩展点的哪个实现。在这个示例中,即是在多个`WheelMaker` 的实现中要注入哪个。