{"id":237,"date":"2007-09-26T14:45:16","date_gmt":"2007-09-26T06:45:16","guid":{"rendered":"https:\/\/lifeparty.idv.tw\/blog\/archives\/237"},"modified":"2007-09-26T14:52:25","modified_gmt":"2007-09-26T06:52:25","slug":"%e6%b5%81%e7%a8%8b%e8%88%87%e4%ba%a4%e6%98%93%e7%9a%84%e6%95%b4%e5%90%88%ef%bc%88%e5%85%b6%e4%ba%8c%ef%bc%89","status":"publish","type":"post","link":"https:\/\/lifeparty.idv.tw\/blog\/archives\/237","title":{"rendered":"\u6d41\u7a0b\u8207\u4ea4\u6613\u7684\u6574\u5408\uff08\u5176\u4e8c\uff09"},"content":{"rendered":"<p><a href=\"https:\/\/lifeparty.idv.tw\/blog\/archives\/30\">\u4e0a\u6b21<\/a>\u63d0\u5230\u7528<a href=\"http:\/\/www.martinfowler.com\/eaaCatalog\/serviceLayer.html\">\u670d\u52d9\u5c64<\/a>\u7684\u6982\u5ff5\u6574\u5408\u696d\u52d9\u6d41\u7a0b\u8207\u529f\u80fd\u6027\u4ea4\u6613\uff0c\u4e26\u6307\u51fa\u56e0\u61c9<a href=\"http:\/\/en.wikipedia.org\/wiki\/Enterprise_application_integration\">\u4ea4\u6613\u6d41\u7a0b\u6574\u5408<\/a>\u7684\u975e\u540c\u6b65\u547c\u53eb\u8003\u91cf\u7684\u5169\u7a2e\u6280\u8853\u5be6\u4f5c\u65b9\u5f0f\uff0c\u4e5f\u5c31\u662f <a href=\"http:\/\/en.wikipedia.org\/wiki\/Database\">database<\/a> sharing \u8207 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Message_queue\">message queue<\/a> \u7684\u4e0d\u540c\u505a\u6cd5\u3002\u5169\u7a2e\u505a\u6cd5\u6703\u6b8a\u9014\u540c\u6b78\uff0c\u6700\u5f8c\u6703\u4f9d\u64da\u8655\u7406\u72c0\u614b\uff0c\u547c\u53eb\u5f8c\u7aef\u7684\u670d\u52d9\u9032\u884c\u5f8c\u7e8c\u7cfb\u7d71\u4f5c\u696d\u3002<\/p>\n<p>\u65e2\u7136\u5169\u7a2e\u505a\u6cd5\u6703\u6b8a\u9014\u540c\u6b78\uff0c\u90a3\u9ebc\u5728\u8a2d\u8a08\u4e0a\uff0c\u53ef\u4e0d\u53ef\u4ee5\u8a2d\u8a08\u51fa\u540c\u6642\u9069\u7528\u4e0d\u540c\u5be6\u4f5c\u65b9\u6cd5\u7684\u975e\u540c\u6b65\u6a5f\u5236\u5462\uff1f\u4f9d\u64da\u9019\u6a23\u7684\u8a2d\u8a08\u601d\u8def\uff0c\u6211\u5011\u6703\u5e0c\u671b\u628a\u6703\u8b8a\u52d5\u7684\u90e8\u5206\u7528\u754c\u9762\u5c01\u88dd\u8d77\u4f86\uff0c\u5982\u4e0b\u5716\u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/lifeparty.idv.tw\/blog\/wp-content\/uploads\/2007\/09\/service-activator1.png\" \/><\/p>\n<p>\u5728\u4e0a\u5716\u7684\u8a2d\u8a08\u4e2d\uff0c\u6211\u5011\u5b9a\u7fa9\u4e86\u4e00\u500b ServiceEvent\uff0c\u7528\u4ee5\u8a18\u9304\u4ea4\u6613\u8b58\u5225\u78bc\u3001\u4ea4\u6613\u968e\u6bb5\u4ee3\u78bc\u53ca\u6d41\u7a0b\u4ee3\u78bc\u7b49\u8cc7\u8a0a\uff0c\u5176\u4e2d\u6d41\u7a0b\u4ee3\u78bc\u7684\u76ee\u7684\u53ef\u63d0\u4f9b\u7cfb\u7d71\u9032\u884c\u66f4\u7cbe\u7d30\u7684\u63a7\u5236\uff0c\u800c\u4ea4\u6613\u8b58\u5225\u78bc\u53ca\u4ea4\u6613\u968e\u6bb5\u4ee3\u78bc\u5247\u662f\u7528\u4ee5\u53d6\u5f97\u4ea4\u6613\u76ee\u524d\u8655\u7406\u72c0\u614b\u4ee5\u8b93\u7cfb\u7d71\u7e7c\u7e8c\u8655\u7406\u4ea4\u6613\u7684\u5f8c\u7e8c\u52d5\u4f5c\u3002<\/p>\n<p>ServiceEvent \u7531 EventAdvice \u7522\u751f\uff0c\u4e26\u7531 EventListener \u8b80\u53d6\uff0c\u800c\u50b3\u9001\u53ca\u63a5\u6536 ServiceEvent \u7684\u4efb\u52d9\u5247\u4ea4\u7531\u5be6\u4f5c EventSender \u53ca EventReader \u7684\u985e\u5225\u4f86\u8655\u7406\uff0c\u5982\u6b64\u4fbf\u53ef\u9054\u5230\u4e0d\u6703\u56e0\u70ba\u4e0d\u540c\u7684\u5be6\u4f5c\u65b9\u5f0f\u800c\u66f4\u52d5\u5230\u8a2d\u8a08\u3002<!--more--><\/p>\n<p>\u7576 EventListener \u6210\u529f\u8b80\u53d6 ServiceEvent \u5f8c\uff0c\u5247\u59d4\u8a17 ServiceActivator \u4f86\u547c\u53eb\u5f8c\u7e8c\u670d\u52d9\u3002\u800c\u70ba\u4e86\u907f\u514d\u5be6\u4f5c ServiceActivator \u7684\u985e\u5225\u8207\u5f8c\u7aef\u670d\u52d9\u7684\u76f8\u4e92\u8026\u548c\uff0c\u6211\u5011\u8a2d\u8a08\u4e86 MappingActivator \u4e26\u805a\u5408\u591a\u500b ServiceAction \u4f86\u89e3\u8026\uff0c\u5373\u4f9d\u64da\u4ea4\u6613\u7684\u4ea4\u6613\u968e\u6bb5\u4ee3\u78bc\u3001\u6d41\u7a0b\u4ee3\u78bc\u7b49\u8cc7\u8a0a\uff0c\u900f\u904e ServiceAction \u7684\u5be6\u4f5c\u547c\u53eb\u5f8c\u7aef\u670d\u52d9\uff0c\u800c\u958b\u767c\u8005\u53ea\u8981\u5728\u8a2d\u5b9a\u6a94\u4e2d\u8a18\u9304\u5176\u6620\u5c0d\u8cc7\u8a0a\uff0c\u800c\u4e0d\u9808\u5beb\u6b7b\u5728 ServiceActivator \u7684\u5be6\u4f5c\u7576\u4e2d\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u529f\u80fd\u6027\u4ea4\u6613\u53ea\u8981\u5728\u5176\u4ea4\u6613\u78ba\u8a8d\u5f8c\uff0c\u900f\u904e EventAdvice \u901a\u77e5\u7cfb\u7d71\u555f\u52d5\u9577\u6642\u9593\u4ea4\u6613\u7684\u5f8c\u7e8c\u529f\u80fd\u6027\u4ea4\u6613\uff0c\u5c31\u53ef\u4ee5\u9054\u5230\u4ea4\u6613\u6d41\u7a0b\u7684\u6574\u5408\u3002\u7136\u800c\uff0c\u9019\u6a23\u505a\u5176\u5be6\u6709\u9ede\u7f8e\u4e2d\u4e0d\u8db3\uff0c\u6bcf\u500b\u529f\u80fd\u6027\u4ea4\u6613\u7684\u670d\u52d9\u90fd\u5fc5\u9808\u984d\u5916\u547c\u53eb EventAdvice\uff0c\u9019\u5728\u696d\u52d9\u9818\u57df\u908f\u8f2f\u4e0a\u4f3c\u4e4e\u6709\u9ede\u4e0d\u81ea\u7136\uff0c\u96d6\u7136\u5b83\u662f\u5fc5\u8981\u4e4b\u7cfb\u7d71\u7d1a\u670d\u52d9\uff0c\u4f46\u5169\u8005\u5982\u679c\u53ef\u4ee5\u5728<a href=\"http:\/\/en.wikipedia.org\/wiki\/Separation_of_concerns\">\u95dc\u5207\u9ede\u4e0a\u505a\u500b\u5206\u96e2<\/a>\uff0c\u9019\u6a23\u5be6\u505a\u670d\u52d9\u7684\u4eba\u54e1\u5c31\u53ef\u4ee5\u4e0d\u9808\u7406\u6703\u7cfb\u7d71\u9762\u7684\u554f\u984c\u4e86\u3002<\/p>\n<p>\u9019\u6a23\u7684\u8a2d\u8a08\u8003\u91cf\u53ef\u5229\u7528 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Aspect-oriented_programming\">AOP<\/a> \u7684\u8a2d\u8a08\u6982\u5ff5\u4f86\u4e88\u4ee5\u652f\u6301\u3002\u5c07\u670d\u52d9\u50b3\u8a0a\u7684\u7cfb\u7d71\u670d\u52d9\u52a0\u5165\u81f3\u696d\u52d9\u670d\u52d9\u7684\u6a2a\u5207\u9762\u4e2d\uff0c\u4fbf\u53ef\u8f15\u6613\u5730\u9054\u6210\u95dc\u5207\u9ede\u5206\u96e2\u7684\u8a2d\u8a08\u76ee\u6a19\uff0c\u5be6\u4f5c\u670d\u52d9\u7684\u958b\u767c\u8005\u4e0d\u9808\u7406\u6703\u670d\u52d9\u50b3\u8a0a\u7684\u554f\u984c\uff0c\u53d6\u800c\u4ee3\u4e4b\u7684\u662f\u5728\u914d\u7f6e\u904e\u7a0b\u4e2d\u5c07\u670d\u52d9\u50b3\u8a0a\u7684\u89c0\u9ede\u7e54\u5165\u6240\u6709\u696d\u52d9\u670d\u52d9\u4e2d\uff0c\u800c\u5f62\u6210\u5c07\u6574\u9ad4\u7e54\u5165\u90e8\u5206\u7684<a href=\"http:\/\/en.wikipedia.org\/wiki\/Holography\">\u5168\u50cf\u5716<\/a>\u7d44\u7e54\u7684\u8907\u96dc\u6027\u7cfb\u7d71\u6709\u6a5f\u9ad4\u3002<\/p>\n<p>\u696d\u52d9\u670d\u52d9\u5176\u5be6\u672c\u8eab\u662f\u500b\u754c\u9762\uff0c\u5176\u5be6\u4f5c\u53ef\u5c08\u6ce8\u65bc\u696d\u52d9\u9818\u57df\u4e0a\uff0c\u800c\u7cfb\u7d71\u7d1a\u670d\u52d9\u4e5f\u85c9\u7531<a href=\"http:\/\/en.wikipedia.org\/wiki\/Join_point\">\u52a0\u5165\u9ede<\/a>\u4ee5\u7d50\u5408<a href=\"http:\/\/en.wikipedia.org\/wiki\/Aspect_%28computer_science%29\">\u4e0d\u540c\u5c64\u9762\u7684\u89c0\u9ede<\/a>\uff0c\u5982\u65e5\u8a8c\u3001\u4ea4\u6613\u7ba1\u7406\u3001\u7570\u5e38\u8655\u7406\u3001\u4ee5\u53ca\u6b64\u8655\u6240\u63d0\u5230\u7684\u670d\u52d9\u50b3\u8a0a\u7b49\u3002EventAdvice \u5728\u6b64\u8655\u662f\u540d\u7b26\u5176\u5be6\u7684\u56e0\u61c9\u50b3\u8a0a\u670d\u52d9\u89c0\u9ede\u6240\u5be6\u4f5c\u7684<a href=\"http:\/\/en.wikipedia.org\/wiki\/Advice_in_aspect-oriented_programming\">\u88dd\u7f6e<\/a>\uff0c\u4e00\u500b\u7576\u696d\u52d9\u670d\u52d9\u547c\u53eb\u5b8c\u6210\u5f8c\u6703\u81ea\u52d5\u547c\u53eb\u7684\u88dd\u7f6e\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u5584\u7528\u8a2d\u8a08\u4e0a\u7684\u5de7\u601d\uff0c\u6211\u5011\u6703\u8b93\u6d41\u7a0b\u8207\u4ea4\u6613\u7684\u6574\u5408\u8b8a\u5f97\u55ae\u7d14\u800c\u7c21\u55ae\u3002\u7576\u7136\uff0c\u5be6\u4f5c\u4e0a\u9084\u6709\u4e00\u4e9b\u5c0f\u7d30\u7bc0\u9650\u65bc\u7bc7\u5e45\u7121\u6cd5\u5728\u6b64\u8a73\u8ff0\uff0c\u4f8b\u5982 EventAdvice \u5982\u4f55\u91dd\u5c0d\u4e0d\u540c\u696d\u52d9\u670d\u52d9\u64cd\u4f5c\u7684\u7c3d\u7ae0\u7522\u751f\u6b63\u78ba\u7684 ServiceEvent\u3001\u5c07 ServiceAction \u5143\u4ef6\u5316\u7684\u5be6\u4f5c\u8b70\u984c\uff0c\u4f46\u9019\u4e9b\u90fd\u4e0d\u662f\u76f8\u7576\u8907\u96dc\u7684\u554f\u984c\uff1a\u524d\u8005\u53ef\u61c9\u7528 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Abstract_factory_pattern\">abstract factory pattern<\/a> \u89e3\u6c7a\u7269\u4ef6\u751f\u6210\u7684\u554f\u984c\uff0c\u5f8c\u8005\u53ef\u904b\u7528<a href=\"http:\/\/en.wikipedia.org\/wiki\/Composite_pattern\">\u8907\u5408\u7269\u4ef6<\/a>\u7684\u65b9\u5f0f\u8a2d\u8a08\u6d41\u7a0b\u63a7\u5236\u5143\u4ef6\u3002<strong>\u8a2d\u8a08\u7684\u91cd\u9ede\u9084\u662f\u5728\u628a\u6703\u8b8a\u52d5\u7684\u5730\u65b9\u5c01\u88dd\u8d77\u4f86<\/strong>\uff0c\u6240\u8b02\u300c\u901a\u5176\u8b8a\uff0c\u4f7f\u6c11\u4e0d\u5026\uff1b\u795e\u800c\u5316\u4e4b\uff0c\u4f7f\u6c11\u5b9c\u4e4b\u300d\uff0c\u9019\u4e5f\u6b63\u662f\u6613\u7aae\u5247\u8b8a\uff0c\u8b8a\u5247\u901a\uff0c\u901a\u5247\u4e45\u7684\u771f\u7406\u5440\u3002<\/p>\n<p class=\"poweredbyperformancing\">Powered by <a href=\"http:\/\/scribefire.com\/\">ScribeFire<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u6b21\u63d0\u5230\u7528\u670d\u52d9\u5c64\u7684\u6982\u5ff5\u6574\u5408\u696d\u52d9\u6d41\u7a0b\u8207\u529f\u80fd\u6027\u4ea4\u6613\uff0c\u4e26\u6307\u51fa\u56e0\u61c9\u4ea4\u6613\u6d41\u7a0b\u6574\u5408\u7684\u975e\u540c\u6b65\u547c &hellip; <a href=\"https:\/\/lifeparty.idv.tw\/blog\/archives\/237\">\u95b1\u8b80\u5168\u6587 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,8,37,19,3],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-29","category-8","category-37","category-19","category-3"],"_links":{"self":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/comments?post=237"}],"version-history":[{"count":0,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts\/237\/revisions"}],"wp:attachment":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/media?parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/categories?post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/tags?post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}