dubbo-exploration journey (1) --- a preliminary exploration of the periphery

     Dubbo-A product of Alibaba, in order to implement SOA (Service Oriented Architecture) tools. I have been paying attention to Ali technology, and at the same time, I have also increased reserves for the following work. So I decided to enter Dubbo and explore it. After reading the articles written by other friends on the Internet, I feel that I am still in the fog, so I plan to write some content myself, one is to organize my thoughts; A good memory is not as good as a bad writing.
     There is still a lot of knowledge involved in Dubbo, so I will not enter the source code first, but first take a look and sort out the knowledge involved. Clear out the peripheral positions first, before entering the core position!
     Peripheral:
     1: JDK dynamic proxy:
This can refer to the website: http://blog.jobbole.com/104433/. (Thank you to the author: @博乐在线 - looking for "four-leaf clover") It is written in great detail and also comes with an analysis of the JDK source code.
     2: Javassist (Java bytecode generation open source framework):
import javassist.ClassPool;  
import javassist.CtClass;  
import javassist.CtMethod;  
import javassist.CtNewMethod;  
public class MyJavassist {  
    public static void main(String[] args) throws Exception {  
        ClassPool pool = ClassPool.getDefault();  
        //Create Test class       
        CtClass cc= pool.makeClass("com.jishuaige.Test");  
        //Define the test method  
        CtMethod method = CtNewMethod.make("public void test(){}", cc);  
        // insert method code  
        method.insertBefore("System.out.println(\"test.....\");");  
        cc.addMethod(method);   
        cc.writeFile("d://myJavassist");  
    }  
}  

     3: Java spi mechanism (emphasis):
  The mechanism provided by Java's SPI (Service Provider Interface): We define the interface standard of the service, and let each implementer complete their own implementation according to the interface standard.
  JDK uses ServiceLoader to find each implementation class. It traverses all jar packages to find the file content in the META-INF/services directory to load each implementation class. This is similar to the idea of ​​IOC, which dynamically injects implementation classes.
  Using SPI must follow its standards: 1) Create a folder: META-INF/service, and place it on the classpath. 2) The configuration file is placed under META-INF/service, and the file name must be the full path of the implemented interface.
  Disadvantages of ServiceLoader: 1) ServiceLoader uses lazy loading to load all the implementation classes of the interface. If you don't want to use some implementation class, but it's loaded and instantiated as well, that's a pain in the ass, I just load whatever I want to use. 2) The way to obtain an implementation class is not convenient enough, and can only be obtained in the form of Iterator.
      Well, here is a brief introduction to the peripheral knowledge that I have seen and learned now (I will come back to add it later, and everyone is welcome to analyze it together).
      Let's start to enter dubbo: how to use SPI in dubbo.
     


   
   

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327045654&siteId=291194637