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:15 UTC
[4/9] isis git commit: ISIS-1028: Merge branch 'feature/ISIS-1028'
into ISIS-1028
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();
}
}