{"id":43647196,"url":"https://github.com/leonlee/mde","last_synced_at":"2026-02-04T19:02:16.933Z","repository":{"id":142922385,"uuid":"381040358","full_name":"leonlee/mde","owner":"leonlee","description":"Metadata Driven Engine with COP and DDD in Java","archived":false,"fork":false,"pushed_at":"2025-04-25T02:33:31.000Z","size":320,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-25T03:33:03.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leonlee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-28T13:24:58.000Z","updated_at":"2025-04-25T02:33:35.000Z","dependencies_parsed_at":"2023-05-17T21:30:37.883Z","dependency_job_id":null,"html_url":"https://github.com/leonlee/mde","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/leonlee/mde","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonlee%2Fmde","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonlee%2Fmde/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonlee%2Fmde/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonlee%2Fmde/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leonlee","download_url":"https://codeload.github.com/leonlee/mde/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonlee%2Fmde/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29092985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T03:31:03.593Z","status":"ssl_error","status_checked_at":"2026-02-04T03:29:50.742Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-04T19:02:15.411Z","updated_at":"2026-02-04T19:02:16.923Z","avatar_url":"https://github.com/leonlee.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"**MDE**(**M**etadata-**D**riven **E**ngine)\nis an application engine that aims at implementing **Domain Driven Design** principles to help developers pay more attention to **Business Value**.\nIt's powered by **MetaData Driven Design** and **Composite Oriental Programming** to supports flexible and extensible architecture.\n\n#### Features:\n- COP as fundamental mechanism\n- Interface as Metadata\n- Composite is assembled at runtime\n- Dynamic customization and extension supporting\n\n### Requirements\n- JDK 1.8+\n\n### Changes\nplease check [Changes](CHANGELOG.md) .\n\n### MDE Modules\n\n#### Core\nCore module is base layer of MDE that implemented the COP and provided plugin mechanism for extensions. In short, It's a dynamic code assembler using ByteBuddy.\n- Path: core\n- Features:\n  - Composite\n  - Mixin\n  - Property\n  - Behavior\n  - Extension\n  - Delegate\n  - Spring boot integration(core-spring)\n\n#### Entity Engine\nEntity engine is a simple extension of Core module to support JDBI integration.\n- Path: entity-engine\n- Features:\n  - Entity\n  - Aggregate\n  - JdbiMixin\n  - Common Mixins\n  - Jdbi: SqlObject StringTemplate\n  - Spring boot integration(entity-engine-spring)\n  - Mustache template engine: [JMustache](https://github.com/samskivert/jmustache)\n\n#### Event Engine\nEvent Engine implemented event bus based on Guava event-bus that supports sync or async application pub/sub mechanism.\n- Path: event-engine\n- Features:\n  - EventHandlerRoot\n  - EventHandler\n  - EventMixin\n  - SyncPost/AsyncPost\n  - Spring Boot integration(event-engine-spring)\n\n#### FSM Engine\nFSM Engine extended standard Composite to FSM that support self-auto status transition according to events.\n- Path: fsm-engine\n- Features:\n  - FSM\n  - FsmAction\n  - FsmTransitionHandler\n\n### FAQ\n\n#### What's the composite?\n  Composite in COP just likes Object in OOP. It's an implementation of **Composition over inheritance** principle.\n  The Composite of MDE is assembled according to metadata that annotated with **@Composite** on the fly, and the definition of Composite is composed by **Mixins** that presents a code fragment.\n\n#### What's the mixin?\n  In object-oriented programming languages, a Mixin is a class that contains methods for use by other classes without having to be the parent class of those other classes. How those other classes gain access to the mixin's methods depends on the language. Mixins are sometimes described as being \"included\" rather than \"inherited\".\n\n  Definition: \u003cbr/\u003e\n  Mixins are a language concept that allows a programmer to inject some code into a class. Mixin programming is a style of software development, in which units of functionality are created in a class and then mixed in with other classes.\n  A mixin class acts as the parent class, containing the desired functionality. A subclass can then inherit or simply reuse this functionality, but not as a means of specialization. Typically, the mixin will export the desired functionality to a child class, without creating a rigid, single \"is a\" relationship. Here lies the important difference between the concepts of mixins and inheritance, in that the child class can still inherit all the features of the parent class, but, the semantics about the child \"being a kind of\" the parent need not be necessarily applied.\n\n  Advantages: \u003cbr/\u003e\n  1. It provides a mechanism for multiple inheritance by allowing multiple classes to use the common functionality, but without the complex semantics of multiple inheritance.\u003cbr/\u003e\n  2. Code reusability: Mixins are useful when a programmer wants to share functionality between different classes. Instead of repeating the same code over and over again, the common functionality can simply be grouped into a mixin and then inherited into each class that requires it.\u003cbr/\u003e\n  3. Mixins allow inheritance and use of only the desired features from the parent class, not necessarily all of the features from the parent class.\u003cbr/\u003e\n\n#### What’s the difference between an interface, a trait and a mixin?\n  It’s a bit academic and not everyone agrees on these definitions, but it goes something like this:\n  ![Traits Vs Mixins](doc/img/TraitsVsMixins.png)\n\n  \u003e 1. First off we have the interface. This is a protocol that just has method signatures but no actual code. This is what Objective-C and Swift 1.2 have.\n  \u003e 2. A trait also has the actual method bodies. In other words, a trait adds code to an interface. This is the new thing that Swift 2.0 lets us do today with protocol extensions.\n  \u003e 3. A mixin is like a trait but it also has state. We can’t really do this yet with Swift 2.0 as you’re not allowed to add stored properties to protocols.\n\n#### What's the COP?\n  It's **C**omposition **O**riented **P**rogramming. COP allows developers to work with 'fragments', smaller than classes, and 'compose' fragments into larger 'composites' which acts like the regular objects.\n\n  **Composition over inheritance** (or composite reuse principle) in object-oriented programming (OOP) is the principle that classes should achieve polymorphic behavior and code reuse by their composition (by containing instances of other classes that implement the desired functionality) rather than inheritance from a base or parent class.\n  ![COP Vs OOP](doc/img/cop_vs_oop.png)\n\n#### What's the Extension?\n  An extension presents the customizations and extensions of target composite. The Composite Engine will enhance target composite according to extension definitions at runtime.\n  The extension mechanism supports adding new properties/methods and override target's method by @Delegate(**Warning:** don't use append mode when the extension inheriting the delegate source).\n\n#### It sound great, but i'm still a little bit of confused. Show me the code!\n    // === OOP style ===\n    // Class is a template of Objects, it's the definition.\n    class Car {\n      String model;\n      int cyclinders;\n      int displacement;\n      int horsepower;\n      int torque;\n      int weight;\n      int length;\n      int width;\n      int height;\n      int speed;\n\n      void ignite() {\n        //...\n      }\n\n      void run() {\n        //...\n      }\n    }\n\n    class Suv extends Car {\n      float approachAngle;\n      float depatureAngle;\n\n      void offroad() {\n        //...\n      }\n    }\n\n    // === COP style ===\n    // Mixins definition.\n    @Mixin\n    interface ModelMixin {\n      @Property\n      String getModel();\n      void setModel(String model);\n\n      @Property\n      int getLength();\n      void setLength(int length);\n\n      @Property\n      int getWidth();\n      void setWidth();\n\n      @Property\n      int getHeight();\n      void setHeight();\n    }\n\n    @Mixin\n    interface EngineMixin {\n      @Property\n      int getCylinders();\n      void setCylinders(int cyclinders);\n\n      @Property\n      int getDisplacement();\n      void setDisplacement(int displacement);\n\n      @Property\n      int getHorsepower();\n      void setHorsepower(int horsepower);\n\n      default void ignite() {\n        //...\n      }\n    }\n\n    @Mixin\n    interface Runable {\n      @Property\n      int getSpeed();\n      void setSpeed(int speed);\n\n      default void run() {\n        //...\n      }\n    }\n\n    @Mixin\n    interface Offroadable {\n      @Property\n      float getApproachAngle();\n      void setApproachAngle(float approachAngle);\n\n      @Property\n      float getDepatureAngle();\n      void setDepatureAngle(float depatureAngle);\n\n      default void offroad() {\n        //...\n      }\n    }\n\n    @Mixin\n    interface Flyable {\n      @Property\n      int getX();\n      void setX(int x);\n\n      @Property\n      int getY();\n      void setY(int y);\n\n      @Property\n      int getZ();\n      void setZ(int z);\n\n      default viod fly() {\n        //...\n      }\n    }\n\n    //Composite definition\n    @Composite\n    interface Car extends ModelMixin, EngineMixin, Runnable {\n    }\n\n    @Composite\n    interface Suv extends ModelMixin, EngineMixin, Runnable, Offroadable {\n    }\n\n    //Extension definition\n    @Extension(target=Car.class)\n    interface FlyCar extends Car.class, Flyable {\n      @Delegate(name = \"run\", parameterTypes = {})\n      default void run(@Self Flyable self) {\n        self.fly();\n      }\n    }\n\n#### The interface only support public members, so what about private members?\n  Directly say, no way in JDK 8.0! But JDK 9.0 had been released now that has added \"Private methods on interfaces\" feature. Still, there're some tricks to help enclose members as private members:\n\n    //Naming methods start with '_' to indicate these are private and should not use outside of the composite.\n    //But properties are not suitable as methods, because properties should follow the java bean standard.\n    @Composite\n    interface Cat {\n      @Property\n      String getColor();\n      void setColor(String color);\n\n      default void _meow() {\n        System.out.println(\"meow...\");\n      }\n\n      default void playWith(String butterfly) {\n        _meow();\n        //...\n      }\n    }\n\n    //Enclose private members in inner classes that only has private constructor methods.\n    @Composite\n    interface Cat {\n      @Property\n      Cask getCask();\n      void setCask(Cask cask);\n\n      @Initializer\n      default void preset() {\n        setCask(new Cask());\n      }\n\n      default void playWith(String butterfly) {\n        getCask().meow();\n      }\n\n      class Cask {\n        private String color;\n\n        //Change constructor scope to private to prevent createing outside of Cat.\n        private Cask(){\n        }\n\n        private void meow() {\n          System.out.println(\"meow...\");\n        }\n      }\n    }\n\n### Resources\n- [Mixins and traits](https://www.ibm.com/developerworks/library/j-jn8/index.html)\n- [Effective Java - Item 18: Prefer interface to abstract class](https://books.google.com/books?id=ka2VUBqHiWkC\u0026lpg=PA93\u0026ots=y_DfIjp-M2\u0026dq=java%20mixin\u0026pg=PA93#v=onepage\u0026q\u0026f=false)\n- [Introduction to Mixins Understanding Mixin Architecture](https://github.com/SpongePowered/Mixin/wiki/Introduction-to-Mixins---Understanding-Mixin-Architecture)\n- [Mixins as alternative to inheritance in Java 8](http://hannesdorfmann.com/android/java-mixins)\n- [Java 8: Now You Have Mixins?](https://kerflyn.wordpress.com/2012/07/09/java-8-now-you-have-mixins/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonlee%2Fmde","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonlee%2Fmde","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonlee%2Fmde/lists"}