You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by my...@apache.org on 2018/01/22 15:10:30 UTC

[fineract-cn-command] branch develop created (now 52c4371)

This is an automated email from the ASF dual-hosted git repository.

myrle pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-command.git.


      at 52c4371  Merge pull request #2 from myrle-krantz/develop

This branch includes the following new commits:

     new 03bdd5e  Open sourcing core.command.
     new 9a341f1  Including sources in resulting artifact.
     new 6dec3c3  fixed default app name to something parseable and valid for Eureka.
     new dfe6e1f  Added optional logging for command handlers.  Default is off.
     new 2cee5a2  Merge pull request #1 from myrle-krantz/develop
     new 72cad96  Added javadoc for command logging.
     new 392f34a  Merge branch 'develop' of https://github.com/mifosio/command into develop
     new 52c4371  Merge pull request #2 from myrle-krantz/develop

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

[fineract-cn-command] 07/08: Merge branch 'develop' of https://github.com/mifosio/command into develop

Posted by my...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-command.git

commit 392f34a95ee29f6162649f5e2515c97c0db6decd
Merge: 72cad96 2cee5a2
Author: myrle-krantz <mk...@mifos.org>
AuthorDate: Mon Jun 12 11:11:17 2017 +0200

    Merge branch 'develop' of https://github.com/mifosio/command into develop


-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

[fineract-cn-command] 04/08: Added optional logging for command handlers. Default is off.

Posted by my...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-command.git

commit dfe6e1fe49756fd444b8c8b1981fccfe0bd3cc4f
Author: myrle-krantz <mk...@mifos.org>
AuthorDate: Wed May 31 13:18:14 2017 +0200

    Added optional logging for command handlers.  Default is off.
---
 .../core/command/annotation/CommandHandler.java    |  9 ++---
 .../{CommandHandler.java => CommandLogLevel.java}  | 22 +++++++-----
 .../core/command/domain/CommandHandlerHolder.java  | 20 ++++++++++-
 .../io/mifos/core/command/internal/CommandBus.java | 40 ++++++++++++++++++++--
 4 files changed, 73 insertions(+), 18 deletions(-)

diff --git a/src/main/java/io/mifos/core/command/annotation/CommandHandler.java b/src/main/java/io/mifos/core/command/annotation/CommandHandler.java
index 8b57ae3..e1db3e3 100644
--- a/src/main/java/io/mifos/core/command/annotation/CommandHandler.java
+++ b/src/main/java/io/mifos/core/command/annotation/CommandHandler.java
@@ -15,15 +15,12 @@
  */
 package io.mifos.core.command.annotation;
 
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.lang.annotation.*;
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.METHOD)
 @Documented
 public @interface CommandHandler {
-
+  CommandLogLevel logStart() default CommandLogLevel.NONE;
+  CommandLogLevel logFinish() default CommandLogLevel.NONE;
 }
