URL:定義了調用的url如協議、協議、參數等信息
public final class URL implements Serializable {
private static final long serialVersionUID = -1985165475234910535L;
private final String protocol;
private final String username;
private final String password;
// by default, host to registry
private final String host;
// by default, port to registry
private final int port;
private final String path;
private final Map<String, String> parameters;
// ==== cache ====
private volatile transient Map<String, Number> numbers;
private volatile transient Map<String, URL> urls;
private volatile transient String ip;
private volatile transient String full;
private volatile transient String identity;
private volatile transient String parameter;
private volatile transient String string;
}
Invocation:是會話域,它持有調用過程中的變量,比如方法名,參數等。
public interface Invocation {
String getMethodName();
Class<?>[] getParameterTypes();
Object[] getArguments();
Map<String, String> getAttachments();
String getAttachment(String key);
String getAttachment(String key, String defaultValue);
Invoker<?> getInvoker();
}
Invoker:是實體域,它是 Dubbo 的核心模型,其它模型都向它靠擾,或轉換成它,它代表一個可執行體,可向它發起 invoke 調用,它有可能是一個本地的實現,也可能是一個遠程的實現,也可能一個集羣實現。
public interface Invoker<T> extends Node {
/**
* @return service interface.
*/
Class<T> getInterface();
Result invoke(Invocation invocation) throws RpcException;
}
服務提供者暴露一個服務的詳細過程
服務消費者消費一個服務的詳細過程
Protocol:是服務域,它是 Invoker 暴露和引用的主功能入口,它負責 Invoker 的生命週期管理。
@SPI("dubbo")
public interface Protocol {
int getDefaultPort();
@Adaptive
<T> Exporter<T> export(Invoker<T> invoker) throws RpcException;
@Adaptive
<T> Invoker<T> refer(Class<T> type, URL url) throws RpcException;
void destroy();
}