Permalink
Browse files

Initial commit after moving codebase from cqrs4j (http://cqrs4j.googl…

  • Loading branch information...
abuijze committed Jan 19, 2010
1 parent 6e21183 commit 89f40710038e40d7f77a3f51a2aa4dc9f1af9a3a
Showing with 12,738 additions and 0 deletions.
  1. +202 −0 LICENSE.txt
  2. +29 −0 core/pom.xml
  3. +130 −0 core/src/main/java/org/axonframework/core/AbstractAggregateRoot.java
  4. +55 −0 core/src/main/java/org/axonframework/core/AggregateRoot.java
  5. +149 −0 core/src/main/java/org/axonframework/core/DomainEvent.java
  6. +144 −0 core/src/main/java/org/axonframework/core/EventContainer.java
  7. +38 −0 core/src/main/java/org/axonframework/core/EventSourcedAggregateRoot.java
  8. +58 −0 core/src/main/java/org/axonframework/core/EventStream.java
  9. +111 −0 core/src/main/java/org/axonframework/core/SimpleEventStream.java
  10. +36 −0 core/src/main/java/org/axonframework/core/VersionedAggregateRoot.java
  11. +159 −0 core/src/main/java/org/axonframework/core/eventhandler/AsyncEventBus.java
  12. +59 −0 core/src/main/java/org/axonframework/core/eventhandler/EventBus.java
  13. +137 −0 core/src/main/java/org/axonframework/core/eventhandler/EventHandlingSequenceManager.java
  14. +57 −0 core/src/main/java/org/axonframework/core/eventhandler/EventListener.java
  15. +211 −0 core/src/main/java/org/axonframework/core/eventhandler/EventProcessingScheduler.java
  16. +45 −0 core/src/main/java/org/axonframework/core/eventhandler/EventSequencingPolicy.java
  17. +36 −0 core/src/main/java/org/axonframework/core/eventhandler/FullConcurrencyPolicy.java
  18. +55 −0 core/src/main/java/org/axonframework/core/eventhandler/MessageHandlerAdapter.java
  19. +37 −0 core/src/main/java/org/axonframework/core/eventhandler/SequentialPerAggregatePolicy.java
  20. +39 −0 core/src/main/java/org/axonframework/core/eventhandler/SequentialPolicy.java
  21. +84 −0 core/src/main/java/org/axonframework/core/eventhandler/SpringIntegrationEventBus.java
  22. +84 −0 core/src/main/java/org/axonframework/core/eventhandler/SynchronousEventBus.java
  23. +59 −0 core/src/main/java/org/axonframework/core/eventhandler/TransactionAware.java
  24. +199 −0 core/src/main/java/org/axonframework/core/eventhandler/TransactionStatus.java
  25. +39 −0 core/src/main/java/org/axonframework/core/eventhandler/YieldPolicy.java
  26. +90 −0 .../src/main/java/org/axonframework/core/eventhandler/annotation/AbstractAnnotatedAggregateRoot.java
  27. +53 −0 core/src/main/java/org/axonframework/core/eventhandler/annotation/AfterTransaction.java
  28. +326 −0 core/src/main/java/org/axonframework/core/eventhandler/annotation/AnnotationEventHandlerInvoker.java
  29. +210 −0 .../src/main/java/org/axonframework/core/eventhandler/annotation/AnnotationEventListenerAdapter.java
  30. +49 −0 core/src/main/java/org/axonframework/core/eventhandler/annotation/BeforeTransaction.java
  31. +51 −0 core/src/main/java/org/axonframework/core/eventhandler/annotation/ConcurrentEventListener.java
  32. +56 −0 core/src/main/java/org/axonframework/core/eventhandler/annotation/EventHandler.java
  33. +52 −0 .../src/main/java/org/axonframework/core/eventhandler/annotation/EventHandlingRejectedException.java
  34. +37 −0 ...main/java/org/axonframework/core/eventhandler/annotation/TransactionMethodExecutionException.java
  35. +55 −0 core/src/main/java/org/axonframework/core/eventhandler/annotation/UnhandledEventException.java
  36. +54 −0 ...c/main/java/org/axonframework/core/eventhandler/annotation/UnsupportedHandlerMethodException.java
  37. +37 −0 core/src/main/java/org/axonframework/core/eventhandler/annotation/UnsupportedPolicyException.java
  38. +42 −0 ...ramework/core/eventhandler/annotation/postprocessor/AnnotationEventListenerBeanPostProcessor.java
  39. +37 −0 .../src/main/java/org/axonframework/core/eventhandler/annotation/postprocessor/AxonNamingPolicy.java
  40. +193 −0 ...work/core/eventhandler/annotation/postprocessor/BaseAnnotationEventListenerBeanPostProcessor.java
  41. +36 −0 ...a/org/axonframework/core/eventhandler/annotation/postprocessor/EventListenerAdapterException.java
  42. +105 −0 core/src/main/java/org/axonframework/core/repository/AbstractRepository.java
  43. +36 −0 core/src/main/java/org/axonframework/core/repository/ConcurrencyException.java
  44. +55 −0 core/src/main/java/org/axonframework/core/repository/LockManager.java
  45. +151 −0 core/src/main/java/org/axonframework/core/repository/LockingRepository.java
  46. +44 −0 core/src/main/java/org/axonframework/core/repository/LockingStrategy.java
  47. +107 −0 core/src/main/java/org/axonframework/core/repository/OptimisticLockManager.java
  48. +148 −0 core/src/main/java/org/axonframework/core/repository/PessimisticLockManager.java
  49. +47 −0 core/src/main/java/org/axonframework/core/repository/Repository.java
  50. +101 −0 ...src/main/java/org/axonframework/core/repository/eventsourcing/CachingEventSourcingRepository.java
  51. +115 −0 core/src/main/java/org/axonframework/core/repository/eventsourcing/EventSourcingRepository.java
  52. +36 −0 core/src/main/java/org/axonframework/core/repository/eventsourcing/EventStorageException.java
  53. +49 −0 core/src/main/java/org/axonframework/core/repository/eventsourcing/EventStore.java
  54. +201 −0 core/src/main/java/org/axonframework/core/repository/eventsourcing/NoCache.java
  55. +106 −0 core/src/main/java/org/axonframework/core/repository/eventsourcing/ObjectInputStreamAdapter.java
  56. +191 −0 core/src/main/java/org/axonframework/core/repository/eventsourcing/XStreamFileSystemEventStore.java
  57. +51 −0 core/src/main/java/org/axonframework/core/util/Assert.java
  58. +81 −0 core/src/test/java/org/axonframework/core/AbstractAggregateRootTest.java
  59. +101 −0 core/src/test/java/org/axonframework/core/DomainEventTest.java
  60. +87 −0 core/src/test/java/org/axonframework/core/EventContainerTest.java
  61. +47 −0 core/src/test/java/org/axonframework/core/StubAggregate.java
  62. +52 −0 core/src/test/java/org/axonframework/core/StubDomainEvent.java
  63. +94 −0 core/src/test/java/org/axonframework/core/eventhandler/AsyncEventBusTest.java
  64. +107 −0 core/src/test/java/org/axonframework/core/eventhandler/EventHandlingSequenceManagerTest.java
  65. +39 −0 core/src/test/java/org/axonframework/core/eventhandler/FullConcurrencyPolicyTest.java
  66. +137 −0 core/src/test/java/org/axonframework/core/eventhandler/ListenerManagerTest.java
  67. +47 −0 core/src/test/java/org/axonframework/core/eventhandler/MessageHandlerAdapterTest.java
  68. +44 −0 core/src/test/java/org/axonframework/core/eventhandler/SequentialPerAggregatePolicyTest.java
  69. +45 −0 core/src/test/java/org/axonframework/core/eventhandler/SequentialPolicyTest.java
  70. +72 −0 core/src/test/java/org/axonframework/core/eventhandler/SimpleEventBusTest.java
  71. +85 −0 core/src/test/java/org/axonframework/core/eventhandler/SpringIntegrationEventBusTest.java
  72. +100 −0 core/src/test/java/org/axonframework/core/eventhandler/TransactionStatusTest.java
  73. +68 −0 .../test/java/org/axonframework/core/eventhandler/annotation/AbstractAnnotatedAggregateRootTest.java
  74. +266 −0 ...c/test/java/org/axonframework/core/eventhandler/annotation/AnnotationEventHandlerInvokerTest.java
  75. +155 −0 .../test/java/org/axonframework/core/eventhandler/annotation/AnnotationEventListenerAdapterTest.java
  76. +37 −0 core/src/test/java/org/axonframework/core/eventhandler/annotation/UnhandledEventExceptionTest.java
  77. +100 −0 ...ework/core/eventhandler/annotation/postprocessor/AnnotationEventHandlerBeanPostProcessorTest.java
  78. +37 −0 ...work/core/eventhandler/annotation/postprocessor/AnnotationEventListenerBeanPostProcessorTest.java
  79. +100 −0 .../core/eventhandler/annotation/postprocessor/BaseAnnotationEventListenerBeanPostProcessorTest.java
  80. +137 −0 core/src/test/java/org/axonframework/core/repository/LockingRepositoryTest.java
  81. +61 −0 core/src/test/java/org/axonframework/core/repository/OptimisticLockManagerTest.java
  82. +44 −0 core/src/test/java/org/axonframework/core/repository/PessimisticLockManagerTest.java
  83. +120 −0 ...test/java/org/axonframework/core/repository/eventsourcing/CachingEventSourcingRepositoryTest.java
  84. +188 −0 .../java/org/axonframework/core/repository/eventsourcing/EventSourcingRepositoryIntegrationTest.java
  85. +115 −0 core/src/test/java/org/axonframework/core/repository/eventsourcing/EventSourcingRepositoryTest.java
  86. +62 −0 core/src/test/java/org/axonframework/core/repository/eventsourcing/NoCacheTest.java
  87. +45 −0 core/src/test/java/org/axonframework/core/util/AssertTest.java
  88. +43 −0 core/src/test/resources/ehcache.xml
  89. +24 −0 core/src/test/resources/log4j.properties
  90. +233 −0 pom.xml
  91. +168 −0 reference-guide/pom.xml
  92. +186 −0 reference-guide/src/main/docbook/en-US/1-getting-started.xml
  93. +94 −0 reference-guide/src/main/docbook/en-US/2-annotation-support.xml
  94. +51 −0 reference-guide/src/main/docbook/en-US/3-event-sourcing-support.xml
  95. +44 −0 reference-guide/src/main/docbook/en-US/4-transaction-support.xml
  96. +60 −0 reference-guide/src/main/docbook/en-US/master.xml
  97. +38 −0 reference-guide/src/main/docbook/en-US/programlistingsample.txt
  98. BIN reference-guide/src/main/resources/images/callouts/1.gif
  99. BIN reference-guide/src/main/resources/images/callouts/1.png
  100. +15 −0 reference-guide/src/main/resources/images/callouts/1.svg
  101. BIN reference-guide/src/main/resources/images/callouts/10.gif
  102. BIN reference-guide/src/main/resources/images/callouts/10.png
  103. +18 −0 reference-guide/src/main/resources/images/callouts/10.svg
  104. BIN reference-guide/src/main/resources/images/callouts/11.gif
  105. BIN reference-guide/src/main/resources/images/callouts/11.png
  106. +16 −0 reference-guide/src/main/resources/images/callouts/11.svg
  107. BIN reference-guide/src/main/resources/images/callouts/12.gif
  108. BIN reference-guide/src/main/resources/images/callouts/12.png
  109. +18 −0 reference-guide/src/main/resources/images/callouts/12.svg
  110. BIN reference-guide/src/main/resources/images/callouts/13.gif
  111. BIN reference-guide/src/main/resources/images/callouts/13.png
  112. +20 −0 reference-guide/src/main/resources/images/callouts/13.svg
  113. BIN reference-guide/src/main/resources/images/callouts/14.gif
  114. BIN reference-guide/src/main/resources/images/callouts/14.png
  115. +17 −0 reference-guide/src/main/resources/images/callouts/14.svg
  116. BIN reference-guide/src/main/resources/images/callouts/15.gif
  117. BIN reference-guide/src/main/resources/images/callouts/15.png
  118. +19 −0 reference-guide/src/main/resources/images/callouts/15.svg
  119. +20 −0 reference-guide/src/main/resources/images/callouts/16.svg
  120. +17 −0 reference-guide/src/main/resources/images/callouts/17.svg
  121. +21 −0 reference-guide/src/main/resources/images/callouts/18.svg
  122. +20 −0 reference-guide/src/main/resources/images/callouts/19.svg
  123. BIN reference-guide/src/main/resources/images/callouts/2.gif
  124. BIN reference-guide/src/main/resources/images/callouts/2.png
  125. +17 −0 reference-guide/src/main/resources/images/callouts/2.svg
  126. +20 −0 reference-guide/src/main/resources/images/callouts/20.svg
  127. +18 −0 reference-guide/src/main/resources/images/callouts/21.svg
  128. +20 −0 reference-guide/src/main/resources/images/callouts/22.svg
  129. +22 −0 reference-guide/src/main/resources/images/callouts/23.svg
  130. +19 −0 reference-guide/src/main/resources/images/callouts/24.svg
  131. +21 −0 reference-guide/src/main/resources/images/callouts/25.svg
  132. +22 −0 reference-guide/src/main/resources/images/callouts/26.svg
  133. +19 −0 reference-guide/src/main/resources/images/callouts/27.svg
  134. +23 −0 reference-guide/src/main/resources/images/callouts/28.svg
  135. +22 −0 reference-guide/src/main/resources/images/callouts/29.svg
  136. BIN reference-guide/src/main/resources/images/callouts/3.gif
  137. BIN reference-guide/src/main/resources/images/callouts/3.png
  138. +19 −0 reference-guide/src/main/resources/images/callouts/3.svg
  139. +22 −0 reference-guide/src/main/resources/images/callouts/30.svg
  140. BIN reference-guide/src/main/resources/images/callouts/4.gif
  141. BIN reference-guide/src/main/resources/images/callouts/4.png
  142. +16 −0 reference-guide/src/main/resources/images/callouts/4.svg
  143. BIN reference-guide/src/main/resources/images/callouts/5.gif
  144. BIN reference-guide/src/main/resources/images/callouts/5.png
  145. +18 −0 reference-guide/src/main/resources/images/callouts/5.svg
  146. BIN reference-guide/src/main/resources/images/callouts/6.gif
  147. BIN reference-guide/src/main/resources/images/callouts/6.png
  148. +19 −0 reference-guide/src/main/resources/images/callouts/6.svg
  149. BIN reference-guide/src/main/resources/images/callouts/7.gif
  150. BIN reference-guide/src/main/resources/images/callouts/7.png
  151. +16 −0 reference-guide/src/main/resources/images/callouts/7.svg
  152. BIN reference-guide/src/main/resources/images/callouts/8.gif
  153. BIN reference-guide/src/main/resources/images/callouts/8.png
  154. +20 −0 reference-guide/src/main/resources/images/callouts/8.svg
  155. BIN reference-guide/src/main/resources/images/callouts/9.gif
  156. BIN reference-guide/src/main/resources/images/callouts/9.png
  157. +19 −0 reference-guide/src/main/resources/images/callouts/9.svg
  158. BIN reference-guide/src/main/resources/images/logo.png
  159. +123 −0 reference-guide/src/main/xslt/basic.xsl
  160. +230 −0 reference-guide/src/main/xslt/borders.xsl
  161. +278 −0 reference-guide/src/main/xslt/coverpages.xsl
  162. +259 −0 reference-guide/src/main/xslt/coverpages_html.xsl
  163. +109 −0 reference-guide/src/main/xslt/highlight.xsl
  164. +108 −0 reference-guide/src/main/xslt/highlight_html.xsl
  165. +16 −0 reference-guide/src/main/xslt/highlighting/README
  166. +105 −0 reference-guide/src/main/xslt/highlighting/c-hl.xml
  167. +140 −0 reference-guide/src/main/xslt/highlighting/common.xsl
  168. +137 −0 reference-guide/src/main/xslt/highlighting/cpp-hl.xml
  169. +174 −0 reference-guide/src/main/xslt/highlighting/csharp-hl.xml
  170. +186 −0 reference-guide/src/main/xslt/highlighting/delphi-hl.xml
  171. +31 −0 reference-guide/src/main/xslt/highlighting/ini-hl.xml
  172. +103 −0 reference-guide/src/main/xslt/highlighting/java-hl.xml
  173. +133 −0 reference-guide/src/main/xslt/highlighting/javascript-hl.xml
  174. +76 −0 reference-guide/src/main/xslt/highlighting/m2-hl.xml
  175. +132 −0 reference-guide/src/main/xslt/highlighting/myxml-hl.xml
  176. +106 −0 reference-guide/src/main/xslt/highlighting/perl-hl.xml
  177. +135 −0 reference-guide/src/main/xslt/highlighting/php-hl.xml
  178. +86 −0 reference-guide/src/main/xslt/highlighting/python-hl.xml
  179. +95 −0 reference-guide/src/main/xslt/highlighting/ruby-hl.xml
  180. +167 −0 reference-guide/src/main/xslt/highlighting/tcl-hl.xml
  181. +34 −0 reference-guide/src/main/xslt/highlighting/xslthl-config.xml
  182. +36 −0 reference-guide/src/main/xslt/main-html.xsl
  183. +35 −0 reference-guide/src/main/xslt/main-html_single.xsl
  184. +344 −0 reference-guide/src/main/xslt/main-pdf.xsl
View
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
View
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2010. Axon Framework
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.axonframework</groupId>
+ <artifactId>axon</artifactId>
+ <version>0.3-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>axon-core</artifactId>
+ <name>Axon Framework core</name>
+
+</project>
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2010. Axon Framework
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.core;
+
+import org.axonframework.core.util.Assert;
+
+import java.util.UUID;
+
+/**
+ * Abstract convenience class to be extended by all aggregate roots. The AbstractAggregateRoot tracks all uncommitted
+ * events. It also provides convenience methods to initialize the state of the aggregate root based on an {@link
+ * org.axonframework.core.EventStream}, which can be used for event sourcing.
+ *
+ * @author Allard Buijze
+ * @since 0.1
+ */
+public abstract class AbstractAggregateRoot implements EventSourcedAggregateRoot {
+
+ private final EventContainer uncommittedEvents;
+ private final UUID identifier;
+ private volatile Long lastCommitted;
+
+ /**
+ * Initializes the aggregate root using a random aggregate identifier.
+ */
+ protected AbstractAggregateRoot() {
+ this(UUID.randomUUID());
+ }
+
+ /**
+ * Initializes the aggregate root using the provided aggregate identifier.
+ *
+ * @param identifier the identifier of this aggregate
+ */
+ protected AbstractAggregateRoot(UUID identifier) {
+ uncommittedEvents = new EventContainer(identifier);
+ this.identifier = identifier;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void initializeState(EventStream eventStream) {
+ Assert.state(uncommittedEvents.size() == 0, "Aggregate is already initialized");
+ long lastSequenceNumber = -1;
+ while (eventStream.hasNext()) {
+ DomainEvent event = eventStream.next();
+ lastSequenceNumber = event.getSequenceNumber();
+ handle(event);
+ }
+ uncommittedEvents.setFirstSequenceNumber(lastSequenceNumber + 1);
+ lastCommitted = lastSequenceNumber >= 0 ? lastSequenceNumber : null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getLastCommittedEventSequenceNumber() {
+ return lastCommitted;
+ }
+
+ /**
+ * Apply the provided event. Applying events means they are added to the uncommitted event queue and forwarded to
+ * the {@link #handle(DomainEvent) event handler method} for processing.
+ *
+ * @param event The event to apply
+ */
+ protected void apply(DomainEvent event) {
+ uncommittedEvents.addEvent(event);
+ handle(event);
+ }
+
+ /**
+ * Apply state changes based on the given event.
+ * <p/>
+ * Note: Implementations of this method should *not* perform validation.
+ *
+ * @param event The event to handle
+ */
+ protected abstract void handle(DomainEvent event);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public EventStream getUncommittedEvents() {
+ return uncommittedEvents.getInputStream();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public UUID getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void commitEvents() {
+ lastCommitted = uncommittedEvents.getLastSequenceNumber();
+ uncommittedEvents.clear();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getUncommittedEventCount() {
+ return uncommittedEvents.size();
+ }
+}
Oops, something went wrong.

0 comments on commit 89f4071

Please sign in to comment.