You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/03/25 02:04:12 UTC

[1/9] isis git commit: ISIS-1028: Create Event Bus Service based on Axon

Repository: isis
Updated Branches:
  refs/heads/master 737c0a2c5 -> efb559e34


ISIS-1028: Create Event Bus Service based on Axon

Initial implementation to be verified by Dan.

There are tests failing locally on "isis-core-runtime", but not sure they're related with this ...


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/852da24b
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/852da24b
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/852da24b

Branch: refs/heads/master
Commit: 852da24bfb2c2b917a1db5d7320e09c4765c82dd
Parents: 99b7030
Author: Oscar Bou <os...@apache.org>
Authored: Sun Feb 8 12:55:47 2015 +0100
Committer: Oscar Bou <os...@apache.org>
Committed: Sun Feb 8 12:55:47 2015 +0100

----------------------------------------------------------------------
 .../isis/applib/services/eventbus/EventBus.java |  81 +++++++++++++++
 .../services/eventbus/EventBusService.java      |   8 +-
 core/runtime/pom.xml                            |   7 ++
 .../eventbus/AxonEventListenerAdapter.java      |  25 +++++
 .../eventbus/AxonSimpleEventBusAdapter.java     |  49 +++++++++
 .../eventbus/AxonSimpleEventBusService.java     |  12 +++
 .../eventbus/AxonSimpleEventBusServiceJdo.java  |  38 +++++++
 .../DefaultSubscriberExceptionHandler.java      |  62 +++++++++++
 .../services/eventbus/EventBusAdapter.java      |   7 ++
 .../eventbus/EventBusServiceDefault.java        | 103 +------------------
 .../services/eventbus/GuavaEventBusAdapter.java |  37 +++++++
 .../eventbus/RuntimeEventBusService.java        |  49 +++++++++
 12 files changed, 377 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBus.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBus.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBus.java
