{"id":19968203,"url":"https://github.com/sormuras/compayler","last_synced_at":"2026-06-02T20:31:54.179Z","repository":{"id":85458733,"uuid":"13438073","full_name":"sormuras/compayler","owner":"sormuras","description":"Prevayler Decorator Compiler","archived":false,"fork":false,"pushed_at":"2015-04-18T12:02:20.000Z","size":3152,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-29T14:46:57.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sormuras.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-09T09:20:03.000Z","updated_at":"2024-01-13T23:51:49.000Z","dependencies_parsed_at":"2023-03-03T11:30:18.346Z","dependency_job_id":null,"html_url":"https://github.com/sormuras/compayler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sormuras/compayler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sormuras%2Fcompayler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sormuras%2Fcompayler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sormuras%2Fcompayler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sormuras%2Fcompayler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sormuras","download_url":"https://codeload.github.com/sormuras/compayler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sormuras%2Fcompayler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33835766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-11-13T02:44:50.992Z","updated_at":"2026-06-02T20:31:54.157Z","avatar_url":"https://github.com/sormuras.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compayler [![Build Status](https://travis-ci.org/sormuras/compayler.png?branch=master)](https://travis-ci.org/sormuras/compayler)\r\n\r\n***Prevayler Decorator Compiler (Java 8)***\r\n\r\nWith the Prevayler Decorator Compiler you can achive these goals\r\n\r\n* Encapsulate all transactions executing on a prevalent system in one place, namely an interface.\r\n\r\n* Easily unit test the system implementation without caring for persistence.\r\n\r\n* Let the compiler do the tedious work of writing the transaction source code.\r\n\r\n* Never instantiate a transaction object by yourself, just call your interface methods.\r\n\r\n* Review/tweak the generated decorator source code.\r\n\r\n* Less overhead compared to a runtime/reflection based solution\r\n\r\n## Generate decorator class via annotation processor\r\n\r\nAdd compayler-X.Y.jar close to prevayler.jar and configure your build setup to execute annotation\r\nprocessors. Then annotate your prevalent interface with `@Compayler.Decorate` and get the decorator class\r\nwith all serializable transaction and query classes *for free* and ahead of compile time.\r\n\r\nSee documentation for [javac](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html)\r\nor [Eclipse](http://www.eclipse.org/jdt/apt/introToAPT.php)\r\nor [Idea](http://www.jetbrains.com/idea/webhelp/annotation-processors-support.html)\r\nor [Netbeans](https://netbeans.org/kb/docs/java/annotations.html) or your favorite IDE\r\n\r\n### Example based on [E101](https://github.com/jsampson/prevayler/tree/master/demos/tutorial/src/test/java/org/prevayler/examples/e101)\r\n* Create interface `Root` and annotate it\r\n```java\r\n    @Decorate\r\n    interface Root extends Closeable, Serializable {\r\n      Person createPerson(String identity);\r\n      Person deletePerson(String identity);\r\n      @Execute(QUERY) Person getPerson(String identity);\r\n      @Execute(DIRECT) boolean isEmpty();\r\n      void updatePersonName(String identity, String name);\r\n    }\r\n```\r\n* Implement the `Root` interface with your business logic in `RootSystem`. Here, you can unit test the system\r\nwithout caring for persistence because there is no reference to Prevayler classes.\r\n```java\r\n    class RootSystem implements Root {\r\n      private static final long serialVersionUID = 170l;\r\n      private Map\u003cString, Person\u003e persons = new HashMap\u003c\u003e();\r\n      @Override\r\n      public Person createPerson(String identity) {\r\n        Person entity = new Person();\r\n        entity.setIdentity(identity);\r\n        persons.put(entity.getIdentity(), entity);\r\n        return entity;\r\n      }\r\n      ...\r\n    }\r\n```\r\n* Finally, use generated `RootDecorator` over `Prevayler` over `RootSystem`\r\n```java\r\n    Prevayler prevayler = createPrevayler(new RootSystem(), new File(\"e101\"));\r\n    try (Root root = new RootDecorator(prevayler)) {\r\n      Person person = root.createPerson(UUID.randomUUID().toString());\r\n      String nameOfPerson = \"John Doe\";\r\n      root.updatePersonName(person.getIdentity(), nameOfPerson);\r\n      assertEquals(nameOfPerson, person.getName());\r\n      Person queryResponse = root.getPerson(person.getIdentity());\r\n      assertSame(\"person and response not same object?!\", person, queryResponse);\r\n      Person removed = root.deletePerson(person.getIdentity());\r\n      assertSame(\"person and removed not same object?!\", person, removed);\r\n      assertTrue(\"root not empty?!\", root.isEmpty());\r\n    }\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsormuras%2Fcompayler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsormuras%2Fcompayler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsormuras%2Fcompayler/lists"}