{"id":216955,"date":"2021-05-08T09:43:10","date_gmt":"2021-05-08T01:43:10","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=216955"},"modified":"2021-04-25T09:44:45","modified_gmt":"2021-04-25T01:44:45","slug":"the-role-of","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/the-role-of.html","title":{"rendered":"Java \u8bbe\u8ba1\u6a21\u5f0f\u4e4b\u5916\u89c2\u6a21\u5f0f\u7684\u4f5c\u7528"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nJava \u8bbe\u8ba1\u6a21\u5f0f\u2014\u2014\u5916\u89c2\u6a21\u5f0f:\u4e3a\u5b50\u7cfb\u7edf\u4e2d\u7684\u4e00\u7ec4\u63a5\u53e3\u63d0\u4f9b\u4e00\u4e2a\u4e00\u81f4\u7684\u754c\u9762,\u8be5\u6a21\u5f0f\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9ad8\u5c42\u63a5\u53e3,\u8fd9\u4e2a\u63a5\u53e3\u4f7f\u8fd9\u4e2a\u5b50\u7cfb\u7edf\u66f4\u52a0\u5bb9\u6613\u4f7f\u7528\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u5916\u89c2\u6a21\u5f0f\u7684\u4f5c\u7528<\/strong><\/div>\n
    \n
  1. \u677e\u6563\u8026\u5408\uff0c\u5916\u89c2\u6a21\u5f0f\u677e\u6563\u4e86\u5ba2\u6237\u7aef\u4e0e\u5b50\u7cfb\u7edf\u7684\u8026\u5408\u5173\u7cfb\uff0c\u8ba9\u5b50\u7cfb\u7edf\u5185\u90e8\u7684\u6a21\u5757\u80fd\u66f4\u5bb9\u6613\u6269\u5c55\u548c\u7ef4\u62a4\u3002<\/li>\n
  2. \u7b80\u5355\u6613\u7528\uff0c\u5916\u89c2\u6a21\u5f0f\u8ba9\u5b50\u7cfb\u7edf\u66f4\u52a0\u6613\u7528\uff0c\u5ba2\u6237\u7aef\u4e0d\u518d\u9700\u8981\u4e86\u89e3\u5b50\u7cfb\u7edf\u5185\u90e8\u7684\u5b9e\u73b0\uff0c\u4e5f\u4e0d\u9700\u8981\u8ddf\u4f17\u591a\u5b50\u7cfb\u7edf\u5185\u90e8\u7684\u6a21\u5757\u8fdb\u884c\u4ea4\u4e92\uff0c\u53ea\u9700\u8981\u8ddf\u95e8\u9762\u7c7b\u4ea4\u4e92\u5c31\u53ef\u4ee5\u4e86\u3002<\/li>\n
  3. \u66f4\u597d\u7684\u5212\u5206\u8bbf\u95ee\u5c42\u6b21-\u901a\u8fc7\u5408\u7406\u4f7f\u7528 Facade\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u5212\u5206\u8bbf\u95ee\u7684\u5c42\u6b21\u3002\u6709\u4e9b\u65b9\u6cd5\u662f\u5bf9\u7cfb\u7edf\u5916\u7684\uff0c\u6709\u4e9b\u65b9\u6cd5\u662f\u7cfb\u7edf\u5185\u90e8\u4f7f\u7528\u7684\u3002\u628a\u9700\u8981\u66b4\u9732\u7ed9\u5916\u90e8\u7684\u529f\u80fd\u96c6\u4e2d\u5230\u95e8\u9762\u4e2d\uff0c\u8fd9\u6837\u65e2\u65b9\u4fbf\u5ba2\u6237\u7aef\u4f7f\u7528\uff0c\u4e5f\u5f88\u597d\u5730\u9690\u85cf\u4e86\u5185\u90e8\u7684\u7ec6\u8282\u3002<\/li>\n<\/ol>\n
    \u5916\u89c2\u6a21\u5f0f\u7684\u89d2\u8272<\/strong><\/div>\n
      \n
    1. SubSystem: \u5b50\u7cfb\u7edf\u89d2\u8272\u3002\u8868\u793a\u4e00\u4e2a\u7cfb\u7edf\u7684\u5b50\u7cfb\u7edf\u6216\u6a21\u5757\u3002<\/li>\n
    2. Facade: \u5916\u89c2\u89d2\u8272\uff0c\u5ba2\u6237\u7aef\u901a\u8fc7\u64cd\u4f5c\u5916\u89c2\u89d2\u8272\u4ece\u800c\u8fbe\u5230\u63a7\u5236\u5b50\u7cfb\u7edf\u89d2\u8272\u7684\u76ee\u7684\u3002\u5bf9\u4e8e\u5ba2\u6237\u7aef\u6765\u8bf4\uff0c\u5916\u89c2\u89d2\u8272\u597d\u6bd4\u4e00\u9053\u5c4f\u969c\uff0c\u5bf9\u5ba2\u6237\u7aef\u5c4f\u853d\u4e86\u5b50\u7cfb\u7edf\u7684\u5177\u4f53\u5b9e\u73b0\u3002<\/li>\n<\/ol>\n
      \u5b9e\u4f8b\u63a2\u7a76<\/strong><\/div>\n

      \u5047\u8bbe\u4e00\u53f0\u7535\u8111\uff0c\u5b83\u5305\u542b\u4e86 CPU\uff08\u5904\u7406\u5668\uff09\uff0cMemory\uff08\u5185\u5b58\uff09 \uff0cDisk\uff08\u786c\u76d8\uff09\u8fd9\u51e0\u4e2a\u90e8\u4ef6\uff0c\u82e5\u60f3\u8981\u542f\u52a8\u7535\u8111\uff0c\u5219\u5148\u540e\u5fc5\u987b\u542f\u52a8 CPU\u3001Memory\u3001Disk\u3002\u5173\u95ed\u4e5f\u662f\u5982\u6b64\u3002<\/p>\n

      \u4f46\u662f\u5b9e\u9645\u4e0a\u6211\u4eec\u5728\u7535\u8111\u5f00\/\u5173\u673a\u65f6\u6839\u672c\u4e0d\u9700\u8981\u53bb\u64cd\u4f5c\u8fd9\u4e9b\u7ec4\u4ef6\uff0c\u56e0\u4e3a\u7535\u8111\u5df2\u7ecf\u5e2e\u6211\u4eec\u90fd\u5904\u7406\u597d\u4e86\uff0c\u5e76\u9690\u85cf\u4e86\u8fd9\u4e9b\u4e1c\u897f\u3002<\/p>\n

      \u8fd9\u4e9b\u7ec4\u4ef6\u597d\u6bd4\u5b50\u7cfb\u7edf\u89d2\u8272\uff0c\u800c\u7535\u8111\u5c31\u662f\u4e00\u4e2a\u5916\u89c2\u89d2\u8272\u3002<\/p>\n

      SubSystem \u5b50\u7cfb\u7edf\u89d2\u8272<\/strong><\/p>\n

      public class CPU {   \r\n    public void startup(){  \r\n        System.out.println(\"cpu startup!\");  \r\n    }  \r\n    public void shutdown(){  \r\n        System.out.println(\"cpu shutdown!\");  \r\n    }  \r\n}\r\n \r\npublic class Memory {    \r\n    public void startup(){  \r\n        System.out.println(\"memory startup!\");  \r\n    }  \r\n    public void shutdown(){  \r\n        System.out.println(\"memory shutdown!\");  \r\n    }  \r\n} \r\n \r\npublic class Disk {  \r\n    public void startup(){  \r\n        System.out.println(\"disk startup!\");  \r\n    }  \r\n    public void shutdown(){  \r\n        System.out.println(\"disk shutdown!\");  \r\n    }  \r\n}<\/pre>\n

      Facade \u5916\u89c2\u89d2\u8272<\/strong><\/p>\n

      public class Computer {  \r\n    private CPU cpu;  \r\n    private Memory memory;  \r\n    private Disk disk;  \r\n \r\n    public Computer(){  \r\n        cpu = new CPU();  \r\n        memory = new Memory();  \r\n        disk = new Disk();  \r\n    }  \r\n \r\n    public void startup(){  \r\n        System.out.println(\"start the computer!\");  \r\n        cpu.startup();  \r\n        memory.startup();  \r\n        disk.startup();  \r\n        System.out.println(\"start computer finished!\");  \r\n    }  \r\n \r\n    public void shutdown(){  \r\n        System.out.println(\"begin to close the computer!\");  \r\n        cpu.shutdown();  \r\n        memory.shutdown();  \r\n        disk.shutdown();  \r\n        System.out.println(\"computer closed!\");  \r\n    }  \r\n}<\/pre>\n

      \u5177\u4f53\u8c03\u7528\u5982\u4e0b\uff1a<\/p>\n

      Computer computer = new Computer();  \r\ncomputer.startup();  \r\ncomputer.shutdown();<\/pre>\n","protected":false},"excerpt":{"rendered":"

      \u677e\u6563\u8026\u5408\uff0c\u5916\u89c2\u6a21\u5f0f\u677e\u6563\u4e86\u5ba2\u6237\u7aef\u4e0e\u5b50\u7cfb\u7edf\u7684\u8026\u5408\u5173\u7cfb\uff0c\u8ba9\u5b50\u7cfb\u7edf\u5185\u90e8\u7684\u6a21\u5757\u80fd\u66f4\u5bb9\u6613\u6269\u5c55\u548c\u7ef4\u62a4\u3002 \u7b80\u5355\u6613\u7528\uff0c\u5916\u89c2\u6a21\u5f0f\u8ba9 […]<\/p>\n","protected":false},"author":1470,"featured_media":216957,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-216955","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/216955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1470"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=216955"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/216955\/revisions"}],"predecessor-version":[{"id":216959,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/216955\/revisions\/216959"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/216957"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=216955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=216955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=216955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}