new file mode 100644
index 0000000..217d12b
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBus.java
@@ -0,0 +1,81 @@
+package org.apache.isis.applib.services.eventbus;
+
+
+/**
+ * Common interface for all Event Bus implementations.
+ * <p>
+ * Currently, there are implementations based on Guava and Axon frameworks.
+ * 
+ */
+public interface EventBus {
+
+    /**
+     * Both singleton and request-scoped domain services can register on the event bus; this should be done in their
+     * <code>@PostConstruct</code> callback method.
+     *
+     * <p>
+     *     <b>Important:</b> Request-scoped services should register their proxy, not themselves.  This is because it is
+     *     the responsibility of the proxy to ensure that the correct underlying (thread-local) instance of the service
+     *     is delegated to.  If the actual instance were to be registered, this would cause a memory leak and all sorts
+     *     of other unexpected issues.
+     * </p>
+     *
+     * <p>
+     *     Also, request-scoped services should <i>NOT</i> unregister themselves.  This is because the
+     *     <code>@PreDestroy</code> lifecycle method is called at the end of each transaction.  The proxy needs to
+     *     remain registered on behalf for any subsequent transactions.
+     * </p>
+     *
+     * <p>For example:</p>
+     * <pre>
+     *     @RequestScoped @DomainService
+     *     public class SomeSubscribingService {
+     *
+     *         @Inject private EventBusService ebs;
+     *         @Inject private SomeSubscribingService proxy;
+     *
+     *         @PostConstruct
+     *         public void startRequest() {
+     *              // register with bus
+     *              ebs.register(proxy);
+     *         }
+     *         @PreDestroy
+     *         public void endRequest() {
+     *              //no-op
+     *         }
+     *     }
+     * </pre>
+     *
+     * <p>
+     *     The <code>@PostConstruct</code> callback is the correct place to register for both singleton and
+     *     request-scoped services.  For singleton domain services, this is done during the initial bootstrapping of
+     *     the system.  For request-scoped services, this is done for the first transaction.  In fact, because
+     *     singleton domain services are initialized <i>within a current transaction</i>, the request-scoped services
+     *     will actually be registered <i>before</i> the singleton services.  Each subsequent transaction will have the
+     *     request-scoped service re-register with the event bus, however the event bus stores its subscribers in a
+     *     set and so these re-registrations are basically a no-op.
+     * </p>
+     *
+     * @param domainService
+     */
+    void register(Object domainService);
+
+    /**
+     * Notionally allows subscribers to unregister from the event bus; however this is a no-op.
+     *
+     * <p>
+     *     It is safe for singleton services to unregister from the bus, however this is only ever called when the
+     *     app is being shutdown so there is no real effect.  For request-scoped services meanwhile that (as
+     *     explained in {@link #register(Object)}'s documentation) actually register their proxy, it would be an error
+     *     to unregister the proxy; subsequent transactions (for this thread or others) must be routed through that
+     *     proxy.
+     * </p>
+     */
+    void unregister(Object domainService);
+
+    /**
+     * Post an event.
+     */
+    void post(Object event);
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
index 52d1c4e..77c8a38 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
@@ -18,10 +18,16 @@ package org.apache.isis.applib.services.eventbus;
 
 import java.util.Collections;
 import java.util.Set;
+
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
+
 import com.google.common.collect.Sets;
-import com.google.common.eventbus.EventBus;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.applib.annotation.Hidden;
 import org.apache.isis.applib.annotation.Programmatic;
 
 /**

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/pom.xml
----------------------------------------------------------------------
diff --git a/core/runtime/pom.xml b/core/runtime/pom.xml
index caad3d4..7aa4f50 100644
--- a/core/runtime/pom.xml
+++ b/core/runtime/pom.xml
@@ -210,6 +210,13 @@
             <version>1.1.1</version>
         </dependency>
         <!-- Email Notification Service -->
+        
+        <!-- Axon Event Bus Service -->
+        <dependency>
+            <groupId>org.axonframework</groupId>
+            <artifactId>axon-core</artifactId>
+            <version>2.4</version>
+        </dependency>
 
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
new file mode 100644
index 0000000..90c22c2
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
@@ -0,0 +1,25 @@
+package org.apache.isis.core.runtime.services.eventbus;
+
+import org.axonframework.domain.EventMessage;
+import org.axonframework.eventhandling.annotation.AnnotationEventListenerAdapter;
+
+public class AxonEventListenerAdapter extends AnnotationEventListenerAdapter {
+
+    public AxonEventListenerAdapter(Object annotatedEventListener) {
+        super(annotatedEventListener);
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * Adds
+     */
+    @Override
+    public void handle(@SuppressWarnings("rawtypes") EventMessage event) {
+        try {
+            super.handle(event);
+        } catch (Exception exception) {
+            DefaultSubscriberExceptionHandler.processException(exception, event);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
new file mode 100644
index 0000000..0b8d904
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
@@ -0,0 +1,49 @@
+package org.apache.isis.core.runtime.services.eventbus;
+
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+import org.axonframework.domain.GenericEventMessage;
+import org.axonframework.eventhandling.SimpleEventBus;
+
+public class AxonSimpleEventBusAdapter extends EventBusAdapter {
+
+    private static SimpleEventBus simpleEventBus = new SimpleEventBus();
+
+    private static Map<Object, AxonEventListenerAdapter> adapters = Maps.newConcurrentMap();
+
+    private static AxonEventListenerAdapter adapterFor(final Object domainService) {
+        AxonEventListenerAdapter annotationEventListenerAdapter = adapters.get(domainService);
+        if (annotationEventListenerAdapter == null) {
+            annotationEventListenerAdapter = new AxonEventListenerAdapter(domainService);
+            adapters.put(domainService, annotationEventListenerAdapter);
+        }
+        return annotationEventListenerAdapter;
+    }
+
+    @Override
+    public void register(final Object domainService) {
+        AxonSimpleEventBusAdapter.simpleEventBus.subscribe(AxonSimpleEventBusAdapter.adapterFor(domainService));
+
+    }
+
+    @Override
+    public void unregister(final Object domainService) {
+        // Seems it's needed to be a no-op (See EventBusService).
+        // AxonSimpleEventBusAdapter.simpleEventBus.unsubscribe(AxonSimpleEventBusAdapter.adapterFor(domainService));
+
+    }
+
+    /*
+     * {@inheritDoc} 
+     * <p> 
+     * Logic equivalent to Guava Event Bus. Despite that,
+     * event processing cannot be followed after an Exception is thrown.
+     */
+    @Override
+    public void post(final Object event) {
+        AxonSimpleEventBusAdapter.simpleEventBus.publish(GenericEventMessage.asEventMessage(event));
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
new file mode 100644
index 0000000..af41e4a
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
@@ -0,0 +1,12 @@
+package org.apache.isis.core.runtime.services.eventbus;
+
+import org.apache.isis.applib.services.eventbus.EventBus;
+
+public class AxonSimpleEventBusService extends RuntimeEventBusService {
+
+    @Override
+    protected EventBus newEventBus() {
+        return new AxonSimpleEventBusAdapter();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusServiceJdo.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusServiceJdo.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusServiceJdo.java
new file mode 100644
index 0000000..53e7811
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusServiceJdo.java
@@ -0,0 +1,38 @@
+package org.apache.isis.core.runtime.services.eventbus;
+
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis;
+import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis.Hint;
+
+
+/**
+ * This domain service that enables both the framework and application code to
+ * publish events through an Axon
+ * {@link org.axonframework.eventhandling.SimpleEventBus} instance.
+ * 
+ * <p>
+ * In addition, this implementation is &quot;JDO-aware&quot; meaning that it
+ * allows events to be {@link #post(Object) posted} from the setters of
+ * entities, automatically ignoring any calls to those setters that occur as a
+ * side-effect of the JDO load/detach lifecycle.
+ * 
+ * <p>
+ * This implementation has no UI.
+ */
+@DomainService(nature=NatureOfService.DOMAIN)
+public class AxonSimpleEventBusServiceJdo extends AxonSimpleEventBusService {
+
+    /**
+     * skip if called in any way by way of the {@link JDOStateManagerForIsis}.
+     * 
+     * <p>
+     * The {@link JDOStateManagerForIsis} sets a
+     * {@link JDOStateManagerForIsis#hint threadlocal} if it has been called.
+     */
+    @Override
+    public boolean skip(final Object event) {
+        return JDOStateManagerForIsis.hint.get() != Hint.NONE;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
new file mode 100644
index 0000000..c8299c2
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
@@ -0,0 +1,62 @@
+package org.apache.isis.core.runtime.services.eventbus;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
+import org.apache.isis.core.commons.exceptions.IsisApplicationException;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+
+public class DefaultSubscriberExceptionHandler {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultSubscriberExceptionHandler.class);
+
+    //region > exception handling
+    
+    public static void processException(Throwable exception,
+            Object event) {
+        if(!(event instanceof AbstractDomainEvent)) {
+            if(LOG.isDebugEnabled()) {
+                LOG.debug("Ignoring exception '%s' (%s), not a subclass of AbstractDomainEvent", exception.getMessage(), exception.getClass().getName());
+            }
+            return;
+        } 
+        final AbstractDomainEvent<?> interactionEvent = (AbstractDomainEvent<?>) event;
+        final AbstractDomainEvent.Phase phase = interactionEvent.getEventPhase();
+        switch (phase) {
+        case HIDE:
+            LOG.warn("Exception thrown during HIDE phase, to be safe will veto (hide) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            interactionEvent.hide();
+            break;
+        case DISABLE:
+            LOG.warn("Exception thrown during DISABLE phase, to be safe will veto (disable) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            interactionEvent.disable(exception.getMessage()!=null?exception.getMessage(): exception.getClass().getName() + " thrown.");
+            break;
+        case VALIDATE:
+            LOG.warn("Exception thrown during VALIDATE phase, to be safe will veto (invalidate) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            interactionEvent.invalidate(exception.getMessage()!=null?exception.getMessage(): exception.getClass().getName() + " thrown.");
+            break;
+        case EXECUTING:
+            LOG.warn("Exception thrown during EXECUTING phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            abortTransaction(exception);
+            break;
+        case EXECUTED:
+            LOG.warn("Exception thrown during EXECUTED phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            abortTransaction(exception);
+            break;
+        }
+    }
+    
+    private static void abortTransaction(Throwable exception) {
+        getTransactionManager().getTransaction().setAbortCause(new IsisApplicationException(exception));
+        return;
+    }
+
+    protected static IsisTransactionManager getTransactionManager() {
+        return IsisContext.getTransactionManager();
+    }
+
+    //endregion
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
new file mode 100644
index 0000000..e573beb
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
@@ -0,0 +1,7 @@
+package org.apache.isis.core.runtime.services.eventbus;
+
+import org.apache.isis.applib.services.eventbus.EventBus;
+
+public abstract class EventBusAdapter implements EventBus {
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
index dc942ad..ac5c23e 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
@@ -16,20 +16,7 @@
  */
 package org.apache.isis.core.runtime.services.eventbus;
 
-import javax.enterprise.context.RequestScoped;
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.SubscriberExceptionContext;
-import com.google.common.eventbus.SubscriberExceptionHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
-import org.apache.isis.applib.services.eventbus.EventBusService;
-import org.apache.isis.core.commons.exceptions.IsisApplicationException;
-import org.apache.isis.core.metamodel.facets.Annotations;
-import org.apache.isis.core.runtime.services.RequestScopedService;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.applib.services.eventbus.EventBus;
 
 /**
  * @deprecated - but only because {@link org.apache.isis.objectstore.jdo.datanucleus.service.eventbus.EventBusServiceJdo}
@@ -37,96 +24,12 @@ import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
  * is still required.
  */
 @Deprecated
-public class EventBusServiceDefault extends EventBusService {
-
-    private static final Logger LOG = LoggerFactory.getLogger(EventBusServiceDefault.class);
-
-    /**
-     * {@inheritDoc}
-     *
-     * This service overrides the method to perform additional validation that (a) request-scoped services register
-     * their proxies, not themselves, and (b) that singleton services are never registered after the event bus has
-     * been created.
-     *
-     * <p>
-     *     Note that we <i>do</i> allow for request-scoped services to register (their proxies) multiple times, ie at
-     *     the beginning of each transaction.  Because the subscribers are stored in a set, these additional
-     *     registrations are in effect ignored.
-     * </p>
-     */
-    @Programmatic
-    @Override
-    public void register(final Object domainService) {
-        if(domainService instanceof RequestScopedService) {
-            // ok; allow to be registered multiple times (each xactn) since stored in a set.
-        } else {
-            if (Annotations.getAnnotation(domainService.getClass(), RequestScoped.class) != null) {
-                throw new IllegalArgumentException("Request-scoped services must register their proxy, not themselves");
-            }
-            // a singleton
-            if(eventBus != null) {
-                // ... coming too late to the party.
-                throw new IllegalStateException("Event bus has already been created; too late to register any further (singleton) subscribers");
-            }
-        }
-        super.register(domainService);
-    }
+public class EventBusServiceDefault extends RuntimeEventBusService {
 
     @Override
     protected EventBus newEventBus() {
-        return new EventBus(newEventBusSubscriberExceptionHandler());
-    }
-
-    protected SubscriberExceptionHandler newEventBusSubscriberExceptionHandler() {
-        return new SubscriberExceptionHandler(){
-            @Override
-            public void handleException(Throwable exception, SubscriberExceptionContext context) {
-                Object event = context.getEvent();
-                if(!(event instanceof AbstractDomainEvent)) {
-                    if(LOG.isDebugEnabled()) {
-                        LOG.debug("Ignoring exception '%s' (%s), not a subclass of AbstractDomainEvent", exception.getMessage(), exception.getClass().getName());
-                    }
-                    return;
-                } 
-                final AbstractDomainEvent<?> interactionEvent = (AbstractDomainEvent<?>) event;
-                final AbstractDomainEvent.Phase phase = interactionEvent.getEventPhase();
-                switch (phase) {
-                case HIDE:
-                    LOG.warn("Exception thrown during HIDE phase, to be safe will veto (hide) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                    interactionEvent.hide();
-                    break;
-                case DISABLE:
-                    LOG.warn("Exception thrown during DISABLE phase, to be safe will veto (disable) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                    interactionEvent.disable(exception.getMessage()!=null?exception.getMessage(): exception.getClass().getName() + " thrown.");
-                    break;
-                case VALIDATE:
-                    LOG.warn("Exception thrown during VALIDATE phase, to be safe will veto (invalidate) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                    interactionEvent.invalidate(exception.getMessage()!=null?exception.getMessage(): exception.getClass().getName() + " thrown.");
-                    break;
-                case EXECUTING:
-                    LOG.warn("Exception thrown during EXECUTING phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                    abortTransaction(exception);
-                    break;
-                case EXECUTED:
-                    LOG.warn("Exception thrown during EXECUTED phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                    abortTransaction(exception);
-                    break;
-                }
-            }
-        };
+        return new GuavaEventBusAdapter();
     }
 
-    private void abortTransaction(Throwable exception) {
-        getTransactionManager().getTransaction().setAbortCause(new IsisApplicationException(exception));
-        return;
-    }
-
-    protected IsisTransactionManager getTransactionManager() {
-        return IsisContext.getTransactionManager();
-    }
-
-    //endregion
-
-
 }
 

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
new file mode 100644
index 0000000..a84e3bc
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
@@ -0,0 +1,37 @@
+package org.apache.isis.core.runtime.services.eventbus;
+
+import com.google.common.eventbus.SubscriberExceptionContext;
+import com.google.common.eventbus.SubscriberExceptionHandler;
+
+public class GuavaEventBusAdapter extends EventBusAdapter {
+
+    private static final com.google.common.eventbus.EventBus eventBus = new com.google.common.eventbus.EventBus(newEventBusSubscriberExceptionHandler());
+
+    protected static SubscriberExceptionHandler newEventBusSubscriberExceptionHandler() {
+        return new SubscriberExceptionHandler(){
+            @Override
+            public void handleException(Throwable exception, SubscriberExceptionContext context) {
+                Object event = context.getEvent();
+                DefaultSubscriberExceptionHandler.processException(exception, event);
+            }
+
+        };
+    }
+
+    @Override
+    public void register(final Object domainService) {
+        // NO-OP. On current implementation subscribers list is the one managed by the EventBusService, and used by EventBusServiceDefault.
+    }
+
+    @Override
+    public void unregister(final Object domainService) {
+        // Intentionally no-op.
+        // this.eventBus.unregister(domainService);
+    }
+
+    @Override
+    public void post(final Object event) {
+        GuavaEventBusAdapter.eventBus.post(event);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/852da24b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
new file mode 100644
index 0000000..887d792
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
@@ -0,0 +1,49 @@
+package org.apache.isis.core.runtime.services.eventbus;
+
+import javax.enterprise.context.RequestScoped;
+
+import org.apache.isis.applib.services.eventbus.EventBusService;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.runtime.services.RequestScopedService;
+
+/**
+ * Holds common runtime logic for EventBusService implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class RuntimeEventBusService extends EventBusService {
+    
+    //region > register
+    /**
+     * {@inheritDoc}
+     *
+     * This service overrides the method to perform additional validation that (a) request-scoped services register
+     * their proxies, not themselves, and (b) that singleton services are never registered after the event bus has
+     * been created.
+     *
+     * <p>
+     *     Note that we <i>do</i> allow for request-scoped services to register (their proxies) multiple times, ie at
+     *     the beginning of each transaction.  Because the subscribers are stored in a set, these additional
+     *     registrations are in effect ignored.
+     * </p>
+     */
+    @Override
+    public void register(final Object domainService) {
+        if(domainService instanceof RequestScopedService) {
+            // ok; allow to be registered multiple times (each xactn) since stored in a set.
+        } else {
+            if (Annotations.getAnnotation(domainService.getClass(), RequestScoped.class) != null) {
+                throw new IllegalArgumentException("Request-scoped services must register their proxy, not themselves");
+            }
+            // a singleton
+            if(this.eventBus != null) {
+                // ... coming too late to the party.
+                throw new IllegalStateException("Event bus has already been created; too late to register any further (singleton) subscribers");
+            }
+        }
+        super.register(domainService);
+    }
+    
+    //endregion
+
+}


[4/9] isis git commit: ISIS-1028: Merge branch 'feature/ISIS-1028' into ISIS-1028

Posted by da...@apache.org.
ISIS-1028: Merge branch 'feature/ISIS-1028' into ISIS-1028

Resolving conflicts:
	core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/43e8693c
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/43e8693c
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/43e8693c

Branch: refs/heads/master
Commit: 43e8693ca4cd27971ec2bc59e3cd7020d804959a
Parents: 737c0a2 15ae2ac
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Mar 24 22:55:43 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Mar 24 22:55:43 2015 +0000

----------------------------------------------------------------------
 .../isis/applib/services/eventbus/EventBus.java | 81 ++++++++++++++++++
 .../services/eventbus/EventBusService.java      | 10 ++-
 core/runtime/pom.xml                            |  7 ++
 .../eventbus/AxonEventListenerAdapter.java      | 41 +++++++++
 .../eventbus/AxonSimpleEventBusAdapter.java     | 69 +++++++++++++++
 .../eventbus/AxonSimpleEventBusService.java     | 31 +++++++
 .../DefaultSubscriberExceptionHandler.java      | 82 ++++++++++++++++++
 .../services/eventbus/EventBusAdapter.java      | 23 +++++
 .../eventbus/EventBusServiceDefault.java        | 88 ++------------------
 .../services/eventbus/GuavaEventBusAdapter.java | 58 +++++++++++++
 .../eventbus/RuntimeEventBusService.java        | 65 +++++++++++++++
 .../eventbus/AxonSimpleEventBusServiceJdo.java  | 51 ++++++++++++
 12 files changed, 521 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/43e8693c/core/runtime/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/isis/blob/43e8693c/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
----------------------------------------------------------------------
diff --cc core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
index 77d6237,a3a19c3..36c21f1
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
@@@ -16,115 -16,21 +16,37 @@@
   */
  package org.apache.isis.core.runtime.services.eventbus;
  
 +import javax.enterprise.context.RequestScoped;
 +import com.google.common.eventbus.EventBus;
 +import com.google.common.eventbus.SubscriberExceptionContext;
 +import com.google.common.eventbus.SubscriberExceptionHandler;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import org.apache.isis.applib.annotation.Programmatic;
+ import org.apache.isis.applib.services.eventbus.EventBus;
 +import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
 +import org.apache.isis.applib.services.eventbus.EventBusService;
 +import org.apache.isis.core.commons.exceptions.IsisApplicationException;
 +import org.apache.isis.core.metamodel.facets.Annotations;
 +import org.apache.isis.core.runtime.services.RequestScopedService;
 +import org.apache.isis.core.runtime.system.context.IsisContext;
 +import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
  
  /**
+  * An Event Bus Service based on Guava.
+  * <p>
   * @deprecated - but only because {@link org.apache.isis.objectstore.jdo.datanucleus.service.eventbus.EventBusServiceJdo}
   * is annotated (with <code>@DomainService</code>) as the default implementation.  The functionality in this implementation
   * is still required.
   */
  @Deprecated
- public class EventBusServiceDefault extends EventBusService {
+ public class EventBusServiceDefault extends RuntimeEventBusService {
  
-     private static final Logger LOG = LoggerFactory.getLogger(EventBusServiceDefault.class);
- 
-     /**
-      * {@inheritDoc}
-      *
-      * This service overrides the method to perform additional validation that (a) request-scoped services register
-      * their proxies, not themselves, and (b) that singleton services are never registered after the event bus has
-      * been created.
-      *
-      * <p>
-      *     Note that we <i>do</i> allow for request-scoped services to register (their proxies) multiple times, ie at
-      *     the beginning of each transaction.  Because the subscribers are stored in a set, these additional
-      *     registrations are in effect ignored.
-      * </p>
-      */
-     @Programmatic
      @Override
-     public void register(final Object domainService) {
-         if(domainService instanceof RequestScopedService) {
-             // ok; allow to be registered multiple times (each xactn) since stored in a set.
-         } else {
-             if (Annotations.getAnnotation(domainService.getClass(), RequestScoped.class) != null) {
-                 throw new IllegalArgumentException("Request-scoped services must register their proxy, not themselves");
-             }
-             // a singleton
-             if(eventBus != null) {
-                 // ... coming too late to the party.
-                 throw new IllegalStateException("Event bus has already been created; too late to register any further (singleton) subscribers");
-             }
-         }
-         super.register(domainService);
-     }
- 
 +    // //////////////////////////////////////
 +
-     @Override
      protected EventBus newEventBus() {
-         return new EventBus(newEventBusSubscriberExceptionHandler());
-     }
- 
-     protected SubscriberExceptionHandler newEventBusSubscriberExceptionHandler() {
-         return new SubscriberExceptionHandler(){
-             @Override
-             public void handleException(Throwable exception, SubscriberExceptionContext context) {
-                 Object event = context.getEvent();
-                 if(!(event instanceof AbstractDomainEvent)) {
-                     if(LOG.isDebugEnabled()) {
-                         LOG.debug("Ignoring exception '%s' (%s), not a subclass of AbstractDomainEvent", exception.getMessage(), exception.getClass().getName());
-                     }
-                     return;
-                 } 
-                 final AbstractDomainEvent<?> interactionEvent = (AbstractDomainEvent<?>) event;
-                 final AbstractDomainEvent.Phase phase = interactionEvent.getEventPhase();
-                 switch (phase) {
-                 case HIDE:
-                     LOG.warn("Exception thrown during HIDE phase, to be safe will veto (hide) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                     interactionEvent.hide();
-                     break;
-                 case DISABLE:
-                     LOG.warn("Exception thrown during DISABLE phase, to be safe will veto (disable) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                     interactionEvent.disable(exception.getMessage()!=null?exception.getMessage(): exception.getClass().getName() + " thrown.");
-                     break;
-                 case VALIDATE:
-                     LOG.warn("Exception thrown during VALIDATE phase, to be safe will veto (invalidate) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                     interactionEvent.invalidate(exception.getMessage()!=null?exception.getMessage(): exception.getClass().getName() + " thrown.");
-                     break;
-                 case EXECUTING:
-                     LOG.warn("Exception thrown during EXECUTING phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                     abortTransaction(exception);
-                     break;
-                 case EXECUTED:
-                     LOG.warn("Exception thrown during EXECUTED phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-                     abortTransaction(exception);
-                     break;
-                 }
-             }
-         };
-     }
- 
-     private void abortTransaction(Throwable exception) {
-         getTransactionManager().getTransaction().setAbortCause(new IsisApplicationException(exception));
-         return;
-     }
- 
-     protected IsisTransactionManager getTransactionManager() {
-         return IsisContext.getTransactionManager();
+         return new GuavaEventBusAdapter();
      }
  
  }


[5/9] isis git commit: ISIS-1028: simplifying some design

Posted by da...@apache.org.
ISIS-1028: simplifying some design


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/a62594b4
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/a62594b4
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/a62594b4

Branch: refs/heads/master
Commit: a62594b47bf85cc54e60261640635390debcf9d4
Parents: 43e8693
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Mar 24 23:28:32 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Mar 24 23:28:32 2015 +0000

----------------------------------------------------------------------
 .../eventbus/AxonEventListenerAdapter.java      | 41 ---------
 .../eventbus/AxonSimpleEventBusAdapter.java     | 69 --------------
 .../eventbus/AxonSimpleEventBusService.java     | 31 -------
 .../services/eventbus/EventBusAdapter.java      | 23 -----
 .../eventbus/EventBusServiceDefault.java        | 95 +++++++++++++++-----
 .../services/eventbus/GuavaEventBusAdapter.java | 58 ------------
 .../eventbus/RuntimeEventBusService.java        | 65 --------------
 .../eventbus/adapter/EventBusAdapter.java       | 23 +++++
 .../adapter/EventBusAdapterForAxonSimple.java   | 95 ++++++++++++++++++++
 .../adapter/EventBusAdapterForGuava.java        | 59 ++++++++++++
 .../jdo/datanucleus/JDOStateManagerForIsis.java |  4 +-
 .../eventbus/AxonSimpleEventBusServiceJdo.java  | 51 -----------
 .../service/eventbus/EventBusServiceJdo.java    |  6 +-
 13 files changed, 256 insertions(+), 364 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
deleted file mode 100644
index e7cedc0..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus;
-
-import org.axonframework.domain.EventMessage;
-import org.axonframework.eventhandling.annotation.AnnotationEventListenerAdapter;
-
-public class AxonEventListenerAdapter extends AnnotationEventListenerAdapter {
-
-    public AxonEventListenerAdapter(Object annotatedEventListener) {
-        super(annotatedEventListener);
-    }
-
-    /**
-     * {@inheritDoc}
-     * <p>
-     * Adds
-     */
-    @Override
-    public void handle(@SuppressWarnings("rawtypes") EventMessage event) {
-        try {
-            super.handle(event);
-        } catch (Exception exception) {
-            DefaultSubscriberExceptionHandler.processException(exception, event);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
deleted file mode 100644
index 68c7044..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus;
-
-import java.util.Map;
-
-import com.google.common.collect.Maps;
-
-import org.axonframework.domain.GenericEventMessage;
-import org.axonframework.eventhandling.SimpleEventBus;
-
-/**
- * A wrapper for an Axon {@link org.axonframework.eventhandling.SimpleEventBus},
- * allowing arbitrary events to be posted and subscribed to.
- */
-public class AxonSimpleEventBusAdapter extends EventBusAdapter {
-
-    private static SimpleEventBus simpleEventBus = new SimpleEventBus();
-
-    private static Map<Object, AxonEventListenerAdapter> adapters = Maps.newConcurrentMap();
-
-    private static AxonEventListenerAdapter adapterFor(final Object domainService) {
-        AxonEventListenerAdapter annotationEventListenerAdapter = adapters.get(domainService);
-        if (annotationEventListenerAdapter == null) {
-            annotationEventListenerAdapter = new AxonEventListenerAdapter(domainService);
-            adapters.put(domainService, annotationEventListenerAdapter);
-        }
-        return annotationEventListenerAdapter;
-    }
-
-    @Override
-    public void register(final Object domainService) {
-        AxonSimpleEventBusAdapter.simpleEventBus.subscribe(AxonSimpleEventBusAdapter.adapterFor(domainService));
-
-    }
-
-    @Override
-    public void unregister(final Object domainService) {
-        // Seems it's needed to be a no-op (See EventBusService).
-        // AxonSimpleEventBusAdapter.simpleEventBus.unsubscribe(AxonSimpleEventBusAdapter.adapterFor(domainService));
-
-    }
-
-    /*
-     * {@inheritDoc} 
-     * <p> 
-     * Logic equivalent to Guava Event Bus. Despite that,
-     * event processing cannot be followed after an Exception is thrown.
-     */
-    @Override
-    public void post(final Object event) {
-        AxonSimpleEventBusAdapter.simpleEventBus.publish(GenericEventMessage.asEventMessage(event));
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
deleted file mode 100644
index 6fb8a2b..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus;
-
-import org.apache.isis.applib.services.eventbus.EventBus;
-
-/**
- * An Event Bus Service based on Axon.
- */
-public class AxonSimpleEventBusService extends RuntimeEventBusService {
-
-    @Override
-    protected EventBus newEventBus() {
-        return new AxonSimpleEventBusAdapter();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
deleted file mode 100644
index 5d45588..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus;
-
-import org.apache.isis.applib.services.eventbus.EventBus;
-
-public abstract class EventBusAdapter implements EventBus {
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
index 36c21f1..88d0342 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
@@ -16,38 +16,91 @@
  */
 package org.apache.isis.core.runtime.services.eventbus;
 
+import java.util.Map;
+import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.SubscriberExceptionContext;
-import com.google.common.eventbus.SubscriberExceptionHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.eventbus.EventBus;
-import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
 import org.apache.isis.applib.services.eventbus.EventBusService;
-import org.apache.isis.core.commons.exceptions.IsisApplicationException;
 import org.apache.isis.core.metamodel.facets.Annotations;
 import org.apache.isis.core.runtime.services.RequestScopedService;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.core.runtime.services.eventbus.adapter.EventBusAdapterForAxonSimple;
+import org.apache.isis.core.runtime.services.eventbus.adapter.EventBusAdapterForGuava;
 
 /**
- * An Event Bus Service based on Guava.
- * <p>
- * @deprecated - but only because {@link org.apache.isis.objectstore.jdo.datanucleus.service.eventbus.EventBusServiceJdo}
- * is annotated (with <code>@DomainService</code>) as the default implementation.  The functionality in this implementation
- * is still required.
+ * Holds common runtime logic for EventBusService implementations.
  */
-@Deprecated
-public class EventBusServiceDefault extends RuntimeEventBusService {
-
+public abstract class EventBusServiceDefault extends EventBusService {
+    
+    //region > register
+    /**
+     * {@inheritDoc}
+     *
+     * This service overrides the method to perform additional validation that (a) request-scoped services register
+     * their proxies, not themselves, and (b) that singleton services are never registered after the event bus has
+     * been created.
+     *
+     * <p>
+     *     Note that we <i>do</i> allow for request-scoped services to register (their proxies) multiple times, ie at
+     *     the beginning of each transaction.  Because the subscribers are stored in a set, these additional
+     *     registrations are in effect ignored.
+     * </p>
+     */
     @Override
-    // //////////////////////////////////////
+    public void register(final Object domainService) {
+        if(domainService instanceof RequestScopedService) {
+            // ok; allow to be registered multiple times (each xactn) since stored in a set.
+        } else {
+            if (Annotations.getAnnotation(domainService.getClass(), RequestScoped.class) != null) {
+                throw new IllegalArgumentException("Request-scoped services must register their proxy, not themselves");
+            }
+            // a singleton
+            if(this.eventBus != null) {
+                // ... coming too late to the party.
+                throw new IllegalStateException("Event bus has already been created; too late to register any further (singleton) subscribers");
+            }
+        }
+        super.register(domainService);
+    }
+    
+    //endregion
+
+    //region > init, shutdown
+    @Programmatic
+    @PostConstruct
+    public void init(final Map<String, String> properties) {
+        final String implementation = properties.get("org.apache.isis.eventbus.implementation");
 
-    protected EventBus newEventBus() {
-        return new GuavaEventBusAdapter();
+        this.implementation =
+                "axon".equalsIgnoreCase(implementation)
+                        ? EventBusImplementation.AXON
+                        : EventBusImplementation.GUAVA;
     }
+    //endregion
 
-}
+    //region > newEventBus
+    enum EventBusImplementation {
+        GUAVA {
+            @Override
+            public EventBus create() {
+                return new EventBusAdapterForGuava();
+            }
+        },
+        AXON {
+            @Override
+            public EventBus create() {
+                return new EventBusAdapterForAxonSimple();
+            }
+        };
+
+        public abstract EventBus create();
+    }
+    private EventBusImplementation implementation;
 
+    @Override
+    protected org.apache.isis.applib.services.eventbus.EventBus newEventBus() {
+        return implementation.create();
+    }
+    //endregion
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
deleted file mode 100644
index 12fbf9e..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus;
-
-import com.google.common.eventbus.SubscriberExceptionContext;
-import com.google.common.eventbus.SubscriberExceptionHandler;
-
-/**
- * A wrapper for a Guava {@link com.google.common.eventbus.EventBus},
- * allowing arbitrary events to be posted and subscribed to.
- */
-public class GuavaEventBusAdapter extends EventBusAdapter {
-
-    private static final com.google.common.eventbus.EventBus eventBus = new com.google.common.eventbus.EventBus(newEventBusSubscriberExceptionHandler());
-
-    protected static SubscriberExceptionHandler newEventBusSubscriberExceptionHandler() {
-        return new SubscriberExceptionHandler() {
-            @Override
-            public void handleException(Throwable exception,
-                    SubscriberExceptionContext context) {
-                Object event = context.getEvent();
-                DefaultSubscriberExceptionHandler.processException(exception, event);
-            }
-
-        };
-    }
-
-    @Override
-    public void register(final Object domainService) {
-        this.eventBus.register(domainService);
-    }
-
-    @Override
-    public void unregister(final Object domainService) {
-        // Intentionally no-op.
-        // this.eventBus.unregister(domainService);
-    }
-
-    @Override
-    public void post(final Object event) {
-        GuavaEventBusAdapter.eventBus.post(event);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
deleted file mode 100644
index fd47781..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus;
-
-import javax.enterprise.context.RequestScoped;
-
-import org.apache.isis.applib.services.eventbus.EventBusService;
-import org.apache.isis.core.metamodel.facets.Annotations;
-import org.apache.isis.core.runtime.services.RequestScopedService;
-
-/**
- * Holds common runtime logic for EventBusService implementations.
- *
- * @version $Rev$ $Date$
- */
-public abstract class RuntimeEventBusService extends EventBusService {
-    
-    //region > register
-    /**
-     * {@inheritDoc}
-     *
-     * This service overrides the method to perform additional validation that (a) request-scoped services register
-     * their proxies, not themselves, and (b) that singleton services are never registered after the event bus has
-     * been created.
-     *
-     * <p>
-     *     Note that we <i>do</i> allow for request-scoped services to register (their proxies) multiple times, ie at
-     *     the beginning of each transaction.  Because the subscribers are stored in a set, these additional
-     *     registrations are in effect ignored.
-     * </p>
-     */
-    @Override
-    public void register(final Object domainService) {
-        if(domainService instanceof RequestScopedService) {
-            // ok; allow to be registered multiple times (each xactn) since stored in a set.
-        } else {
-            if (Annotations.getAnnotation(domainService.getClass(), RequestScoped.class) != null) {
-                throw new IllegalArgumentException("Request-scoped services must register their proxy, not themselves");
-            }
-            // a singleton
-            if(this.eventBus != null) {
-                // ... coming too late to the party.
-                throw new IllegalStateException("Event bus has already been created; too late to register any further (singleton) subscribers");
-            }
-        }
-        super.register(domainService);
-    }
-    
-    //endregion
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapter.java
new file mode 100644
index 0000000..a29e2dd
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapter.java
@@ -0,0 +1,23 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.core.runtime.services.eventbus.adapter;
+
+import org.apache.isis.applib.services.eventbus.EventBus;
+
+public abstract class EventBusAdapter implements EventBus {
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForAxonSimple.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForAxonSimple.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForAxonSimple.java
new file mode 100644
index 0000000..b8403f7
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForAxonSimple.java
@@ -0,0 +1,95 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.core.runtime.services.eventbus.adapter;
+
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+import org.axonframework.domain.EventMessage;
+import org.axonframework.domain.GenericEventMessage;
+import org.axonframework.eventhandling.SimpleEventBus;
+import org.axonframework.eventhandling.annotation.AnnotationEventListenerAdapter;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.core.runtime.services.eventbus.DefaultSubscriberExceptionHandler;
+
+/**
+ * A wrapper for an Axon {@link org.axonframework.eventhandling.SimpleEventBus},
+ * allowing arbitrary events to be posted and subscribed to.
+ */
+public class EventBusAdapterForAxonSimple extends EventBusAdapter {
+
+    private static SimpleEventBus simpleEventBus = new SimpleEventBus();
+
+    private static Map<Object, AxonEventListenerAdapter> adapters = Maps.newConcurrentMap();
+
+    private static AxonEventListenerAdapter adapterFor(final Object domainService) {
+        AxonEventListenerAdapter annotationEventListenerAdapter = adapters.get(domainService);
+        if (annotationEventListenerAdapter == null) {
+            annotationEventListenerAdapter = new AxonEventListenerAdapter(domainService);
+            adapters.put(domainService, annotationEventListenerAdapter);
+        }
+        return annotationEventListenerAdapter;
+    }
+
+    @Override
+    public void register(final Object domainService) {
+        EventBusAdapterForAxonSimple.simpleEventBus.subscribe(EventBusAdapterForAxonSimple.adapterFor(domainService));
+
+    }
+
+    @Override
+    public void unregister(final Object domainService) {
+        // Seems it's needed to be a no-op (See EventBusService).
+        // AxonSimpleEventBusAdapter.simpleEventBus.unsubscribe(AxonSimpleEventBusAdapter.adapterFor(domainService));
+
+    }
+
+    /*
+     * Logic equivalent to Guava Event Bus.
+     *
+     * <p>
+     *     Despite that, event processing cannot be followed after an Exception is thrown.
+     * </p>
+     */
+    @Override
+    @Programmatic
+    public void post(final Object event) {
+        EventBusAdapterForAxonSimple.simpleEventBus.publish(GenericEventMessage.asEventMessage(event));
+    }
+
+
+    static class AxonEventListenerAdapter extends AnnotationEventListenerAdapter {
+
+        public AxonEventListenerAdapter(final Object annotatedEventListener) {
+            super(annotatedEventListener);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void handle(@SuppressWarnings("rawtypes") final EventMessage event) {
+            try {
+                super.handle(event);
+            } catch (final Exception exception) {
+                DefaultSubscriberExceptionHandler.processException(exception, event);
+            }
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForGuava.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForGuava.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForGuava.java
new file mode 100644
index 0000000..f8e97c9
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForGuava.java
@@ -0,0 +1,59 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.core.runtime.services.eventbus.adapter;
+
+import com.google.common.eventbus.SubscriberExceptionContext;
+import com.google.common.eventbus.SubscriberExceptionHandler;
+import org.apache.isis.core.runtime.services.eventbus.DefaultSubscriberExceptionHandler;
+
+/**
+ * A wrapper for a Guava {@link com.google.common.eventbus.EventBus},
+ * allowing arbitrary events to be posted and subscribed to.
+ */
+public class EventBusAdapterForGuava extends EventBusAdapter {
+
+    private static final com.google.common.eventbus.EventBus eventBus = new com.google.common.eventbus.EventBus(newEventBusSubscriberExceptionHandler());
+
+    protected static SubscriberExceptionHandler newEventBusSubscriberExceptionHandler() {
+        return new SubscriberExceptionHandler() {
+            @Override
+            public void handleException(final Throwable exception,
+                    final SubscriberExceptionContext context) {
+                final Object event = context.getEvent();
+                DefaultSubscriberExceptionHandler.processException(exception, event);
+            }
+
+        };
+    }
+
+    @Override
+    public void register(final Object domainService) {
+        eventBus.register(domainService);
+    }
+
+    @Override
+    public void unregister(final Object domainService) {
+        // Intentionally no-op.
+        // this.eventBus.unregister(domainService);
+    }
+
+    @Override
+    public void post(final Object event) {
+        EventBusAdapterForGuava.eventBus.post(event);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/JDOStateManagerForIsis.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/JDOStateManagerForIsis.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/JDOStateManagerForIsis.java
index e1c660a..21e6882 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/JDOStateManagerForIsis.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/JDOStateManagerForIsis.java
@@ -25,7 +25,6 @@ import javax.jdo.spi.StateManager;
 import org.datanucleus.ExecutionContext;
 import org.datanucleus.cache.CachedPC;
 import org.datanucleus.metadata.AbstractClassMetaData;
-import org.datanucleus.state.JDOStateManager;
 import org.datanucleus.state.ObjectProvider;
 import org.datanucleus.state.ReferentialJDOStateManager;
 import org.datanucleus.store.FieldValues;
@@ -33,7 +32,6 @@ import org.datanucleus.store.fieldmanager.FieldManager;
 
 import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
 import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.objectstore.jdo.datanucleus.service.eventbus.EventBusServiceJdo;
 
 public class JDOStateManagerForIsis extends ReferentialJDOStateManager implements StateManager, ObjectProvider {
 
@@ -48,7 +46,7 @@ public class JDOStateManagerForIsis extends ReferentialJDOStateManager implement
     }
 
     /**
-     * Tunnel down the thread stack as a hint to the {@link EventBusServiceJdo}.
+     * Tunnel down the thread stack as a hint to the {@link org.apache.isis.objectstore.jdo.datanucleus.service.eventbus.EventBusServiceJdo}.
      */
     public final static ThreadLocal<Hint> hint = new ThreadLocal<JDOStateManagerForIsis.Hint>() {
         protected Hint initialValue() {

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/AxonSimpleEventBusServiceJdo.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/AxonSimpleEventBusServiceJdo.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/AxonSimpleEventBusServiceJdo.java
deleted file mode 100644
index dbfb744..0000000
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/AxonSimpleEventBusServiceJdo.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.objectstore.jdo.datanucleus.service.eventbus;
-
-import org.apache.isis.core.runtime.services.eventbus.AxonSimpleEventBusService;
-import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis;
-import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis.Hint;
-
-/**
- * This domain service that enables both the framework and application code to
- * publish events through an Axon
- * {@link org.axonframework.eventhandling.SimpleEventBus} instance.
- * 
- * <p>
- * In addition, this implementation is &quot;JDO-aware&quot; meaning that it
- * allows events to be {@link #post(Object) posted} from the setters of
- * entities, automatically ignoring any calls to those setters that occur as a
- * side-effect of the JDO load/detach lifecycle.
- * 
- * <p>
- * This implementation has no UI.
- */
-public class AxonSimpleEventBusServiceJdo extends AxonSimpleEventBusService {
-
-    /**
-     * skip if called in any way by way of the {@link JDOStateManagerForIsis}.
-     * 
-     * <p>
-     * The {@link JDOStateManagerForIsis} sets a
-     * {@link JDOStateManagerForIsis#hint threadlocal} if it has been called.
-     */
-    @Override
-    public boolean skip(final Object event) {
-        return JDOStateManagerForIsis.hint.get() != Hint.NONE;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/a62594b4/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/EventBusServiceJdo.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/EventBusServiceJdo.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/EventBusServiceJdo.java
index 2df75cf..505fceb 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/EventBusServiceJdo.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/EventBusServiceJdo.java
@@ -24,8 +24,10 @@ import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis;
 import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis.Hint;
 
 /**
- * This domain service that enables both the framework and application code to publish events through a Guava
- * {@link com.google.common.eventbus.EventBus} instance.
+ * This domain service that enables both the framework and application code to publish events through either a
+ * Guava {@link com.google.common.eventbus.EventBus} instance or through an Axon
+ * {@link org.axonframework.eventhandling.SimpleEventBus} instance.
+
  *
  * <p>
  * In addition, this implementation is &quot;JDO-aware&quot; meaning that it allows events to be


[2/9] isis git commit: ISIS-1028: Create Event Bus Service based on Axon

Posted by da...@apache.org.
ISIS-1028: Create Event Bus Service based on Axon

Comments added.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/c5b06bbe
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/c5b06bbe
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/c5b06bbe

Branch: refs/heads/master
Commit: c5b06bbe580bf2db895d84eeae0a9acb3d15b26e
Parents: 852da24
Author: Oscar Bou <os...@apache.org>
Authored: Sun Feb 8 20:50:25 2015 +0100
Committer: Oscar Bou <os...@apache.org>
Committed: Sun Feb 8 20:50:25 2015 +0100

----------------------------------------------------------------------
 .../services/eventbus/EventBusService.java      |  2 +-
 .../eventbus/AxonEventListenerAdapter.java      | 16 ++++++
 .../eventbus/AxonSimpleEventBusAdapter.java     | 20 ++++++++
 .../eventbus/AxonSimpleEventBusService.java     | 19 ++++++++
 .../eventbus/AxonSimpleEventBusServiceJdo.java  | 38 ---------------
 .../DefaultSubscriberExceptionHandler.java      | 40 +++++++++++----
 .../services/eventbus/EventBusAdapter.java      | 16 ++++++
 .../eventbus/EventBusServiceDefault.java        |  2 +
 .../services/eventbus/GuavaEventBusAdapter.java | 28 +++++++++--
 .../eventbus/RuntimeEventBusService.java        | 16 ++++++
 .../eventbus/AxonSimpleEventBusServiceJdo.java  | 51 ++++++++++++++++++++
 11 files changed, 196 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
index 77c8a38..db450d3 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
@@ -31,7 +31,7 @@ import org.apache.isis.applib.annotation.Hidden;
 import org.apache.isis.applib.annotation.Programmatic;
 
 /**
- * A wrapper for a Guava {@link EventBus}, allowing arbitrary events to be posted and
+ * A service implementing an Event Bus, allowing arbitrary events to be posted and
  * subscribed to.
  *  
  * <p>

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
index 90c22c2..e7cedc0 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonEventListenerAdapter.java
@@ -1,3 +1,19 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.isis.core.runtime.services.eventbus;
 
 import org.axonframework.domain.EventMessage;

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
index 0b8d904..68c7044 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusAdapter.java
@@ -1,3 +1,19 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.isis.core.runtime.services.eventbus;
 
 import java.util.Map;
@@ -7,6 +23,10 @@ import com.google.common.collect.Maps;
 import org.axonframework.domain.GenericEventMessage;
 import org.axonframework.eventhandling.SimpleEventBus;
 
+/**
+ * A wrapper for an Axon {@link org.axonframework.eventhandling.SimpleEventBus},
+ * allowing arbitrary events to be posted and subscribed to.
+ */
 public class AxonSimpleEventBusAdapter extends EventBusAdapter {
 
     private static SimpleEventBus simpleEventBus = new SimpleEventBus();

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
index af41e4a..6fb8a2b 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusService.java
@@ -1,7 +1,26 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.isis.core.runtime.services.eventbus;
 
 import org.apache.isis.applib.services.eventbus.EventBus;
 
+/**
+ * An Event Bus Service based on Axon.
+ */
 public class AxonSimpleEventBusService extends RuntimeEventBusService {
 
     @Override

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusServiceJdo.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusServiceJdo.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusServiceJdo.java
deleted file mode 100644
index 53e7811..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/AxonSimpleEventBusServiceJdo.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.isis.core.runtime.services.eventbus;
-
-import org.apache.isis.applib.annotation.DomainService;
-import org.apache.isis.applib.annotation.NatureOfService;
-import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis;
-import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis.Hint;
-
-
-/**
- * This domain service that enables both the framework and application code to
- * publish events through an Axon
- * {@link org.axonframework.eventhandling.SimpleEventBus} instance.
- * 
- * <p>
- * In addition, this implementation is &quot;JDO-aware&quot; meaning that it
- * allows events to be {@link #post(Object) posted} from the setters of
- * entities, automatically ignoring any calls to those setters that occur as a
- * side-effect of the JDO load/detach lifecycle.
- * 
- * <p>
- * This implementation has no UI.
- */
-@DomainService(nature=NatureOfService.DOMAIN)
-public class AxonSimpleEventBusServiceJdo extends AxonSimpleEventBusService {
-
-    /**
-     * skip if called in any way by way of the {@link JDOStateManagerForIsis}.
-     * 
-     * <p>
-     * The {@link JDOStateManagerForIsis} sets a
-     * {@link JDOStateManagerForIsis#hint threadlocal} if it has been called.
-     */
-    @Override
-    public boolean skip(final Object event) {
-        return JDOStateManagerForIsis.hint.get() != Hint.NONE;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
index c8299c2..ca4d4f2 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
@@ -1,3 +1,19 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.isis.core.runtime.services.eventbus;
 
 import org.slf4j.Logger;
@@ -8,20 +24,24 @@ import org.apache.isis.core.commons.exceptions.IsisApplicationException;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
 
+/**
+ * Default logic for handling Exceptions thrown while processing Events on an
+ * {@link org.apache.isis.applib.services.eventbus.EventBusService}.
+ */
 public class DefaultSubscriberExceptionHandler {
-    
+
     private static final Logger LOG = LoggerFactory.getLogger(DefaultSubscriberExceptionHandler.class);
 
-    //region > exception handling
-    
+    // region > exception handling
+
     public static void processException(Throwable exception,
             Object event) {
-        if(!(event instanceof AbstractDomainEvent)) {
-            if(LOG.isDebugEnabled()) {
+        if (!(event instanceof AbstractDomainEvent)) {
+            if (LOG.isDebugEnabled()) {
                 LOG.debug("Ignoring exception '%s' (%s), not a subclass of AbstractDomainEvent", exception.getMessage(), exception.getClass().getName());
             }
             return;
-        } 
+        }
         final AbstractDomainEvent<?> interactionEvent = (AbstractDomainEvent<?>) event;
         final AbstractDomainEvent.Phase phase = interactionEvent.getEventPhase();
         switch (phase) {
@@ -31,11 +51,11 @@ public class DefaultSubscriberExceptionHandler {
             break;
         case DISABLE:
             LOG.warn("Exception thrown during DISABLE phase, to be safe will veto (disable) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-            interactionEvent.disable(exception.getMessage()!=null?exception.getMessage(): exception.getClass().getName() + " thrown.");
+            interactionEvent.disable(exception.getMessage() != null ? exception.getMessage() : exception.getClass().getName() + " thrown.");
             break;
         case VALIDATE:
             LOG.warn("Exception thrown during VALIDATE phase, to be safe will veto (invalidate) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-            interactionEvent.invalidate(exception.getMessage()!=null?exception.getMessage(): exception.getClass().getName() + " thrown.");
+            interactionEvent.invalidate(exception.getMessage() != null ? exception.getMessage() : exception.getClass().getName() + " thrown.");
             break;
         case EXECUTING:
             LOG.warn("Exception thrown during EXECUTING phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
@@ -47,7 +67,7 @@ public class DefaultSubscriberExceptionHandler {
             break;
         }
     }
-    
+
     private static void abortTransaction(Throwable exception) {
         getTransactionManager().getTransaction().setAbortCause(new IsisApplicationException(exception));
         return;
@@ -57,6 +77,6 @@ public class DefaultSubscriberExceptionHandler {
         return IsisContext.getTransactionManager();
     }
 
-    //endregion
+    // endregion
 
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
index e573beb..5d45588 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusAdapter.java
@@ -1,3 +1,19 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.isis.core.runtime.services.eventbus;
 
 import org.apache.isis.applib.services.eventbus.EventBus;

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
index ac5c23e..a3a19c3 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
@@ -19,6 +19,8 @@ package org.apache.isis.core.runtime.services.eventbus;
 import org.apache.isis.applib.services.eventbus.EventBus;
 
 /**
+ * An Event Bus Service based on Guava.
+ * <p>
  * @deprecated - but only because {@link org.apache.isis.objectstore.jdo.datanucleus.service.eventbus.EventBusServiceJdo}
  * is annotated (with <code>@DomainService</code>) as the default implementation.  The functionality in this implementation
  * is still required.

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
index a84e3bc..8baf576 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
@@ -1,16 +1,37 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.isis.core.runtime.services.eventbus;
 
 import com.google.common.eventbus.SubscriberExceptionContext;
 import com.google.common.eventbus.SubscriberExceptionHandler;
 
+/**
+ * A wrapper for a Guava {@link com.google.common.eventbus.EventBus},
+ * allowing arbitrary events to be posted and subscribed to.
+ */
 public class GuavaEventBusAdapter extends EventBusAdapter {
 
     private static final com.google.common.eventbus.EventBus eventBus = new com.google.common.eventbus.EventBus(newEventBusSubscriberExceptionHandler());
 
     protected static SubscriberExceptionHandler newEventBusSubscriberExceptionHandler() {
-        return new SubscriberExceptionHandler(){
+        return new SubscriberExceptionHandler() {
             @Override
-            public void handleException(Throwable exception, SubscriberExceptionContext context) {
+            public void handleException(Throwable exception,
+                    SubscriberExceptionContext context) {
                 Object event = context.getEvent();
                 DefaultSubscriberExceptionHandler.processException(exception, event);
             }
@@ -20,7 +41,8 @@ public class GuavaEventBusAdapter extends EventBusAdapter {
 
     @Override
     public void register(final Object domainService) {
-        // NO-OP. On current implementation subscribers list is the one managed by the EventBusService, and used by EventBusServiceDefault.
+        // NO-OP. On current implementation subscribers list is the one managed
+        // by the EventBusService, and used by EventBusServiceDefault.
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
index 887d792..fd47781 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/RuntimeEventBusService.java
@@ -1,3 +1,19 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.isis.core.runtime.services.eventbus;
 
 import javax.enterprise.context.RequestScoped;

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b06bbe/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/AxonSimpleEventBusServiceJdo.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/AxonSimpleEventBusServiceJdo.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/AxonSimpleEventBusServiceJdo.java
new file mode 100644
index 0000000..dbfb744
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/service/eventbus/AxonSimpleEventBusServiceJdo.java
@@ -0,0 +1,51 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.objectstore.jdo.datanucleus.service.eventbus;
+
+import org.apache.isis.core.runtime.services.eventbus.AxonSimpleEventBusService;
+import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis;
+import org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis.Hint;
+
+/**
+ * This domain service that enables both the framework and application code to
+ * publish events through an Axon
+ * {@link org.axonframework.eventhandling.SimpleEventBus} instance.
+ * 
+ * <p>
+ * In addition, this implementation is &quot;JDO-aware&quot; meaning that it
+ * allows events to be {@link #post(Object) posted} from the setters of
+ * entities, automatically ignoring any calls to those setters that occur as a
+ * side-effect of the JDO load/detach lifecycle.
+ * 
+ * <p>
+ * This implementation has no UI.
+ */
+public class AxonSimpleEventBusServiceJdo extends AxonSimpleEventBusService {
+
+    /**
+     * skip if called in any way by way of the {@link JDOStateManagerForIsis}.
+     * 
+     * <p>
+     * The {@link JDOStateManagerForIsis} sets a
+     * {@link JDOStateManagerForIsis#hint threadlocal} if it has been called.
+     */
+    @Override
+    public boolean skip(final Object event) {
+        return JDOStateManagerForIsis.hint.get() != Hint.NONE;
+    }
+
+}
\ No newline at end of file


[9/9] isis git commit: Merge branch 'ISIS-1028'

Posted by da...@apache.org.
Merge branch 'ISIS-1028'


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/efb559e3
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/efb559e3
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/efb559e3

Branch: refs/heads/master
Commit: efb559e347b4e8a7a34b0fe8400995e8e675f29b
Parents: 737c0a2 c5b794d
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Wed Mar 25 01:03:13 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Wed Mar 25 01:03:13 2015 +0000

----------------------------------------------------------------------
 .../eventbus/EventBusImplementation.java        |  33 +++++
 .../services/eventbus/EventBusService.java      |  41 ++++---
 core/runtime/pom.xml                            |   7 ++
 .../EventBusImplementationAbstract.java         |  81 +++++++++++++
 .../eventbus/EventBusServiceDefault.java        | 121 ++++++++-----------
 .../EventBusImplementationForAxonSimple.java    |  92 ++++++++++++++
 .../adapter/EventBusImplementationForGuava.java |  61 ++++++++++
 .../jdo/datanucleus/JDOStateManagerForIsis.java |   4 +-
 .../service/eventbus/EventBusServiceJdo.java    |   6 +-
 core/viewer-restfulobjects-applib/pom.xml       |   7 ++
 10 files changed, 361 insertions(+), 92 deletions(-)
----------------------------------------------------------------------



[6/9] isis git commit: ISIS-1028: rename EventBus to EventBusImplementation; EventBusAdapter to EventBusImplementationAbstract; also...

Posted by da...@apache.org.
ISIS-1028: rename EventBus to EventBusImplementation; EventBusAdapter to EventBusImplementationAbstract; also...

... select the implementation by reading from "isis.services.eventbus.implementation" property (either "guava" or "axon" or a fully-qualified classname)
... improved some javadoc


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/e95494ff
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/e95494ff
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/e95494ff

Branch: refs/heads/master
Commit: e95494ff92d48a24a49aaa2406019ab2fc6d83ed
Parents: a62594b
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Mar 24 23:59:37 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Mar 24 23:59:37 2015 +0000

----------------------------------------------------------------------
 .../isis/applib/services/eventbus/EventBus.java | 81 -----------------
 .../eventbus/EventBusImplementation.java        | 33 +++++++
 .../services/eventbus/EventBusService.java      | 34 ++++---
 .../DefaultSubscriberExceptionHandler.java      | 82 -----------------
 .../EventBusImplementationAbstract.java         | 81 +++++++++++++++++
 .../eventbus/EventBusServiceDefault.java        | 68 ++++++++------
 .../eventbus/adapter/EventBusAdapter.java       | 23 -----
 .../adapter/EventBusAdapterForAxonSimple.java   | 95 --------------------
 .../adapter/EventBusAdapterForGuava.java        | 59 ------------
 .../EventBusImplementationForAxonSimple.java    | 92 +++++++++++++++++++
 .../adapter/EventBusImplementationForGuava.java | 61 +++++++++++++
 11 files changed, 321 insertions(+), 388 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBus.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBus.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBus.java
deleted file mode 100644
index 217d12b..0000000
--- a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBus.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.apache.isis.applib.services.eventbus;
-
-
-/**
- * Common interface for all Event Bus implementations.
- * <p>
- * Currently, there are implementations based on Guava and Axon frameworks.
- * 
- */
-public interface EventBus {
-
-    /**
-     * Both singleton and request-scoped domain services can register on the event bus; this should be done in their
-     * <code>@PostConstruct</code> callback method.
-     *
-     * <p>
-     *     <b>Important:</b> Request-scoped services should register their proxy, not themselves.  This is because it is
-     *     the responsibility of the proxy to ensure that the correct underlying (thread-local) instance of the service
-     *     is delegated to.  If the actual instance were to be registered, this would cause a memory leak and all sorts
-     *     of other unexpected issues.
-     * </p>
-     *
-     * <p>
-     *     Also, request-scoped services should <i>NOT</i> unregister themselves.  This is because the
-     *     <code>@PreDestroy</code> lifecycle method is called at the end of each transaction.  The proxy needs to
-     *     remain registered on behalf for any subsequent transactions.
-     * </p>
-     *
-     * <p>For example:</p>
-     * <pre>
-     *     @RequestScoped @DomainService
-     *     public class SomeSubscribingService {
-     *
-     *         @Inject private EventBusService ebs;
-     *         @Inject private SomeSubscribingService proxy;
-     *
-     *         @PostConstruct
-     *         public void startRequest() {
-     *              // register with bus
-     *              ebs.register(proxy);
-     *         }
-     *         @PreDestroy
-     *         public void endRequest() {
-     *              //no-op
-     *         }
-     *     }
-     * </pre>
-     *
-     * <p>
-     *     The <code>@PostConstruct</code> callback is the correct place to register for both singleton and
-     *     request-scoped services.  For singleton domain services, this is done during the initial bootstrapping of
-     *     the system.  For request-scoped services, this is done for the first transaction.  In fact, because
-     *     singleton domain services are initialized <i>within a current transaction</i>, the request-scoped services
-     *     will actually be registered <i>before</i> the singleton services.  Each subsequent transaction will have the
-     *     request-scoped service re-register with the event bus, however the event bus stores its subscribers in a
-     *     set and so these re-registrations are basically a no-op.
-     * </p>
-     *
-     * @param domainService
-     */
-    void register(Object domainService);
-
-    /**
-     * Notionally allows subscribers to unregister from the event bus; however this is a no-op.
-     *
-     * <p>
-     *     It is safe for singleton services to unregister from the bus, however this is only ever called when the
-     *     app is being shutdown so there is no real effect.  For request-scoped services meanwhile that (as
-     *     explained in {@link #register(Object)}'s documentation) actually register their proxy, it would be an error
-     *     to unregister the proxy; subsequent transactions (for this thread or others) must be routed through that
-     *     proxy.
-     * </p>
-     */
-    void unregister(Object domainService);
-
-    /**
-     * Post an event.
-     */
-    void post(Object event);
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusImplementation.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusImplementation.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusImplementation.java
new file mode 100644
index 0000000..cfaa661
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusImplementation.java
@@ -0,0 +1,33 @@
+package org.apache.isis.applib.services.eventbus;
+
+
+/**
+ * Common interface for all Event Bus implementations.
+ *
+ * <p>
+ *     Defines an SPI to the {@link org.apache.isis.applib.services.eventbus.EventBusService}, to allow alternative
+ *     implementations of in-memory event bus to be used. Currently, there are implementations based on Guava and on
+ *     the Axon framework.
+ * </p>
+ */
+public interface EventBusImplementation {
+
+    /**
+     * For {@link org.apache.isis.applib.services.eventbus.EventBusService} to call on
+     * {@link org.apache.isis.applib.services.eventbus.EventBusService#register(Object)}.
+     */
+    void register(Object domainService);
+
+    /**
+     * For {@link org.apache.isis.applib.services.eventbus.EventBusService} to call on
+     * {@link org.apache.isis.applib.services.eventbus.EventBusService#unregister(Object)}.
+     */
+    void unregister(Object domainService);
+
+    /**
+     * For {@link org.apache.isis.applib.services.eventbus.EventBusService} to call on
+     * {@link org.apache.isis.applib.services.eventbus.EventBusService#post(Object)}.
+     */
+    void post(Object event);
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
index db450d3..4582a8b 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
@@ -24,10 +24,6 @@ import javax.annotation.PreDestroy;
 
 import com.google.common.collect.Sets;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.annotation.Hidden;
 import org.apache.isis.applib.annotation.Programmatic;
 
 /**
@@ -60,11 +56,11 @@ public abstract class EventBusService {
         @Override
         public void post(Object event) {}
         @Override
-        protected EventBus getEventBus() {
+        protected EventBusImplementation getEventBusImplementation() {
             return null;
         }
         @Override
-        protected EventBus newEventBus() { return null; }
+        protected EventBusImplementation newEventBus() { return null; }
     }
 
     public static final EventBusService NOOP = new Noop();
@@ -76,7 +72,7 @@ public abstract class EventBusService {
      * no guarantee of the order in which <code>@PostConstruct</code> is called on any request-scoped services.  We
      * therefore allow all services (singleton or request-scoped) to {@link #register(Object) register} themselves
      * with this service in their <code>@PostConstruct</code> and do the actual instantiation of the guava
-     * {@link com.google.common.eventbus.EventBus} and registering of subscribers lazily, in {@link #getEventBus()}.
+     * {@link com.google.common.eventbus.EventBus} and registering of subscribers lazily, in {@link #getEventBusImplementation()}.
      * This lifecycle method ({@link #init()}) is therefore a no-op.
      *
      * <p>
@@ -203,7 +199,7 @@ public abstract class EventBusService {
         if(skip(event)) {
             return;
         }
-        getEventBus().post(event);
+        getEventBusImplementation().post(event);
     }
 
     //endregion
@@ -212,17 +208,17 @@ public abstract class EventBusService {
     //region > getEventBus
 
     /**
-     * Lazily populated in {@link #getEventBus()}.
+     * Lazily populated in {@link #getEventBusImplementation()}.
      */
-    protected EventBus eventBus;
+    protected EventBusImplementation eventBusImplementation;
 
     /**
      * Lazily populates the event bus for the current {@link #getSubscribers() subscribers}.
      */
     @Programmatic
-    protected EventBus getEventBus() {
+    protected EventBusImplementation getEventBusImplementation() {
         setupEventBus();
-        return eventBus;
+        return eventBusImplementation;
     }
 
     /**
@@ -235,7 +231,7 @@ public abstract class EventBusService {
     private Set<Object> registeredSubscribers;
 
     /**
-     * Populates {@link #eventBus} with the {@link #registeredSubscribers currently registered subscribers}.
+     * Populates {@link #eventBusImplementation} with the {@link #registeredSubscribers currently registered subscribers}.
      *
      * <p>
      *     Guava event bus will throw an exception if attempt to unsubscribe any subscribers that were not subscribed.
@@ -251,26 +247,26 @@ public abstract class EventBusService {
      * </p>
      */
     protected void setupEventBus() {
-        if(eventBus != null) {
+        if(eventBusImplementation != null) {
             return;
         }
-        this.eventBus = newEventBus();
+        this.eventBusImplementation = newEventBus();
 
         registeredSubscribers = getSubscribers();
 
         for (Object subscriber : this.registeredSubscribers) {
-            eventBus.register(subscriber);
+            eventBusImplementation.register(subscriber);
         }
     }
 
     protected void teardownEventBus() {
         if(registeredSubscribers != null) {
             for (Object subscriber : this.registeredSubscribers) {
-                eventBus.unregister(subscriber);
+                eventBusImplementation.unregister(subscriber);
             }
         }
 
-        this.eventBus = null;
+        this.eventBusImplementation = null;
     }
 
     //endregion
@@ -280,7 +276,7 @@ public abstract class EventBusService {
     /**
      * Mandatory hook method for subclass to instantiate an appropriately configured Guava event bus.
      */
-    protected abstract EventBus newEventBus();
+    protected abstract EventBusImplementation newEventBus();
 
 
     /**

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
deleted file mode 100644
index ca4d4f2..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/DefaultSubscriberExceptionHandler.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
-import org.apache.isis.core.commons.exceptions.IsisApplicationException;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-
-/**
- * Default logic for handling Exceptions thrown while processing Events on an
- * {@link org.apache.isis.applib.services.eventbus.EventBusService}.
- */
-public class DefaultSubscriberExceptionHandler {
-
-    private static final Logger LOG = LoggerFactory.getLogger(DefaultSubscriberExceptionHandler.class);
-
-    // region > exception handling
-
-    public static void processException(Throwable exception,
-            Object event) {
-        if (!(event instanceof AbstractDomainEvent)) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Ignoring exception '%s' (%s), not a subclass of AbstractDomainEvent", exception.getMessage(), exception.getClass().getName());
-            }
-            return;
-        }
-        final AbstractDomainEvent<?> interactionEvent = (AbstractDomainEvent<?>) event;
-        final AbstractDomainEvent.Phase phase = interactionEvent.getEventPhase();
-        switch (phase) {
-        case HIDE:
-            LOG.warn("Exception thrown during HIDE phase, to be safe will veto (hide) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-            interactionEvent.hide();
-            break;
-        case DISABLE:
-            LOG.warn("Exception thrown during DISABLE phase, to be safe will veto (disable) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-            interactionEvent.disable(exception.getMessage() != null ? exception.getMessage() : exception.getClass().getName() + " thrown.");
-            break;
-        case VALIDATE:
-            LOG.warn("Exception thrown during VALIDATE phase, to be safe will veto (invalidate) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-            interactionEvent.invalidate(exception.getMessage() != null ? exception.getMessage() : exception.getClass().getName() + " thrown.");
-            break;
-        case EXECUTING:
-            LOG.warn("Exception thrown during EXECUTING phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-            abortTransaction(exception);
-            break;
-        case EXECUTED:
-            LOG.warn("Exception thrown during EXECUTED phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
-            abortTransaction(exception);
-            break;
-        }
-    }
-
-    private static void abortTransaction(Throwable exception) {
-        getTransactionManager().getTransaction().setAbortCause(new IsisApplicationException(exception));
-        return;
-    }
-
-    protected static IsisTransactionManager getTransactionManager() {
-        return IsisContext.getTransactionManager();
-    }
-
-    // endregion
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusImplementationAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusImplementationAbstract.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusImplementationAbstract.java
new file mode 100644
index 0000000..938c51a
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusImplementationAbstract.java
@@ -0,0 +1,81 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.core.runtime.services.eventbus;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
+import org.apache.isis.applib.services.eventbus.EventBusImplementation;
+import org.apache.isis.core.commons.exceptions.IsisApplicationException;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+
+public abstract class EventBusImplementationAbstract implements EventBusImplementation {
+
+    private static final Logger LOG = LoggerFactory.getLogger(EventBusImplementationAbstract.class);
+
+    protected static void processException(
+            final Throwable exception,
+            final Object event) {
+        if (!(event instanceof AbstractDomainEvent)) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Ignoring exception '%s' (%s), not a subclass of AbstractDomainEvent", exception.getMessage(), exception.getClass().getName());
+            }
+            return;
+        }
+
+        final AbstractDomainEvent<?> interactionEvent = (AbstractDomainEvent<?>) event;
+        final AbstractDomainEvent.Phase phase = interactionEvent.getEventPhase();
+        switch (phase) {
+        case HIDE:
+            LOG.warn("Exception thrown during HIDE phase, to be safe will veto (hide) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            interactionEvent.hide();
+            break;
+        case DISABLE:
+            LOG.warn("Exception thrown during DISABLE phase, to be safe will veto (disable) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            interactionEvent.disable(exception.getMessage() != null ? exception.getMessage() : exception.getClass().getName() + " thrown.");
+            break;
+        case VALIDATE:
+            LOG.warn("Exception thrown during VALIDATE phase, to be safe will veto (invalidate) the interaction event, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            interactionEvent.invalidate(exception.getMessage() != null ? exception.getMessage() : exception.getClass().getName() + " thrown.");
+            break;
+        case EXECUTING:
+            LOG.warn("Exception thrown during EXECUTING phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            abortTransaction(exception);
+            break;
+        case EXECUTED:
+            LOG.warn("Exception thrown during EXECUTED phase, to be safe will abort the transaction, msg='{}', class='{}'", exception.getMessage(), exception.getClass().getName());
+            abortTransaction(exception);
+            break;
+        }
+    }
+
+
+    // region > exception handling
+
+    private static void abortTransaction(final Throwable exception) {
+        getTransactionManager().getTransaction().setAbortCause(new IsisApplicationException(exception));
+        return;
+    }
+
+    private static IsisTransactionManager getTransactionManager() {
+        return IsisContext.getTransactionManager();
+    }
+
+    // endregion
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
index 88d0342..33b0097 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/EventBusServiceDefault.java
@@ -19,13 +19,16 @@ package org.apache.isis.core.runtime.services.eventbus;
 import java.util.Map;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
+import com.google.common.base.Strings;
+import org.apache.isis.applib.NonRecoverableException;
 import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.services.eventbus.EventBus;
+import org.apache.isis.applib.services.eventbus.EventBusImplementation;
 import org.apache.isis.applib.services.eventbus.EventBusService;
+import org.apache.isis.core.commons.lang.ClassUtil;
 import org.apache.isis.core.metamodel.facets.Annotations;
 import org.apache.isis.core.runtime.services.RequestScopedService;
-import org.apache.isis.core.runtime.services.eventbus.adapter.EventBusAdapterForAxonSimple;
-import org.apache.isis.core.runtime.services.eventbus.adapter.EventBusAdapterForGuava;
+import org.apache.isis.core.runtime.services.eventbus.adapter.EventBusImplementationForAxonSimple;
+import org.apache.isis.core.runtime.services.eventbus.adapter.EventBusImplementationForGuava;
 
 /**
  * Holds common runtime logic for EventBusService implementations.
@@ -55,7 +58,7 @@ public abstract class EventBusServiceDefault extends EventBusService {
                 throw new IllegalArgumentException("Request-scoped services must register their proxy, not themselves");
             }
             // a singleton
-            if(this.eventBus != null) {
+            if(this.eventBusImplementation != null) {
                 // ... coming too late to the party.
                 throw new IllegalStateException("Event bus has already been created; too late to register any further (singleton) subscribers");
             }
@@ -69,37 +72,44 @@ public abstract class EventBusServiceDefault extends EventBusService {
     @Programmatic
     @PostConstruct
     public void init(final Map<String, String> properties) {
-        final String implementation = properties.get("org.apache.isis.eventbus.implementation");
+        final String implementation = properties.get("isis.services.eventbus.implementation");
 
-        this.implementation =
-                "axon".equalsIgnoreCase(implementation)
-                        ? EventBusImplementation.AXON
-                        : EventBusImplementation.GUAVA;
+        if(Strings.isNullOrEmpty(implementation) || "guava".equalsIgnoreCase(implementation)) {
+            this.implementation = "guava";
+            return;
+        }
+        if("axon".equalsIgnoreCase(implementation)) {
+            this.implementation = "axon";
+        }
+        this.implementation = implementation;
     }
     //endregion
 
-    //region > newEventBus
-    enum EventBusImplementation {
-        GUAVA {
-            @Override
-            public EventBus create() {
-                return new EventBusAdapterForGuava();
-            }
-        },
-        AXON {
-            @Override
-            public EventBus create() {
-                return new EventBusAdapterForAxonSimple();
-            }
-        };
-
-        public abstract EventBus create();
-    }
-    private EventBusImplementation implementation;
+    /**
+     * Either &lt;guava&gt; or &lt;axon&gt;, or else the fully qualified class name of an
+     * implementation of {@link org.apache.isis.applib.services.eventbus.EventBusImplementation}.
+     */
+    private String implementation;
 
     @Override
-    protected org.apache.isis.applib.services.eventbus.EventBus newEventBus() {
-        return implementation.create();
+    protected org.apache.isis.applib.services.eventbus.EventBusImplementation newEventBus() {
+        if("guava".equals(implementation)) {
+            return new EventBusImplementationForGuava();
+        }
+        if("axon".equals(implementation)) {
+            return new EventBusImplementationForAxonSimple();
+        }
+
+        final Class<?> aClass = ClassUtil.forName(implementation);
+        if(EventBusImplementation.class.isAssignableFrom(aClass)) {
+            try {
+                return (EventBusImplementation) aClass.newInstance();
+            } catch (InstantiationException | IllegalAccessException e) {
+                throw new NonRecoverableException(e);
+            }
+        }
+        throw new NonRecoverableException(
+                "Could not instantiate event bus implementation '" + implementation + "'");
     }
     //endregion
 

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapter.java
deleted file mode 100644
index a29e2dd..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapter.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus.adapter;
-
-import org.apache.isis.applib.services.eventbus.EventBus;
-
-public abstract class EventBusAdapter implements EventBus {
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForAxonSimple.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForAxonSimple.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForAxonSimple.java
deleted file mode 100644
index b8403f7..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForAxonSimple.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus.adapter;
-
-import java.util.Map;
-
-import com.google.common.collect.Maps;
-
-import org.axonframework.domain.EventMessage;
-import org.axonframework.domain.GenericEventMessage;
-import org.axonframework.eventhandling.SimpleEventBus;
-import org.axonframework.eventhandling.annotation.AnnotationEventListenerAdapter;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.core.runtime.services.eventbus.DefaultSubscriberExceptionHandler;
-
-/**
- * A wrapper for an Axon {@link org.axonframework.eventhandling.SimpleEventBus},
- * allowing arbitrary events to be posted and subscribed to.
- */
-public class EventBusAdapterForAxonSimple extends EventBusAdapter {
-
-    private static SimpleEventBus simpleEventBus = new SimpleEventBus();
-
-    private static Map<Object, AxonEventListenerAdapter> adapters = Maps.newConcurrentMap();
-
-    private static AxonEventListenerAdapter adapterFor(final Object domainService) {
-        AxonEventListenerAdapter annotationEventListenerAdapter = adapters.get(domainService);
-        if (annotationEventListenerAdapter == null) {
-            annotationEventListenerAdapter = new AxonEventListenerAdapter(domainService);
-            adapters.put(domainService, annotationEventListenerAdapter);
-        }
-        return annotationEventListenerAdapter;
-    }
-
-    @Override
-    public void register(final Object domainService) {
-        EventBusAdapterForAxonSimple.simpleEventBus.subscribe(EventBusAdapterForAxonSimple.adapterFor(domainService));
-
-    }
-
-    @Override
-    public void unregister(final Object domainService) {
-        // Seems it's needed to be a no-op (See EventBusService).
-        // AxonSimpleEventBusAdapter.simpleEventBus.unsubscribe(AxonSimpleEventBusAdapter.adapterFor(domainService));
-
-    }
-
-    /*
-     * Logic equivalent to Guava Event Bus.
-     *
-     * <p>
-     *     Despite that, event processing cannot be followed after an Exception is thrown.
-     * </p>
-     */
-    @Override
-    @Programmatic
-    public void post(final Object event) {
-        EventBusAdapterForAxonSimple.simpleEventBus.publish(GenericEventMessage.asEventMessage(event));
-    }
-
-
-    static class AxonEventListenerAdapter extends AnnotationEventListenerAdapter {
-
-        public AxonEventListenerAdapter(final Object annotatedEventListener) {
-            super(annotatedEventListener);
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public void handle(@SuppressWarnings("rawtypes") final EventMessage event) {
-            try {
-                super.handle(event);
-            } catch (final Exception exception) {
-                DefaultSubscriberExceptionHandler.processException(exception, event);
-            }
-        }
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForGuava.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForGuava.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForGuava.java
deleted file mode 100644
index f8e97c9..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusAdapterForGuava.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.core.runtime.services.eventbus.adapter;
-
-import com.google.common.eventbus.SubscriberExceptionContext;
-import com.google.common.eventbus.SubscriberExceptionHandler;
-import org.apache.isis.core.runtime.services.eventbus.DefaultSubscriberExceptionHandler;
-
-/**
- * A wrapper for a Guava {@link com.google.common.eventbus.EventBus},
- * allowing arbitrary events to be posted and subscribed to.
- */
-public class EventBusAdapterForGuava extends EventBusAdapter {
-
-    private static final com.google.common.eventbus.EventBus eventBus = new com.google.common.eventbus.EventBus(newEventBusSubscriberExceptionHandler());
-
-    protected static SubscriberExceptionHandler newEventBusSubscriberExceptionHandler() {
-        return new SubscriberExceptionHandler() {
-            @Override
-            public void handleException(final Throwable exception,
-                    final SubscriberExceptionContext context) {
-                final Object event = context.getEvent();
-                DefaultSubscriberExceptionHandler.processException(exception, event);
-            }
-
-        };
-    }
-
-    @Override
-    public void register(final Object domainService) {
-        eventBus.register(domainService);
-    }
-
-    @Override
-    public void unregister(final Object domainService) {
-        // Intentionally no-op.
-        // this.eventBus.unregister(domainService);
-    }
-
-    @Override
-    public void post(final Object event) {
-        EventBusAdapterForGuava.eventBus.post(event);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForAxonSimple.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForAxonSimple.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForAxonSimple.java
new file mode 100644
index 0000000..8739c0d
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForAxonSimple.java
@@ -0,0 +1,92 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.core.runtime.services.eventbus.adapter;
+
+import java.util.Map;
+import com.google.common.collect.Maps;
+import org.axonframework.domain.EventMessage;
+import org.axonframework.domain.GenericEventMessage;
+import org.axonframework.eventhandling.SimpleEventBus;
+import org.axonframework.eventhandling.annotation.AnnotationEventListenerAdapter;
+import org.apache.isis.core.runtime.services.eventbus.EventBusImplementationAbstract;
+
+/**
+ * A wrapper for an Axon {@link org.axonframework.eventhandling.SimpleEventBus},
+ * allowing arbitrary events to be posted and subscribed to.
+ */
+public class EventBusImplementationForAxonSimple extends EventBusImplementationAbstract {
+
+    // TODO: does this need to be static?
+    private static SimpleEventBus simpleEventBus = new SimpleEventBus();
+
+    // TODO: does this need to be static?
+    private static Map<Object, AxonEventListenerAdapter> adapters = Maps.newConcurrentMap();
+
+    private static AxonEventListenerAdapter adapterFor(final Object domainService) {
+        AxonEventListenerAdapter annotationEventListenerAdapter = adapters.get(domainService);
+        if (annotationEventListenerAdapter == null) {
+            annotationEventListenerAdapter = new AxonEventListenerAdapter(domainService);
+            adapters.put(domainService, annotationEventListenerAdapter);
+        }
+        return annotationEventListenerAdapter;
+    }
+
+    @Override
+    public void register(final Object domainService) {
+        simpleEventBus.subscribe(EventBusImplementationForAxonSimple.adapterFor(domainService));
+    }
+
+    @Override
+    public void unregister(final Object domainService) {
+        // Seems it's needed to be a no-op (See EventBusService).
+        // AxonSimpleEventBusAdapter.simpleEventBus.unsubscribe(AxonSimpleEventBusAdapter.adapterFor(domainService));
+
+    }
+
+    /*
+     * Logic equivalent to Guava Event Bus.
+     *
+     * <p>
+     *     Despite that, event processing cannot be followed after an Exception is thrown.
+     * </p>
+     */
+    @Override
+    public void post(final Object event) {
+        simpleEventBus.publish(GenericEventMessage.asEventMessage(event));
+    }
+
+
+    static class AxonEventListenerAdapter extends AnnotationEventListenerAdapter {
+
+        public AxonEventListenerAdapter(final Object annotatedEventListener) {
+            super(annotatedEventListener);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void handle(@SuppressWarnings("rawtypes") final EventMessage event) {
+            try {
+                super.handle(event);
+            } catch (final Exception exception) {
+                processException(exception, event);
+            }
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/e95494ff/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForGuava.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForGuava.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForGuava.java
new file mode 100644
index 0000000..6801561
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForGuava.java
@@ -0,0 +1,61 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.core.runtime.services.eventbus.adapter;
+
+import com.google.common.eventbus.SubscriberExceptionContext;
+import com.google.common.eventbus.SubscriberExceptionHandler;
+import org.apache.isis.core.runtime.services.eventbus.EventBusImplementationAbstract;
+
+/**
+ * A wrapper for a Guava {@link com.google.common.eventbus.EventBus},
+ * allowing arbitrary events to be posted and subscribed to.
+ */
+public class EventBusImplementationForGuava extends EventBusImplementationAbstract {
+
+    // TODO: does this need to be static?
+    private static final com.google.common.eventbus.EventBus eventBus = new com.google.common.eventbus.EventBus(newEventBusSubscriberExceptionHandler());
+
+    // TODO: does this need to be static?
+    protected static SubscriberExceptionHandler newEventBusSubscriberExceptionHandler() {
+        return new SubscriberExceptionHandler() {
+            @Override
+            public void handleException(final Throwable exception,
+                    final SubscriberExceptionContext context) {
+                final Object event = context.getEvent();
+                processException(exception, event);
+            }
+
+        };
+    }
+
+    @Override
+    public void register(final Object domainService) {
+        eventBus.register(domainService);
+    }
+
+    @Override
+    public void unregister(final Object domainService) {
+        // Intentionally no-op.
+        // this.eventBus.unregister(domainService);
+    }
+
+    @Override
+    public void post(final Object event) {
+        eventBus.post(event);
+    }
+
+}


[8/9] isis git commit: ISIS-1028: fixing mvn dependency convergence issue; fixing two @PostConstruct in EventBusServiceDefault.

Posted by da...@apache.org.
ISIS-1028: fixing mvn dependency convergence issue; fixing two @PostConstruct in EventBusServiceDefault.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/c5b794d6
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/c5b794d6
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/c5b794d6

Branch: refs/heads/master
Commit: c5b794d65dfc8edd279596de894665d6686a18fd
Parents: d8d882d
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Wed Mar 25 00:59:51 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Wed Mar 25 00:59:51 2015 +0000

----------------------------------------------------------------------
 .../apache/isis/applib/services/eventbus/EventBusService.java | 5 +++--
 core/viewer-restfulobjects-applib/pom.xml                     | 7 +++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/c5b794d6/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
index 4582a8b..a4ac8eb 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusService.java
@@ -17,6 +17,7 @@
 package org.apache.isis.applib.services.eventbus;
 
 import java.util.Collections;
+import java.util.Map;
 import java.util.Set;
 
 import javax.annotation.PostConstruct;
@@ -73,7 +74,7 @@ public abstract class EventBusService {
      * therefore allow all services (singleton or request-scoped) to {@link #register(Object) register} themselves
      * with this service in their <code>@PostConstruct</code> and do the actual instantiation of the guava
      * {@link com.google.common.eventbus.EventBus} and registering of subscribers lazily, in {@link #getEventBusImplementation()}.
-     * This lifecycle method ({@link #init()}) is therefore a no-op.
+     * This lifecycle method ({@link #init(Map)}) is therefore a no-op.
      *
      * <p>
      *     The guava {@link com.google.common.eventbus.EventBus} can however (and is) be torndown in the
@@ -82,7 +83,7 @@ public abstract class EventBusService {
      */
     @Programmatic
     @PostConstruct
-    public void init() {
+    public void init(final Map<String, String> properties) {
         // no-op
     }
 

http://git-wip-us.apache.org/repos/asf/isis/blob/c5b794d6/core/viewer-restfulobjects-applib/pom.xml
----------------------------------------------------------------------
diff --git a/core/viewer-restfulobjects-applib/pom.xml b/core/viewer-restfulobjects-applib/pom.xml
index 2a107f6..d8b60b8 100644
--- a/core/viewer-restfulobjects-applib/pom.xml
+++ b/core/viewer-restfulobjects-applib/pom.xml
@@ -74,6 +74,13 @@
         <dependency>
             <groupId>org.jboss.resteasy</groupId>
             <artifactId>resteasy-jaxrs</artifactId>
+            <exclusions>
+                <!-- clashes with axon -->
+                <exclusion>
+                    <groupId>commons-io</groupId>
+                    <artifactId>commons-io</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>


[3/9] isis git commit: ISIS-1028: Create Event Bus Service based on Axon

Posted by da...@apache.org.
ISIS-1028: Create Event Bus Service based on Axon

Registering Subscribers.

Still estrange behavior on Guava's EventBusServiceJdo. When an exception is thrown during EXECUTING phase, transaction is marked to be aborted, but execution flow continues in my tests ...

Is that behavior correct? Should an Exception be thrown?
Perhaps there's still something missing on current refactoring.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/15ae2ace
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/15ae2ace
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/15ae2ace

Branch: refs/heads/master
Commit: 15ae2ace671383e2f1580ecf2266a07f3427d32e
Parents: c5b06bb
Author: Oscar Bou <os...@apache.org>
Authored: Sun Feb 8 21:39:00 2015 +0100
Committer: Oscar Bou <os...@apache.org>
Committed: Sun Feb 8 21:39:00 2015 +0100

----------------------------------------------------------------------
 .../isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/15ae2ace/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
index 8baf576..12fbf9e 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/eventbus/GuavaEventBusAdapter.java
@@ -41,8 +41,7 @@ public class GuavaEventBusAdapter extends EventBusAdapter {
 
     @Override
     public void register(final Object domainService) {
-        // NO-OP. On current implementation subscribers list is the one managed
-        // by the EventBusService, and used by EventBusServiceDefault.
+        this.eventBus.register(domainService);
     }
 
     @Override


[7/9] isis git commit: Merge branch 'ISIS-1028-merge' into ISIS-1028

Posted by da...@apache.org.
Merge branch 'ISIS-1028-merge' into ISIS-1028


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/d8d882d9
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/d8d882d9
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/d8d882d9

Branch: refs/heads/master
Commit: d8d882d92fd2cadb5f3c104e7c95ea775d5abb48
Parents: 737c0a2 e95494f
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Mar 24 23:59:56 2015 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Mar 24 23:59:56 2015 +0000

----------------------------------------------------------------------
 .../eventbus/EventBusImplementation.java        |  33 +++++
 .../services/eventbus/EventBusService.java      |  36 +++---
 core/runtime/pom.xml                            |   7 ++
 .../EventBusImplementationAbstract.java         |  81 +++++++++++++
 .../eventbus/EventBusServiceDefault.java        | 121 ++++++++-----------
 .../EventBusImplementationForAxonSimple.java    |  92 ++++++++++++++
 .../adapter/EventBusImplementationForGuava.java |  61 ++++++++++
 .../jdo/datanucleus/JDOStateManagerForIsis.java |   4 +-
 .../service/eventbus/EventBusServiceJdo.java    |   6 +-
 9 files changed, 351 insertions(+), 90 deletions(-)
----------------------------------------------------------------------