diff --git a/src/main/java/io/mifos/core/command/annotation/CommandHandler.java b/src/main/java/io/mifos/core/command/annotation/CommandLogLevel.java
similarity index 67%
copy from src/main/java/io/mifos/core/command/annotation/CommandHandler.java
copy to src/main/java/io/mifos/core/command/annotation/CommandLogLevel.java
index 8b57ae3..c042c86 100644
--- a/src/main/java/io/mifos/core/command/annotation/CommandHandler.java
+++ b/src/main/java/io/mifos/core/command/annotation/CommandLogLevel.java
@@ -15,15 +15,19 @@
  */
 package io.mifos.core.command.annotation;
 
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+/**
+ * @author Myrle Krantz
+ */
+public enum CommandLogLevel {
+
+  INFO("INFO"), DEBUG("DEBUG"), TRACE("TRACE"), NONE("TRACE");
 
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-@Documented
-public @interface CommandHandler {
+  private final String strVal;
 
+  CommandLogLevel(final String strVal) {
+    this.strVal = strVal;
+  }
+  public String toString() {
+    return strVal;
+  }
 }
diff --git a/src/main/java/io/mifos/core/command/domain/CommandHandlerHolder.java b/src/main/java/io/mifos/core/command/domain/CommandHandlerHolder.java
index a0d4efa..33a08b5 100644
--- a/src/main/java/io/mifos/core/command/domain/CommandHandlerHolder.java
+++ b/src/main/java/io/mifos/core/command/domain/CommandHandlerHolder.java
@@ -16,8 +16,10 @@
 package io.mifos.core.command.domain;
 
 import io.mifos.core.command.annotation.EventEmitter;
+import io.mifos.core.lang.TenantContextHolder;
 
 import java.lang.reflect.Method;
+import java.util.function.Consumer;
 
 public final class CommandHandlerHolder {
 
@@ -25,14 +27,20 @@ public final class CommandHandlerHolder {
   private final Method method;
   private final EventEmitter eventEmitter;
   private final Class<?>[] exceptionTypes;
+  private final Consumer<Object> logStart;
+  private final Consumer<Object> logFinish;
 
   public CommandHandlerHolder(final Object aggregate, final Method method, final EventEmitter eventEmitter,
-                              final Class<?>[] exceptionTypes) {
+                              final Class<?>[] exceptionTypes,
+                              final Consumer<Object> logStart,
+                              final Consumer<Object> logFinish) {
     super();
     this.aggregate = aggregate;
     this.method = method;
     this.eventEmitter = eventEmitter;
     this.exceptionTypes = exceptionTypes;
+    this.logStart = logStart;
+    this.logFinish = logFinish;
   }
 
   public Object aggregate() {
@@ -50,4 +58,14 @@ public final class CommandHandlerHolder {
   public Class<?>[] exceptionTypes() {
     return exceptionTypes;
   }
+
+  @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
+  public void logStart(final Object command) {
+    logStart.accept(command);
+  }
+
+  @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
+  public void logFinish(final Object command) {
+    logFinish.accept(command);
+  }
 }
diff --git a/src/main/java/io/mifos/core/command/internal/CommandBus.java b/src/main/java/io/mifos/core/command/internal/CommandBus.java
index 73466f7..a460be8 100644
--- a/src/main/java/io/mifos/core/command/internal/CommandBus.java
+++ b/src/main/java/io/mifos/core/command/internal/CommandBus.java
@@ -19,6 +19,7 @@ import com.google.gson.Gson;
 import io.mifos.core.cassandra.core.TenantAwareEntityTemplate;
 import io.mifos.core.command.annotation.Aggregate;
 import io.mifos.core.command.annotation.CommandHandler;
+import io.mifos.core.command.annotation.CommandLogLevel;
 import io.mifos.core.command.annotation.EventEmitter;
 import io.mifos.core.command.domain.CommandHandlerHolder;
 import io.mifos.core.command.domain.CommandProcessingException;
@@ -49,6 +50,7 @@ import java.util.Date;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Future;
+import java.util.function.Consumer;
 
 @Component
 public class CommandBus implements ApplicationContextAware {
@@ -83,8 +85,13 @@ public class CommandBus implements ApplicationContextAware {
     CommandHandlerHolder commandHandlerHolder = null;
     try {
       commandHandlerHolder = this.findCommandHandler(command);
+      commandHandlerHolder.logStart(command);
+
       final Object result = commandHandlerHolder.method().invoke(commandHandlerHolder.aggregate(), command);
       this.updateCommandSource(commandSource, null);
+
+      commandHandlerHolder.logFinish(result);
+
       if (commandHandlerHolder.eventEmitter() != null) {
         this.fireEvent(result, commandHandlerHolder.eventEmitter());
       }
@@ -103,9 +110,13 @@ public class CommandBus implements ApplicationContextAware {
     try {
       // find command handling method
       commandHandlerHolder = this.findCommandHandler(command);
+      commandHandlerHolder.logStart(command);
+
       final Object result = commandHandlerHolder.method().invoke(commandHandlerHolder.aggregate(), command);
       this.updateCommandSource(commandSource, null);
 
+      commandHandlerHolder.logFinish(result);
+
       if (commandHandlerHolder.eventEmitter() != null) {
         this.fireEvent(result, commandHandlerHolder.eventEmitter());
       }
@@ -136,17 +147,42 @@ public class CommandBus implements ApplicationContextAware {
   CommandHandlerHolder getCommandHandlerMethodFromClass(final Class<?> commandClass, final Object aggregate) {
     final Method[] methods = aggregate.getClass().getDeclaredMethods();
     for (final Method method : methods) {
-      if (AnnotationUtils.findAnnotation(method, CommandHandler.class) != null
+      final CommandHandler commandHandlerAnnotation = AnnotationUtils.findAnnotation(method, CommandHandler.class);
+      if (commandHandlerAnnotation != null
           && method.getParameterCount() == 1
           && method.getParameterTypes()[0].isAssignableFrom(commandClass)) {
         this.logger.debug("CommandBus::findCommandHandler added method for {}.", commandClass.getSimpleName());
+
+        //Note that as much of the logic of determining how to log as possible is moved into the creation of the
+        //handler holder rather than performing it in the process of handling the command.  Creation of the command
+        //handler holder is not performance critical, but execution of the command is.
+        final Consumer<Object> logStart = getLogHandler(commandHandlerAnnotation.logStart(),
+                "Handling command of type " + commandClass.getCanonicalName() + " for tenant {}, -> command {}");
+
+        final Consumer<Object> logFinish = getLogHandler(commandHandlerAnnotation.logFinish(),
+                "Handled command of type " + commandClass.getCanonicalName() + " for tenant {}, -> result {}");
+
         return new CommandHandlerHolder(aggregate, method, AnnotationUtils.findAnnotation(method, EventEmitter.class),
-            method.getExceptionTypes());
+            method.getExceptionTypes(), logStart, logFinish);
       }
     }
     return null;
   }
 
+  private Consumer<Object> getLogHandler(final CommandLogLevel level, final String formatString) {
+    switch (level) {
+      case INFO:
+        return (x) -> logger.info(formatString, TenantContextHolder.identifier().orElse("none"), x);
+      case DEBUG:
+        return (x) -> logger.debug(formatString, TenantContextHolder.identifier().orElse("none"), x);
+      case TRACE:
+        return (x) -> logger.trace(formatString, TenantContextHolder.identifier().orElse("none"), x);
+      default:
+      case NONE:
+        return (x) -> { };
+    }
+  }
+
   private <C> CommandSource storeCommand(final C command) {
     this.logger.debug("CommandBus::storeCommand called.");
     final LocalDateTime now = LocalDateTime.now();

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

[fineract-cn-command] 05/08: Merge pull request #1 from myrle-krantz/develop

Posted by my...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-command.git

commit 2cee5a250b92a0554013050b9e3516fe203f56a5
Merge: 6dec3c3 dfe6e1f
Author: Myrle Krantz <my...@apache.org>
AuthorDate: Thu Jun 8 18:12:13 2017 +0200

    Merge pull request #1 from myrle-krantz/develop
    
    Added optional logging for command handlers.  Default is off.

 .../core/command/annotation/CommandHandler.java    |  9 ++---
 .../{CommandHandler.java => CommandLogLevel.java}  | 22 +++++++-----
 .../core/command/domain/CommandHandlerHolder.java  | 20 ++++++++++-
 .../io/mifos/core/command/internal/CommandBus.java | 40 ++++++++++++++++++++--
 4 files changed, 73 insertions(+), 18 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

[fineract-cn-command] 08/08: Merge pull request #2 from myrle-krantz/develop

Posted by my...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-command.git

commit 52c437195b816f20c5342dbb3e16f337c810d65e
Merge: 2cee5a2 392f34a
Author: Myrle Krantz <my...@apache.org>
AuthorDate: Mon Jun 12 11:12:02 2017 +0200

    Merge pull request #2 from myrle-krantz/develop
    
    Added javadoc for command logging.

 .../core/command/annotation/CommandHandler.java      | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

[fineract-cn-command] 03/08: fixed default app name to something parseable and valid for Eureka.

Posted by my...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-command.git

commit 6dec3c3972f360d840f1bfe252a93c9f4a019586
Author: myrle-krantz <mk...@mifos.org>
AuthorDate: Thu Mar 23 15:32:37 2017 +0100

    fixed default app name to something parseable and valid for Eureka.
---
 src/main/java/io/mifos/core/command/util/CommandConstants.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/io/mifos/core/command/util/CommandConstants.java b/src/main/java/io/mifos/core/command/util/CommandConstants.java
index b9e9c9e..c641804 100644
--- a/src/main/java/io/mifos/core/command/util/CommandConstants.java
+++ b/src/main/java/io/mifos/core/command/util/CommandConstants.java
@@ -22,7 +22,7 @@ public interface CommandConstants {
   String COMMAND_SOURCE_TABLE_NAME = "command_source";
 
   String APPLICATION_NAME_PROP = "spring.application.name";
-  String APPLICATION_NAME_DEFAULT = "command/v1";
+  String APPLICATION_NAME_DEFAULT = "command-v1";
 
   String ACTIVEMQ_BROKER_URL_PROP = "activemq.brokerUrl";
   String ACTIVEMQ_BROKER_URL_DEFAULT = "vm://localhost?broker.persistent=false";

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

[fineract-cn-command] 02/08: Including sources in resulting artifact.

Posted by my...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-command.git

commit 9a341f169fcc93cfaf4c50a49fb552b2661416c6
Author: myrle-krantz <mk...@mifos.org>
AuthorDate: Thu Mar 23 14:37:27 2017 +0100

    Including sources in resulting artifact.
---
 build.gradle | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/build.gradle b/build.gradle
index 97cb772..e3a8a7a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -66,6 +66,10 @@ publishing {
     }
 }
 
+jar {
+    from sourceSets.main.allSource
+}
+
 license {
     header rootProject.file('HEADER')
     strictCheck true

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

[fineract-cn-command] 01/08: Open sourcing core.command.

Posted by my...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-command.git

commit 03bdd5e0a04b0c4339284a4878d6acf6031aea06
Author: myrle-krantz <mk...@mifos.org>
AuthorDate: Tue Mar 14 11:39:16 2017 +0100

    Open sourcing core.command.
---
 .gitignore                                         |  14 ++
 HEADER                                             |  13 ++
 LICENSE                                            | 201 ++++++++++++++++++
 README.md                                          |  45 ++++
 build.gradle                                       |  77 +++++++
 gradle/wrapper/gradle-wrapper.jar                  | Bin 0 -> 54212 bytes
 gradle/wrapper/gradle-wrapper.properties           |   6 +
 gradlew                                            | 172 ++++++++++++++++
 gradlew.bat                                        |  84 ++++++++
 settings.gradle                                    |   1 +
 .../mifos/core/command/annotation/Aggregate.java   |  32 +++
 .../core/command/annotation/CommandHandler.java    |  29 +++
 .../core/command/annotation/EventEmitter.java      |  32 +++
 .../command/config/CommandModuleConfiguration.java |  98 +++++++++
 .../command/config/EnableCommandProcessing.java    |  35 ++++
 .../mifos/core/command/domain/CommandCallback.java |  33 +++
 .../core/command/domain/CommandHandlerHolder.java  |  53 +++++
 .../command/domain/CommandProcessingException.java |  23 +++
 .../mifos/core/command/gateway/CommandGateway.java |  42 ++++
 .../io/mifos/core/command/internal/CommandBus.java | 228 +++++++++++++++++++++
 .../core/command/repository/CommandSource.java     | 130 ++++++++++++
 .../mifos/core/command/util/CommandConstants.java  |  31 +++
 .../core/command/fixture/DomainAggregate.java      |  56 +++++
 .../core/command/fixture/DomainException.java      |  23 +++
 .../mifos/core/command/fixture/DomainObject.java   |  35 ++++
 .../command/fixture/ErroneousDomainCommand.java    |  23 +++
 .../core/command/fixture/ReturningCommand.java     |  30 +++
 .../command/fixture/ReturningWithEventCommand.java |  30 +++
 .../io/mifos/core/command/fixture/VoidCommand.java |  23 +++
 .../core/command/fixture/VoidWithEventCommand.java |  23 +++
 .../core/command/internal/CommandBusTest.java      | 207 +++++++++++++++++++
 31 files changed, 1829 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..97a9529
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,14 @@
+.gradle
+.idea
+build/
+target/
+
+# Ignore Gradle GUI config
+gradle-app.setting
+
+# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
+!gradle-wrapper.jar
+
+*.iml
+
+*.log
\ No newline at end of file
diff --git a/HEADER b/HEADER
new file mode 100644
index 0000000..d47a70e
--- /dev/null
+++ b/HEADER
@@ -0,0 +1,13 @@
+Copyright ${year} ${name}.
+
+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.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8dada3e
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+                                 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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c1012be
--- /dev/null
+++ b/README.md
@@ -0,0 +1,45 @@
+# Mifos I/O Core Command
+
+[![Join the chat at https://gitter.im/mifos-initiative/mifos.io](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mifos-initiative/mifos.io?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
+This project is an umbrella for all Mifos I/O Core components.
+
+## Abstract
+Mifos I/O is an application framework for digital financial services, a system to support nationwide and cross-national financial transactions and help to level and speed the creation of an inclusive, interconnected digital economy for every nation in the world.
+
+## Prerequisites
+### Runtime
+Install Java 8 as described at https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html.
+
+### Cassandra
+Install Apache Cassandra as described at https://wiki.apache.org/cassandra/GettingStarted.
+
+After installation you need to create the meta keyspace:
+
+    cqlsh
+    CREATE KEYSPACE IF NOT EXISTS system_console
+      WITH REPLICATION = {
+          'class' : 'SimpleStrategy',
+          'replication_factor' : 3
+      };
+
+## Multi-tenancy
+Multi-tenancy is reached by providing separate data storage on a per tenant basis.
+
+For every tenant a new keyspace is created internally. A tenant aware component provides transparent access to these resources.
+
+## Versioning
+The version numbers follow the [Semantic Versioning](http://semver.org/) scheme.
+
+In addition to MAJOR.MINOR.PATCH the following postfixes are used to indicate the development state.
+
+* BUILD-SNAPSHOT - A release currently in development. 
+* RELEASE - _General availability_ indicates that this release is the best available version and is recommended for all usage.
+
+The versioning layout is {MAJOR}.{MINOR}.{PATCH}-{INDICATOR}[.{PATCH}]. Only milestones and release candidates can  have patch versions. Some examples:
+
+1.2.3-BUILD-SNAPSHOT  
+1.3.5-RELEASE
+
+## License
+See [LICENSE](LICENSE) file.
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..97cb772
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,77 @@
+buildscript {
+    repositories {
+        jcenter();
+    }
+}
+
+plugins {
+    id 'com.github.hierynomus.license' version '0.13.1'
+}
+
+group 'io.mifos.core'
+version '0.1.0-BUILD-SNAPSHOT'
+
+ext.versions = [
+        springcontext             : '4.3.3.RELEASE',
+        springboot                : '1.4.1.RELEASE',
+        gson                      : '2.5',
+        findbugs                  : '3.0.1',
+        frameworklangversion      : '0.1.0-BUILD-SNAPSHOT',
+        frameworkasyncversion     : '0.1.0-BUILD-SNAPSHOT',
+        frameworkcassandraversion : '0.1.0-BUILD-SNAPSHOT'
+]
+
+apply plugin: 'java'
+apply plugin: 'idea'
+apply plugin: 'maven'
+apply plugin: 'maven-publish'
+apply plugin: 'license'
+
+tasks.withType(JavaCompile) {
+    sourceCompatibility = JavaVersion.VERSION_1_8
+    targetCompatibility = JavaVersion.VERSION_1_8
+}
+
+repositories {
+    jcenter()
+    mavenLocal()
+}
+
+
+dependencies {
+    compile(
+            [group: 'org.springframework', name: 'spring-context', version: versions.springcontext],
+            [group: 'com.google.code.findbugs', name: 'jsr305', version: versions.findbugs],
+            [group: 'org.springframework', name: 'spring-jms', version: versions.springcontext],
+            [group: 'org.apache.activemq', name: 'activemq-spring', version: '5.13.2'],
+            [group: 'com.google.code.gson', name: 'gson', version: versions.gson],
+            [group: 'io.mifos.core', name: 'lang', version: versions.frameworklangversion],
+            [group: 'io.mifos.core', name: 'async', version: versions.frameworkasyncversion],
+            [group: 'io.mifos.core', name: 'cassandra', version: versions.frameworkcassandraversion]
+    )
+
+    testCompile(
+            [group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: versions.springboot]
+    )
+}
+
+publishing {
+    publications {
+        commandPublication(MavenPublication) {
+            from components.java
+            groupId project.group
+            artifactId project.name
+            version project.version
+        }
+    }
+}
+
+license {
+    header rootProject.file('HEADER')
+    strictCheck true
+    mapping {
+        java = 'SLASHSTAR_STYLE'
+    }
+    ext.year = Calendar.getInstance().get(Calendar.YEAR)
+    ext.name = 'The Mifos Initiative'
+}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..2fe063b
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..10c05a8
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Mar 14 10:46:02 CET 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-bin.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..4453cce
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save ( ) {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..e95643d
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..b3a7e2b
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'command'
\ No newline at end of file
diff --git a/src/main/java/io/mifos/core/command/annotation/Aggregate.java b/src/main/java/io/mifos/core/command/annotation/Aggregate.java
new file mode 100644
index 0000000..8fc7c51
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/annotation/Aggregate.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.annotation;
+
+import org.springframework.stereotype.Component;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+@Component
+public @interface Aggregate {
+
+}
diff --git a/src/main/java/io/mifos/core/command/annotation/CommandHandler.java b/src/main/java/io/mifos/core/command/annotation/CommandHandler.java
new file mode 100644
index 0000000..8b57ae3
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/annotation/CommandHandler.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@Documented
+public @interface CommandHandler {
+
+}
diff --git a/src/main/java/io/mifos/core/command/annotation/EventEmitter.java b/src/main/java/io/mifos/core/command/annotation/EventEmitter.java
new file mode 100644
index 0000000..73f66ab
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/annotation/EventEmitter.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@Documented
+public @interface EventEmitter {
+
+  String selectorName();
+
+  String selectorValue();
+}
diff --git a/src/main/java/io/mifos/core/command/config/CommandModuleConfiguration.java b/src/main/java/io/mifos/core/command/config/CommandModuleConfiguration.java
new file mode 100644
index 0000000..f02a604
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/config/CommandModuleConfiguration.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.config;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import io.mifos.core.command.util.CommandConstants;
+import io.mifos.core.lang.ApplicationName;
+import io.mifos.core.lang.config.EnableApplicationName;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.jms.pool.PooledConnectionFactory;
+import org.apache.activemq.spring.ActiveMQConnectionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
+import org.springframework.jms.config.JmsListenerContainerFactory;
+import org.springframework.jms.core.JmsTemplate;
+
+@Configuration
+@EnableApplicationName
+@ComponentScan(basePackages = {
+    "io.mifos.core.command.internal",
+    "io.mifos.core.command.gateway"
+})
+public class CommandModuleConfiguration {
+
+  private final Environment environment;
+
+  @Autowired
+  public CommandModuleConfiguration(Environment environment) {
+    super();
+    this.environment = environment;
+  }
+
+  @Bean(name = CommandConstants.SERIALIZER)
+  public Gson gson() {
+    return new GsonBuilder().create();
+  }
+
+  @Bean(name = CommandConstants.LOGGER_NAME)
+  public Logger loggerBean() {
+    return LoggerFactory.getLogger(CommandConstants.LOGGER_NAME);
+  }
+
+  @Bean
+  public PooledConnectionFactory jmsFactory() {
+    final PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory();
+    final ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
+    activeMQConnectionFactory.setBrokerURL(
+        this.environment.getProperty(
+            CommandConstants.ACTIVEMQ_BROKER_URL_PROP,
+            CommandConstants.ACTIVEMQ_BROKER_URL_DEFAULT));
+    pooledConnectionFactory.setConnectionFactory(activeMQConnectionFactory);
+    return pooledConnectionFactory;
+  }
+
+  @Bean
+  public JmsListenerContainerFactory jmsListenerContainerFactory(final PooledConnectionFactory jmsFactory) {
+    final DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
+    factory.setPubSubDomain(true);
+    factory.setConnectionFactory(jmsFactory);
+    factory.setConcurrency(
+        this.environment.getProperty(
+            CommandConstants.ACTIVEMQ_CONCURRENCY_PROP,
+            CommandConstants.ACTIVEMQ_CONCURRENCY_DEFAULT
+        )
+    );
+    return factory;
+  }
+
+  @Bean
+  public JmsTemplate jmsTemplate(final ApplicationName applicationName, final PooledConnectionFactory jmsFactory) {
+    final ActiveMQTopic activeMQTopic = new ActiveMQTopic(applicationName.toString());
+    final JmsTemplate jmsTemplate = new JmsTemplate();
+    jmsTemplate.setPubSubDomain(true);
+    jmsTemplate.setConnectionFactory(jmsFactory);
+    jmsTemplate.setDefaultDestination(activeMQTopic);
+    return jmsTemplate;
+  }
+}
diff --git a/src/main/java/io/mifos/core/command/config/EnableCommandProcessing.java b/src/main/java/io/mifos/core/command/config/EnableCommandProcessing.java
new file mode 100644
index 0000000..fb36b24
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/config/EnableCommandProcessing.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.config;
+
+import org.springframework.context.annotation.Import;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@SuppressWarnings("unused")
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+@Import({CommandModuleConfiguration.class})
+public @interface EnableCommandProcessing {
+
+}
diff --git a/src/main/java/io/mifos/core/command/domain/CommandCallback.java b/src/main/java/io/mifos/core/command/domain/CommandCallback.java
new file mode 100644
index 0000000..e7d4a07
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/domain/CommandCallback.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.domain;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+public final class CommandCallback<T> {
+
+  private final Future<T> result;
+
+  public CommandCallback(final Future<T> result) {
+    super();
+    this.result = result;
+  }
+
+  public T get() throws ExecutionException, InterruptedException {
+    return this.result.get();
+  }
+}
\ No newline at end of file
diff --git a/src/main/java/io/mifos/core/command/domain/CommandHandlerHolder.java b/src/main/java/io/mifos/core/command/domain/CommandHandlerHolder.java
new file mode 100644
index 0000000..a0d4efa
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/domain/CommandHandlerHolder.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.domain;
+
+import io.mifos.core.command.annotation.EventEmitter;
+
+import java.lang.reflect.Method;
+
+public final class CommandHandlerHolder {
+
+  private final Object aggregate;
+  private final Method method;
+  private final EventEmitter eventEmitter;
+  private final Class<?>[] exceptionTypes;
+
+  public CommandHandlerHolder(final Object aggregate, final Method method, final EventEmitter eventEmitter,
+                              final Class<?>[] exceptionTypes) {
+    super();
+    this.aggregate = aggregate;
+    this.method = method;
+    this.eventEmitter = eventEmitter;
+    this.exceptionTypes = exceptionTypes;
+  }
+
+  public Object aggregate() {
+    return aggregate;
+  }
+
+  public Method method() {
+    return method;
+  }
+
+  public EventEmitter eventEmitter() {
+    return eventEmitter;
+  }
+
+  public Class<?>[] exceptionTypes() {
+    return exceptionTypes;
+  }
+}
diff --git a/src/main/java/io/mifos/core/command/domain/CommandProcessingException.java b/src/main/java/io/mifos/core/command/domain/CommandProcessingException.java
new file mode 100644
index 0000000..ca704a9
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/domain/CommandProcessingException.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.domain;
+
+public class CommandProcessingException extends Exception {
+
+  public CommandProcessingException(String message, Throwable cause) {
+    super(message, cause);
+  }
+}
diff --git a/src/main/java/io/mifos/core/command/gateway/CommandGateway.java b/src/main/java/io/mifos/core/command/gateway/CommandGateway.java
new file mode 100644
index 0000000..556b044
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/gateway/CommandGateway.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.gateway;
+
+import io.mifos.core.command.domain.CommandCallback;
+import io.mifos.core.command.domain.CommandProcessingException;
+import io.mifos.core.command.internal.CommandBus;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CommandGateway {
+
+  private final CommandBus commandBus;
+
+  @Autowired
+  public CommandGateway(final CommandBus commandBus) {
+    super();
+    this.commandBus = commandBus;
+  }
+
+  public <C> void process(final C command) {
+    this.commandBus.dispatch(command);
+  }
+
+  public <C, T> CommandCallback<T> process(final C command, Class<T> clazz) throws CommandProcessingException {
+    return new CommandCallback<>(this.commandBus.dispatch(command, clazz));
+  }
+}
diff --git a/src/main/java/io/mifos/core/command/internal/CommandBus.java b/src/main/java/io/mifos/core/command/internal/CommandBus.java
new file mode 100644
index 0000000..73466f7
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/internal/CommandBus.java
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.internal;
+
+import com.google.gson.Gson;
+import io.mifos.core.cassandra.core.TenantAwareEntityTemplate;
+import io.mifos.core.command.annotation.Aggregate;
+import io.mifos.core.command.annotation.CommandHandler;
+import io.mifos.core.command.annotation.EventEmitter;
+import io.mifos.core.command.domain.CommandHandlerHolder;
+import io.mifos.core.command.domain.CommandProcessingException;
+import io.mifos.core.command.repository.CommandSource;
+import io.mifos.core.command.util.CommandConstants;
+import io.mifos.core.lang.TenantContextHolder;
+import io.mifos.core.lang.config.TenantHeaderFilter;
+import org.slf4j.Logger;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.core.annotation.AnnotationUtils;
+import org.springframework.core.env.Environment;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.AsyncResult;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Future;
+
+@Component
+public class CommandBus implements ApplicationContextAware {
+
+  private final Environment environment;
+  private final Logger logger;
+  private final Gson gson;
+  private final TenantAwareEntityTemplate tenantAwareEntityTemplate;
+  private final JmsTemplate jmsTemplate;
+
+  private final ConcurrentHashMap<Class, CommandHandlerHolder> cachedCommandHandlers = new ConcurrentHashMap<>();
+  private ApplicationContext applicationContext;
+
+  @Autowired
+  public CommandBus(final Environment environment,
+                    @Qualifier(CommandConstants.LOGGER_NAME) final Logger logger,
+                    @Qualifier(CommandConstants.SERIALIZER) final Gson gson,
+                    @SuppressWarnings("SpringJavaAutowiringInspection") TenantAwareEntityTemplate tenantAwareEntityTemplate,
+                    final JmsTemplate jmsTemplate) {
+    super();
+    this.environment = environment;
+    this.logger = logger;
+    this.gson = gson;
+    this.tenantAwareEntityTemplate = tenantAwareEntityTemplate;
+    this.jmsTemplate = jmsTemplate;
+  }
+
+  @Async
+  public <C> void dispatch(final C command) {
+    this.logger.debug("CommandBus::dispatch-async called.");
+    final CommandSource commandSource = this.storeCommand(command);
+    CommandHandlerHolder commandHandlerHolder = null;
+    try {
+      commandHandlerHolder = this.findCommandHandler(command);
+      final Object result = commandHandlerHolder.method().invoke(commandHandlerHolder.aggregate(), command);
+      this.updateCommandSource(commandSource, null);
+      if (commandHandlerHolder.eventEmitter() != null) {
+        this.fireEvent(result, commandHandlerHolder.eventEmitter());
+      }
+    } catch (final Throwable th) {
+      //noinspection ThrowableResultOfMethodCallIgnored
+      this.handle(th, commandSource, (commandHandlerHolder != null ? commandHandlerHolder.exceptionTypes() : null));
+    }
+  }
+
+  @Async
+  public <C, T> Future<T> dispatch(final C command, final Class<T> clazz) throws CommandProcessingException {
+    this.logger.debug("CommandBus::dispatch-sync called.");
+    // store command
+    final CommandSource commandSource = this.storeCommand(command);
+    CommandHandlerHolder commandHandlerHolder = null;
+    try {
+      // find command handling method
+      commandHandlerHolder = this.findCommandHandler(command);
+      final Object result = commandHandlerHolder.method().invoke(commandHandlerHolder.aggregate(), command);
+      this.updateCommandSource(commandSource, null);
+
+      if (commandHandlerHolder.eventEmitter() != null) {
+        this.fireEvent(result, commandHandlerHolder.eventEmitter());
+      }
+
+      return new AsyncResult<>(clazz.cast(result));
+    } catch (final Throwable th) {
+      throw this.handle(th, commandSource, (commandHandlerHolder != null ? commandHandlerHolder.exceptionTypes() : null));
+    }
+  }
+
+  private <C> CommandHandlerHolder findCommandHandler(final C command) {
+    this.logger.debug("CommandBus::findCommandHandler called for {}.", command.getClass().getSimpleName());
+    final Class<?> commandClass = command.getClass();
+    this.cachedCommandHandlers.computeIfAbsent(commandClass, findHandler -> {
+      final Map<String, Object> aggregates = this.applicationContext.getBeansWithAnnotation(Aggregate.class);
+      for (Object aggregate : aggregates.values()) {
+        final CommandHandlerHolder commandHandlerHolder = this.getCommandHandlerMethodFromClass(commandClass, aggregate);
+        if (commandHandlerHolder != null) {
+          return commandHandlerHolder;
+        }
+      }
+      this.logger.info("Could not find command handler for {}.", commandClass.getSimpleName());
+      throw new IllegalArgumentException("No command handler found.");
+    });
+    return this.cachedCommandHandlers.get(commandClass);
+  }
+
+  CommandHandlerHolder getCommandHandlerMethodFromClass(final Class<?> commandClass, final Object aggregate) {
+    final Method[] methods = aggregate.getClass().getDeclaredMethods();
+    for (final Method method : methods) {
+      if (AnnotationUtils.findAnnotation(method, CommandHandler.class) != null
+          && method.getParameterCount() == 1
+          && method.getParameterTypes()[0].isAssignableFrom(commandClass)) {
+        this.logger.debug("CommandBus::findCommandHandler added method for {}.", commandClass.getSimpleName());
+        return new CommandHandlerHolder(aggregate, method, AnnotationUtils.findAnnotation(method, EventEmitter.class),
+            method.getExceptionTypes());
+      }
+    }
+    return null;
+  }
+
+  private <C> CommandSource storeCommand(final C command) {
+    this.logger.debug("CommandBus::storeCommand called.");
+    final LocalDateTime now = LocalDateTime.now();
+
+    final CommandSource commandSource = new CommandSource();
+    commandSource.setSource(
+        this.environment.getProperty(
+            CommandConstants.APPLICATION_NAME_PROP,
+            CommandConstants.APPLICATION_NAME_DEFAULT
+        )
+    );
+    commandSource.setBucket(now.format(DateTimeFormatter.ISO_LOCAL_DATE));
+    commandSource.setCreatedOn(Date.from(now.atZone(ZoneId.systemDefault()).toInstant()));
+    commandSource.setCommand(this.gson.toJson(command));
+
+    this.tenantAwareEntityTemplate.save(commandSource);
+
+    return commandSource;
+  }
+
+  private void updateCommandSource(final CommandSource commandSource, final String failureMessage) {
+    this.logger.debug("CommandBus::updateCommandSource called.");
+    if (failureMessage != null) {
+      commandSource.setFailed(Boolean.TRUE);
+      commandSource.setFailureMessage(failureMessage);
+    } else {
+      commandSource.setProcessed(Boolean.TRUE);
+    }
+
+    this.tenantAwareEntityTemplate.save(commandSource);
+  }
+
+  private <T> void fireEvent(final T eventPayload, final EventEmitter eventEmitter) {
+    if (eventPayload != null) {
+      this.jmsTemplate.convertAndSend(
+          this.gson.toJson(eventPayload),
+          message -> {
+            if (TenantContextHolder.identifier().isPresent()) {
+              message.setStringProperty(
+                  TenantHeaderFilter.TENANT_HEADER,
+                  TenantContextHolder.checkedGetIdentifier());
+            }
+            message.setStringProperty(
+                eventEmitter.selectorName(),
+                eventEmitter.selectorValue()
+            );
+            return message;
+          }
+      );
+    }
+  }
+
+  private CommandProcessingException handle(final Throwable th, final CommandSource commandSource,
+                                            final Class<?>[] declaredExceptions) {
+    final Throwable cause;
+    if (th.getClass().isAssignableFrom(InvocationTargetException.class)) {
+      cause = th.getCause();
+    } else {
+      cause = th;
+    }
+    this.logger.info(cause.getMessage(), cause);
+    this.updateCommandSource(commandSource, cause.getMessage());
+    if (declaredExceptions != null) {
+      if (Arrays.asList(declaredExceptions).contains(cause.getClass())) {
+        if (cause instanceof RuntimeException) {
+          throw RuntimeException.class.cast(cause);
+        } else {
+          this.logger.info("Exception {} is not a runtime exception.", cause.getClass().getSimpleName());
+        }
+      }
+    }
+    return new CommandProcessingException(cause.getMessage(), cause);
+  }
+
+  @Override
+  public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
+    this.applicationContext = applicationContext;
+  }
+}
diff --git a/src/main/java/io/mifos/core/command/repository/CommandSource.java b/src/main/java/io/mifos/core/command/repository/CommandSource.java
new file mode 100644
index 0000000..753cb71
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/repository/CommandSource.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.repository;
+
+import com.datastax.driver.mapping.annotations.ClusteringColumn;
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+import io.mifos.core.command.util.CommandConstants;
+
+import java.util.Date;
+
+@SuppressWarnings("unused")
+@Table(name = CommandConstants.COMMAND_SOURCE_TABLE_NAME)
+public final class CommandSource {
+
+  @SuppressWarnings("DefaultAnnotationParam")
+  @PartitionKey(0)
+  @Column(name = "source")
+  private String source;
+  @PartitionKey(1)
+  @Column(name = "bucket")
+  private String bucket;
+  @SuppressWarnings("DefaultAnnotationParam")
+  @ClusteringColumn(0)
+  @Column(name = "created_on")
+  private Date createdOn;
+  @Column(name = "command")
+  private String command;
+  @Column(name = "processed")
+  private Boolean processed;
+  @Column(name = "failed")
+  private Boolean failed;
+  @Column(name = "failure_message")
+  private String failureMessage;
+
+  public CommandSource() {
+    super();
+  }
+
+  public String getSource() {
+    return source;
+  }
+
+  public void setSource(String source) {
+    this.source = source;
+  }
+
+  public String getBucket() {
+    return bucket;
+  }
+
+  public void setBucket(String bucket) {
+    this.bucket = bucket;
+  }
+
+  public Date getCreatedOn() {
+    return createdOn;
+  }
+
+  public void setCreatedOn(Date createdOn) {
+    this.createdOn = createdOn;
+  }
+
+  public String getCommand() {
+    return command;
+  }
+
+  public void setCommand(String command) {
+    this.command = command;
+  }
+
+  public Boolean getProcessed() {
+    return processed;
+  }
+
+  public void setProcessed(Boolean processed) {
+    this.processed = processed;
+  }
+
+  public Boolean getFailed() {
+    return failed;
+  }
+
+  public void setFailed(Boolean failed) {
+    this.failed = failed;
+  }
+
+  public String getFailureMessage() {
+    return failureMessage;
+  }
+
+  public void setFailureMessage(String failureMessage) {
+    this.failureMessage = failureMessage;
+  }
+
+  @SuppressWarnings("SimplifiableIfStatement")
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    CommandSource that = (CommandSource) o;
+
+    if (!source.equals(that.source)) return false;
+    if (!bucket.equals(that.bucket)) return false;
+    return createdOn.equals(that.createdOn);
+  }
+
+  @Override
+  public int hashCode() {
+    int result = source.hashCode();
+    result = 31 * result + bucket.hashCode();
+    result = 31 * result + createdOn.hashCode();
+    return result;
+  }
+}
diff --git a/src/main/java/io/mifos/core/command/util/CommandConstants.java b/src/main/java/io/mifos/core/command/util/CommandConstants.java
new file mode 100644
index 0000000..b9e9c9e
--- /dev/null
+++ b/src/main/java/io/mifos/core/command/util/CommandConstants.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.util;
+
+public interface CommandConstants {
+
+  String LOGGER_NAME = "command-logger";
+  String SERIALIZER = "command-serializer";
+  String COMMAND_SOURCE_TABLE_NAME = "command_source";
+
+  String APPLICATION_NAME_PROP = "spring.application.name";
+  String APPLICATION_NAME_DEFAULT = "command/v1";
+
+  String ACTIVEMQ_BROKER_URL_PROP = "activemq.brokerUrl";
+  String ACTIVEMQ_BROKER_URL_DEFAULT = "vm://localhost?broker.persistent=false";
+  String ACTIVEMQ_CONCURRENCY_PROP = "activemq.concurrency";
+  String ACTIVEMQ_CONCURRENCY_DEFAULT = "3-10";
+}
diff --git a/src/test/java/io/mifos/core/command/fixture/DomainAggregate.java b/src/test/java/io/mifos/core/command/fixture/DomainAggregate.java
new file mode 100644
index 0000000..bf4792c
--- /dev/null
+++ b/src/test/java/io/mifos/core/command/fixture/DomainAggregate.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.fixture;
+
+import io.mifos.core.command.annotation.Aggregate;
+import io.mifos.core.command.annotation.CommandHandler;
+import io.mifos.core.command.annotation.EventEmitter;
+
+@Aggregate
+public class DomainAggregate {
+
+  public DomainAggregate() {
+    super();
+  }
+
+  @CommandHandler
+  public void voidCommand(final VoidCommand voidCommand) {
+    // do nothing
+  }
+
+  @CommandHandler
+  public DomainObject returningCommand(final ReturningCommand returningCommand) {
+    return returningCommand.getDomainObject();
+  }
+
+  @CommandHandler
+  @EventEmitter(selectorName = "operation", selectorValue = "void")
+  public String voidWithEventCommand(final VoidWithEventCommand voidWithEventCommand) {
+    return "event";
+  }
+
+  @CommandHandler
+  @EventEmitter(selectorName = "operation", selectorValue = "returning")
+  public DomainObject returningWithEventCommand(
+      final ReturningWithEventCommand returningWithEventCommand) {
+    return returningWithEventCommand.getDomainObject();
+  }
+
+  @CommandHandler
+  public void erroneous(final ErroneousDomainCommand erroneousDomainCommand) throws DomainException {
+    throw new DomainException();
+  }
+}
diff --git a/src/test/java/io/mifos/core/command/fixture/DomainException.java b/src/test/java/io/mifos/core/command/fixture/DomainException.java
new file mode 100644
index 0000000..640f77b
--- /dev/null
+++ b/src/test/java/io/mifos/core/command/fixture/DomainException.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.fixture;
+
+public class DomainException extends RuntimeException {
+
+  DomainException() {
+    super();
+  }
+}
diff --git a/src/test/java/io/mifos/core/command/fixture/DomainObject.java b/src/test/java/io/mifos/core/command/fixture/DomainObject.java
new file mode 100644
index 0000000..2551a78
--- /dev/null
+++ b/src/test/java/io/mifos/core/command/fixture/DomainObject.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.fixture;
+
+public class DomainObject {
+
+  private String stringProperty;
+  private Long longProperty;
+
+  public DomainObject(final String stringProperty, final Long longProperty) {
+    this.stringProperty = stringProperty;
+    this.longProperty = longProperty;
+  }
+
+  public String getStringProperty() {
+    return stringProperty;
+  }
+
+  public Long getLongProperty() {
+    return longProperty;
+  }
+}
diff --git a/src/test/java/io/mifos/core/command/fixture/ErroneousDomainCommand.java b/src/test/java/io/mifos/core/command/fixture/ErroneousDomainCommand.java
new file mode 100644
index 0000000..25087bd
--- /dev/null
+++ b/src/test/java/io/mifos/core/command/fixture/ErroneousDomainCommand.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.fixture;
+
+public class ErroneousDomainCommand {
+
+  public ErroneousDomainCommand() {
+    super();
+  }
+}
diff --git a/src/test/java/io/mifos/core/command/fixture/ReturningCommand.java b/src/test/java/io/mifos/core/command/fixture/ReturningCommand.java
new file mode 100644
index 0000000..365c22f
--- /dev/null
+++ b/src/test/java/io/mifos/core/command/fixture/ReturningCommand.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.fixture;
+
+public class ReturningCommand {
+
+  private final DomainObject domainObject;
+
+  public ReturningCommand(final DomainObject domainObject) {
+    super();
+    this.domainObject = domainObject;
+  }
+
+  DomainObject getDomainObject() {
+    return domainObject;
+  }
+}
diff --git a/src/test/java/io/mifos/core/command/fixture/ReturningWithEventCommand.java b/src/test/java/io/mifos/core/command/fixture/ReturningWithEventCommand.java
new file mode 100644
index 0000000..2749069
--- /dev/null
+++ b/src/test/java/io/mifos/core/command/fixture/ReturningWithEventCommand.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.fixture;
+
+public class ReturningWithEventCommand {
+
+  private final DomainObject domainObject;
+
+  public ReturningWithEventCommand(final DomainObject domainObject) {
+    super();
+    this.domainObject = domainObject;
+  }
+
+  DomainObject getDomainObject() {
+    return domainObject;
+  }
+}
diff --git a/src/test/java/io/mifos/core/command/fixture/VoidCommand.java b/src/test/java/io/mifos/core/command/fixture/VoidCommand.java
new file mode 100644
index 0000000..642b905
--- /dev/null
+++ b/src/test/java/io/mifos/core/command/fixture/VoidCommand.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.fixture;
+
+public class VoidCommand {
+
+  public VoidCommand() {
+    super();
+  }
+}
diff --git a/src/test/java/io/mifos/core/command/fixture/VoidWithEventCommand.java b/src/test/java/io/mifos/core/command/fixture/VoidWithEventCommand.java
new file mode 100644
index 0000000..6703ef9
--- /dev/null
+++ b/src/test/java/io/mifos/core/command/fixture/VoidWithEventCommand.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.fixture;
+
+public class VoidWithEventCommand {
+
+  public VoidWithEventCommand() {
+    super();
+  }
+}
diff --git a/src/test/java/io/mifos/core/command/internal/CommandBusTest.java b/src/test/java/io/mifos/core/command/internal/CommandBusTest.java
new file mode 100644
index 0000000..3b3d98f
--- /dev/null
+++ b/src/test/java/io/mifos/core/command/internal/CommandBusTest.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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 io.mifos.core.command.internal;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import io.mifos.core.cassandra.core.TenantAwareEntityTemplate;
+import io.mifos.core.command.annotation.Aggregate;
+import io.mifos.core.command.annotation.CommandHandler;
+import io.mifos.core.command.domain.CommandHandlerHolder;
+import io.mifos.core.command.domain.CommandProcessingException;
+import io.mifos.core.command.fixture.DomainAggregate;
+import io.mifos.core.command.fixture.DomainException;
+import io.mifos.core.command.fixture.DomainObject;
+import io.mifos.core.command.fixture.ErroneousDomainCommand;
+import io.mifos.core.command.fixture.ReturningCommand;
+import io.mifos.core.command.fixture.ReturningWithEventCommand;
+import io.mifos.core.command.fixture.VoidCommand;
+import io.mifos.core.command.fixture.VoidWithEventCommand;
+import io.mifos.core.command.repository.CommandSource;
+import io.mifos.core.command.util.CommandConstants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.slf4j.Logger;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.env.Environment;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.jms.core.MessagePostProcessor;
+
+import java.util.HashMap;
+import java.util.concurrent.Future;
+
+public class CommandBusTest {
+
+  public CommandBusTest() {
+    super();
+  }
+
+  private static TestHarness createTestHarness() {
+    final Environment mockedEnvironment = Mockito.mock(Environment.class);
+    Mockito.when(mockedEnvironment.getProperty(CommandConstants.APPLICATION_NAME_PROP,
+        CommandConstants.APPLICATION_NAME_DEFAULT))
+        .thenReturn(CommandConstants.APPLICATION_NAME_DEFAULT);
+
+    final Logger mockedLogger = Mockito.mock(Logger.class);
+
+    final Gson gson = new GsonBuilder().create();
+
+    final TenantAwareEntityTemplate mockedTenantAwareEntityTemplate = Mockito.mock(TenantAwareEntityTemplate.class);
+
+    final JmsTemplate mockedJmsTemplate = Mockito.mock(JmsTemplate.class);
+
+    final ApplicationContext mockedApplicationContext = Mockito.mock(ApplicationContext.class);
+    final HashMap<String, Object> mockedBeans = new HashMap<>();
+    mockedBeans.put(DomainAggregate.class.getSimpleName(), new DomainAggregate());
+    Mockito.when(mockedApplicationContext.getBeansWithAnnotation(Mockito.eq(Aggregate.class)))
+        .thenReturn(mockedBeans);
+    Mockito.when(mockedApplicationContext.getBean(Mockito.eq(DomainAggregate.class)))
+        .thenReturn((DomainAggregate) mockedBeans.get(DomainAggregate.class.getSimpleName()));
+
+    final CommandBus commandBus =
+        new CommandBus(mockedEnvironment, mockedLogger, gson, mockedTenantAwareEntityTemplate, mockedJmsTemplate);
+    commandBus.setApplicationContext(mockedApplicationContext);
+
+    return new TestHarness(commandBus, mockedTenantAwareEntityTemplate, mockedJmsTemplate);
+  }
+
+  @Test
+  public void shouldProcessVoidCommand() {
+    final TestHarness testHarness = createTestHarness();
+    testHarness.commandBus.dispatch(new VoidCommand());
+
+    Mockito.verify(testHarness.mockedTenantAwareEntityTemplate, Mockito.times(2)).save(Mockito.any(CommandSource.class));
+    Mockito.verify(testHarness.jmsTemplate, Mockito.times(0)).convertAndSend(Mockito.any(Object.class), Mockito.any(MessagePostProcessor.class));
+  }
+
+  @Test
+  public void shouldProcessReturningCommand() throws Exception {
+    final TestHarness testHarness = createTestHarness();
+    final DomainObject domainObject = new DomainObject("test", 1L);
+
+    final Future<DomainObject> future = testHarness.commandBus.dispatch(new ReturningCommand(domainObject), DomainObject.class);
+    final DomainObject returnValue = future.get();
+
+    Assert.assertNotNull(returnValue);
+    Assert.assertEquals(domainObject.getStringProperty(), returnValue.getStringProperty());
+    Assert.assertEquals(domainObject.getLongProperty(), returnValue.getLongProperty());
+
+    Mockito.verify(testHarness.mockedTenantAwareEntityTemplate, Mockito.times(2)).save(Mockito.any(CommandSource.class));
+    Mockito.verify(testHarness.jmsTemplate, Mockito.times(0)).convertAndSend(Mockito.any(Object.class), Mockito.any(MessagePostProcessor.class));
+  }
+
+  @Test
+  public void shouldProcessVoidWithEventCommand() {
+    final TestHarness testHarness = createTestHarness();
+    testHarness.commandBus.dispatch(new VoidWithEventCommand());
+
+    Mockito.verify(testHarness.mockedTenantAwareEntityTemplate, Mockito.times(2)).save(Mockito.any(CommandSource.class));
+    Mockito.verify(testHarness.jmsTemplate, Mockito.times(1)).convertAndSend(Mockito.any(Object.class), Mockito.any(MessagePostProcessor.class));
+  }
+
+  @Test
+  public void shouldProcessReturningWithEventCommand() throws Exception {
+    final TestHarness testHarness = createTestHarness();
+    final DomainObject domainObject = new DomainObject("test", 2L);
+
+    final Future<DomainObject> future = testHarness.commandBus.dispatch(new ReturningWithEventCommand(domainObject), DomainObject.class);
+    final DomainObject returnValue = future.get();
+
+    Assert.assertNotNull(returnValue);
+    Assert.assertEquals(domainObject.getStringProperty(), returnValue.getStringProperty());
+    Assert.assertEquals(domainObject.getLongProperty(), returnValue.getLongProperty());
+
+    Mockito.verify(testHarness.mockedTenantAwareEntityTemplate, Mockito.times(2)).save(Mockito.any(CommandSource.class));
+    Mockito.verify(testHarness.jmsTemplate, Mockito.times(1)).convertAndSend(Mockito.any(Object.class), Mockito.any(MessagePostProcessor.class));
+  }
+
+  @Test
+  public void shouldNotProcessCommandRethrowDeclaredException()
+      throws CommandProcessingException {
+
+    final TestHarness testHarness = createTestHarness();
+
+    final ErroneousDomainCommand erroneousDomainCommand = new ErroneousDomainCommand();
+    try {
+      testHarness.commandBus.dispatch(erroneousDomainCommand, Void.class);
+      Assert.fail();
+    } catch (final DomainException ex) {
+      // do nothing
+    }
+
+    Mockito.verify(testHarness.mockedTenantAwareEntityTemplate, Mockito.times(2)).save(Mockito.any(CommandSource.class));
+  }
+
+  @Test()
+  public void getCommandHandlerMethodWithoutReturnValue() {
+    final TestHarness testHarness = createTestHarness();
+    final TestCommandHandler aggregateHandler = new TestCommandHandler();
+    final CommandHandlerHolder commandHandlerHolder = testHarness.commandBus
+        .getCommandHandlerMethodFromClass(TestCommandClass1.class, aggregateHandler);
+    Assert.assertNotNull(commandHandlerHolder);
+  }
+
+  @Test()
+  public void getCommandHandlerMethodWithReturnValue() {
+    final TestHarness testHarness = createTestHarness();
+    final TestCommandHandler aggregateHandler = new TestCommandHandler();
+    final CommandHandlerHolder commandHandlerHolder = testHarness.commandBus
+        .getCommandHandlerMethodFromClass(TestCommandClass2.class, aggregateHandler);
+    Assert.assertNotNull(commandHandlerHolder);
+  }
+
+  private static class TestHarness {
+
+    CommandBus commandBus;
+    TenantAwareEntityTemplate mockedTenantAwareEntityTemplate;
+    JmsTemplate jmsTemplate;
+
+    private TestHarness(final CommandBus commandBus,
+                        final TenantAwareEntityTemplate mockedTenantAwareEntityTemplate,
+                        final JmsTemplate jmsTemplate) {
+      this.commandBus = commandBus;
+      this.mockedTenantAwareEntityTemplate = mockedTenantAwareEntityTemplate;
+      this.jmsTemplate = jmsTemplate;
+    }
+  }
+
+  private static class TestCommandClass1 {
+
+  }
+
+  private static class TestCommandClass2 {
+
+  }
+
+  private static class TestCommandResponse {
+
+  }
+
+  private static class TestCommandHandler {
+
+    @SuppressWarnings("unused")
+    @CommandHandler
+    void process(final TestCommandClass1 command) {
+    }
+
+    @SuppressWarnings("unused")
+    @CommandHandler
+    TestCommandResponse process(final TestCommandClass2 command) {
+      return new TestCommandResponse();
+    }
+  }
+}

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

[fineract-cn-command] 06/08: Added javadoc for command logging.

Posted by my...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-command.git

commit 72cad963eae29cb06537324432707fbfd1412d34
Author: myrle-krantz <mk...@mifos.org>
AuthorDate: Mon Jun 12 11:11:04 2017 +0200

    Added javadoc for command logging.
---
 .../core/command/annotation/CommandHandler.java      | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/main/java/io/mifos/core/command/annotation/CommandHandler.java b/src/main/java/io/mifos/core/command/annotation/CommandHandler.java
index e1db3e3..44c069d 100644
--- a/src/main/java/io/mifos/core/command/annotation/CommandHandler.java
+++ b/src/main/java/io/mifos/core/command/annotation/CommandHandler.java
@@ -21,6 +21,26 @@ import java.lang.annotation.*;
 @Target(ElementType.METHOD)
 @Documented
 public @interface CommandHandler {
+  /**
+   *
+   * @return the log level with which to log a command which will be sent to a command handler. By default this is
+   * NONE. The level should be left at NONE for sensitive data which do not belong in the log file, such as
+   * passwords, financial transactions, and customer names and addresses. The logfile contents will include what
+   * is output by "toString" of the command, so any fine-tuning of the contents of the logfile can be performed there.
+   * For commands which happen frequently this can produce a lot of output. Consider using a log level of DEBUG or
+   * TRACE if you decide to log a command of that sort. No log level of ERROR, or WARNING is offered here, because
+   * a command is not an error.
+   */
   CommandLogLevel logStart() default CommandLogLevel.NONE;
+
+  /**
+   *
+   * @return the log level with which to log the result of a command which emits an event. Leave this as it's default
+   * NONE, if the command is not event-emitting.  The level should also be left at NONE for sensitive data which do
+   * not belong in the log file, however you should consider not putting such data in the event queue in the first
+   * place. The logfile contents will include the output of the events "toString". For commands which happen frequently,
+   * this can produce a lot of output.  Consider not using INFO as a log level for a command of that sort. If a command
+   * handler is exited via an exception, no event is logged, but the exception may be logged regardless of this setting.
+   */
   CommandLogLevel logFinish() default CommandLogLevel.NONE;
 }

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.