
摘 要: 領域驅動開發(DDD)是完全基于內存的業務對象建模(In?Memory)方法,而目前的DDD框架不能完全覆蓋系統業務,也不成熟穩定,無法應用于實際項目的開發。在Spring框架的基礎上,實現了一個基于領域消息驅動和內存建模的DDD插件,在不影響目前系統架構的基礎上,讓項目實施完全兼容DDD設計。同時基于JDK和Disruptor并發框架實現的領域事件消息和領域對象緩存模型,有效地降低了系統的解耦關系,并提高了系統的整體性能及效率。
關鍵詞: 領域消息驅動; 內存建模; 領域事件; 領域緩存
中圖分類號: TN911?34; TP319 文獻標識碼: A 文章編號: 1004?373X(2015)24?0062?04
Design and implementation of light?weighted Spring?DDD plug?in driven by
domain message
WANG Wei1, HUANG Qiang2, 3
(1. Department of Electronic Business, Sichuan Finance and Economics Vocational College, Chengdu 610101, China;
2. College of transportation, Southwest Jiaotong University, Chengdu 610031, China;
3. College of Information and Engineering, Sichuan Agricultural University, Ya’an 625014, China)
Abstract: DDD (domain driven development) is entirely memory?based business object modeling (In?Memory) method, but the current DDD framework is not stable enough to cover the system business completely and can not be applied to the development of practical project. On the basis of Spring framework, the DDD plug?in based on domain message driving and memory modeling was realized, in which the implementation of the project is fully compatible with DDD design without affecting the current system architecture. The domain event message and domain object caching model based on JDK and Disruptor concurrency control framework can effectively reduce the decoupling relationship and improve the whole performance and efficiency of the system.
Keywords: domain message?driven; memory modeling; domain event; domain cache
0 引 言
領域建模(Domain Modeling,DM)的初期是基于對象關系映射的ORM(Object Relationship Mapping)技術。ORM通過數據庫與對象的數據映射,初步解決了關系與對象的不匹配問題[1],使系統設計分析人員能夠采用純粹的對象技術來解決領域問題。但是隨著業務分析的深入,ORM產生的貧血對象模型由于行為能力的缺失,讓系統又從對象模型退化為事務處理過程,與DM理論逐漸背離;隨后為了避免貧血模型的弊端而出現的充血模型,將業務與數據全部合并到領域模型中。在后來的幾年中,有很多框架都在充血模型的理論基礎上進行了大量實踐(如ROR,Grails,Spring Roo等),這些快速開發框架出現的初期在小型項目上應用非常成功。但是隨著業務增長,領域對象會急速膨脹,維護難度會急劇增加,讓系統處于一個不可控的狀態,并且業務和數據的領域整合會讓系統的結構變得模糊不清,給系統帶來另外的壓力,所以這類框架始終沒有能成功地應用到大型項目開發中去。……