{"id":1057,"date":"2019-05-27T19:19:46","date_gmt":"2019-05-27T11:19:46","guid":{"rendered":"http:\/\/www.rain1024.com\/?p=1057"},"modified":"2023-08-07T20:57:25","modified_gmt":"2023-08-07T12:57:25","slug":"aritcle151","status":"publish","type":"post","link":"http:\/\/rain1024.com\/index.php\/2019\/05\/27\/aritcle151\/","title":{"rendered":"RMI\u4e0eRPC\u7684\u533a\u522b"},"content":{"rendered":"<h1>Java RMI\u4e0eRPC\u7684\u533a\u522b<\/h1>\n<p>\u4e00\uff1aRPC \u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528<\/p>\n<p>RPC\uff08Remote Procedure Call Protocol\uff09\u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528\u534f\u8bae\uff0c\u901a\u8fc7\u7f51\u7edc\u4ece\u8fdc\u7a0b\u8ba1\u7b97\u673a\u4e0a\u8bf7\u6c42\u8c03\u7528\u67d0\u79cd\u670d\u52a1\u3002<\/p>\n<p>\u4e00\u6b21RPC\u8c03\u7528\u7684\u8fc7\u7a0b\u5927\u6982\u670910\u6b65\uff1a<\/p>\n<p>1.\u6267\u884c\u5ba2\u6237\u7aef\u8c03\u7528\u8bed\u53e5\uff0c\u4f20\u9001\u53c2\u6570<\/p>\n<p>2.\u8c03\u7528\u672c\u5730\u7cfb\u7edf\u53d1\u9001\u7f51\u7edc\u6d88\u606f<\/p>\n<p>3.\u6d88\u606f\u4f20\u9001\u5230\u8fdc\u7a0b\u4e3b\u673a<\/p>\n<p>4.\u670d\u52a1\u5668\u5f97\u5230\u6d88\u606f\u5e76\u53d6\u5f97\u53c2\u6570<\/p>\n<p>5.\u6839\u636e\u8c03\u7528\u8bf7\u6c42\u4ee5\u53ca\u53c2\u6570\u6267\u884c\u8fdc\u7a0b\u8fc7\u7a0b\uff08\u670d\u52a1\uff09<\/p>\n<p>6.\u6267\u884c\u8fc7\u7a0b\u5b8c\u6bd5\uff0c\u5c06\u7ed3\u679c\u8fd4\u56de\u670d\u52a1\u5668\u53e5\u67c4<\/p>\n<p>7.\u670d\u52a1\u5668\u53e5\u67c4\u8fd4\u56de\u7ed3\u679c\uff0c\u8c03\u7528\u8fdc\u7a0b\u4e3b\u673a\u7684\u7cfb\u7edf\u7f51\u7edc\u670d\u52a1\u53d1\u9001\u7ed3\u679c<\/p>\n<p>8.\u6d88\u606f\u4f20\u56de\u672c\u5730\u4e3b\u673a<\/p>\n<p>9.\u5ba2\u6237\u7aef\u53e5\u67c4\u7531\u672c\u5730\u4e3b\u673a\u7684\u7f51\u7edc\u670d\u52a1\u63a5\u6536\u6d88\u606f<\/p>\n<p>10.\u5ba2\u6237\u7aef\u63a5\u6536\u5230\u8c03\u7528\u8bed\u53e5\u8fd4\u56de\u7684\u7ed3\u679c\u6570\u636e<\/p>\n<p>\u4e8c\uff1aRMI \u8fdc\u7a0b\u65b9\u6cd5\u8c03\u7528<\/p>\n<p>RMI:\u8fdc\u7a0b\u65b9\u6cd5\u8c03\u7528(Remote Method Invocation)\u3002\u80fd\u591f\u8ba9\u5728\u5ba2\u6237\u7aef <strong>Java<\/strong> \u865a\u62df\u673a\u4e0a\u7684\u5bf9\u8c61\u50cf\u8c03\u7528\u672c\u5730\u5bf9\u8c61\u4e00\u6837\u8c03\u7528\u670d\u52a1\u7aefjava \u865a\u62df\u673a\u4e2d\u7684\u5bf9\u8c61\u4e0a\u7684\u65b9\u6cd5\u3002<\/p>\n<p>RMI\u8fdc\u7a0b\u8c03\u7528\u6b65\u9aa4\uff1a<\/p>\n<p>1\uff0c\u5ba2\u6237\u8c03\u7528\u5ba2\u6237\u7aef\u8f85\u52a9\u5bf9\u8c61stub\u4e0a\u7684\u65b9\u6cd5<\/p>\n<p>2\uff0c\u5ba2\u6237\u7aef\u8f85\u52a9\u5bf9\u8c61stub\u6253\u5305\u8c03\u7528\u4fe1\u606f\uff08\u53d8\u91cf\uff0c\u65b9\u6cd5\u540d\uff09\uff0c\u901a\u8fc7\u7f51\u7edc\u53d1\u9001\u7ed9\u670d\u52a1\u7aef\u8f85\u52a9\u5bf9\u8c61skeleton<\/p>\n<p>3\uff0c\u670d\u52a1\u7aef\u8f85\u52a9\u5bf9\u8c61skeleton\u5c06\u5ba2\u6237\u7aef\u8f85\u52a9\u5bf9\u8c61\u53d1\u9001\u6765\u7684\u4fe1\u606f\u89e3\u5305\uff0c\u627e\u51fa\u771f\u6b63\u88ab\u8c03\u7528\u7684\u65b9\u6cd5\u4ee5\u53ca\u8be5\u65b9\u6cd5\u6240\u5728\u5bf9\u8c61<\/p>\n<p>4\uff0c\u8c03\u7528\u771f\u6b63\u670d\u52a1\u5bf9\u8c61\u4e0a\u7684\u771f\u6b63\u65b9\u6cd5\uff0c\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u670d\u52a1\u7aef\u8f85\u52a9\u5bf9\u8c61skeleton<\/p>\n<p>5\uff0c\u670d\u52a1\u7aef\u8f85\u52a9\u5bf9\u8c61\u5c06\u7ed3\u679c\u6253\u5305\uff0c\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u8f85\u52a9\u5bf9\u8c61stub<\/p>\n<p>6\uff0c\u5ba2\u6237\u7aef\u8f85\u52a9\u5bf9\u8c61\u5c06\u8fd4\u56de\u503c\u89e3\u5305\uff0c\u8fd4\u56de\u7ed9\u8c03\u7528\u8005<\/p>\n<p>7\uff0c\u5ba2\u6237\u83b7\u5f97\u8fd4\u56de\u503c<\/p>\n<p>\u4e09\uff1aRPC\u4e0eRMI\u7684\u533a\u522b<\/p>\n<p>1\uff1a\u65b9\u6cd5\u8c03\u7528\u65b9\u5f0f\u4e0d\u540c\uff1a<\/p>\n<p><strong>RMI\u4e2d\u662f\u901a\u8fc7\u5728\u5ba2\u6237\u7aef\u7684Stub\u5bf9\u8c61\u4f5c\u4e3a\u8fdc\u7a0b\u63a5\u53e3\u8fdb\u884c\u8fdc\u7a0b\u65b9\u6cd5\u7684\u8c03\u7528<\/strong> \u3002 <strong>\u6bcf\u4e2a\u8fdc\u7a0b\u65b9\u6cd5\u90fd\u5177\u6709\u65b9\u6cd5\u7b7e\u540d<\/strong> \u3002\u5982\u679c\u4e00\u4e2a\u65b9\u6cd5\u5728\u670d\u52a1\u5668\u4e0a\u6267\u884c\uff0c\u4f46\u662f <strong>\u6ca1\u6709\u76f8\u5339\u914d\u7684\u7b7e\u540d\u88ab\u6dfb\u52a0\u5230\u8fd9\u4e2a\u8fdc\u7a0b\u63a5\u53e3(stub)\u4e0a\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65b0\u65b9\u6cd5\u5c31\u4e0d\u80fd\u88abRMI\u5ba2\u6237\u65b9\u6240\u8c03\u7528<\/strong> \u3002<\/p>\n<p><strong>RPC\u4e2d\u662f\u901a\u8fc7\u7f51\u7edc\u670d\u52a1\u534f\u8bae\u5411\u8fdc\u7a0b\u4e3b\u673a\u53d1\u9001\u8bf7\u6c42<\/strong> \uff0c\u8bf7\u6c42\u5305\u542b\u4e86\u4e00\u4e2a\u53c2\u6570\u96c6\u548c\u4e00\u4e2a\u6587\u672c\u503c\uff0c\u901a\u5e38\u5f62\u6210\u201cclassname.methodname(\u53c2\u6570\u96c6)\u201d\u7684\u5f62\u5f0f\u3002RPC\u8fdc\u7a0b\u4e3b\u673a\u5c31\u53bb\u641c\u7d22\u4e0e\u4e4b\u76f8\u5339\u914d\u7684\u7c7b\u548c\u65b9\u6cd5\uff0c\u627e\u5230\u540e\u5c31\u6267\u884c\u65b9\u6cd5\u5e76\u628a\u7ed3\u679c\u7f16\u7801\uff0c\u901a\u8fc7\u7f51\u7edc\u534f\u8bae\u53d1\u56de\u3002<\/p>\n<p>2\uff1a\u9002\u7528\u8bed\u8a00\u8303\u56f4\u4e0d\u540c\uff1a<\/p>\n<p>RMI\u53ea\u7528\u4e8eJava\uff1b<\/p>\n<p>RPC\u662f\u7f51\u7edc\u670d\u52a1\u534f\u8bae\uff0c\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u548c\u8bed\u8a00\u65e0\u5173\u3002<\/p>\n<p>3\uff1a\u8c03\u7528\u7ed3\u679c\u7684\u8fd4\u56de\u5f62\u5f0f\u4e0d\u540c\uff1a<\/p>\n<p>Java\u662f\u9762\u5411\u5bf9\u8c61\u7684\uff0c\u6240\u4ee5RMI\u7684\u8c03\u7528\u7ed3\u679c\u53ef\u4ee5\u662f\u5bf9\u8c61\u7c7b\u578b\u6216\u8005\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff1b<\/p>\n<pre><code>RMI\u7684\u7ed3\u679c\u7edf\u4e00\u7531 **\u5916\u90e8\u6570\u636e\u8868\u793a (External Data Representation, XDR) \u8bed\u8a00** \u8868\u793a\uff0c\u8fd9\u79cd\u8bed\u8a00\u62bd\u8c61\u4e86\u5b57\u8282\u5e8f\u7c7b\u548c\u6570\u636e\u7c7b\u578b\u7ed3\u6784\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Java RMI\u4e0eRPC\u7684\u533a\u522b \u4e00\uff1aRPC \u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528 RPC\uff08Remote Procedure Call \u2026 <span class=\"read-more\"><a href=\"http:\/\/rain1024.com\/index.php\/2019\/05\/27\/aritcle151\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-1057","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/1057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/comments?post=1057"}],"version-history":[{"count":1,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/1057\/revisions"}],"predecessor-version":[{"id":1380,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/1057\/revisions\/1380"}],"wp:attachment":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media?parent=1057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/categories?post=1057"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/tags?post=1057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}