This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push: new bb42507 ISIS-1949: Also aligning event-bus plugins. bb42507 is described below commit bb42507b53e1faa6d4a72554221cd0e1c60990ef Author: Andi Huber <ahu...@apache.org> AuthorDate: Sat May 19 19:33:22 2018 +0200 ISIS-1949: Also aligning event-bus plugins. Task-Url: https://issues.apache.org/jira/browse/ISIS-1949 --- .../isis/applib/services/eventbus/EventBusService.java | 13 +++++++------ .../isis/core/plugins/eventbus/EventBusPlugin.java} | 12 ++++++------ .../eventbus/EventBusPluginForAxon.java} | 12 ++++++------ ....isis.applib.services.eventbus.EventBusImplementation | 1 - .../org.apache.isis.core.plugins.eventbus.EventBusPlugin | 1 + .../QueryResultsCacheUsingAxonTest.java | 6 +++--- .../eventbus/EventBusPluginForGuava.java} | 8 ++++---- ....isis.applib.services.eventbus.EventBusImplementation | 1 - .../org.apache.isis.core.plugins.eventbus.EventBusPlugin | 1 + .../QueryResultsCacheUsingGuavaTest.java | 6 +++--- .../eventbus/EventBusImplementationAbstract.java | 4 ++-- .../services/eventbus/EventBusServiceDefault.java | 16 ++++++++-------- 12 files changed, 41 insertions(+), 40 deletions(-) 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 b1ebe6d..a0eeade 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 @@ -26,8 +26,9 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.apache.isis.applib.annotation.Programmatic; -import org.apache.isis.applib.services.eventbus.EventBusImplementation.EventListener; import org.apache.isis.commons.internal.collections._Sets; +import org.apache.isis.core.plugins.eventbus.EventBusPlugin; +import org.apache.isis.core.plugins.eventbus.EventBusPlugin.EventListener; /** * A service implementing an Event Bus, allowing arbitrary events to be posted and @@ -59,11 +60,11 @@ public abstract class EventBusService { @Override public void post(Object event) {} @Override - public EventBusImplementation getEventBusImplementation() { + public EventBusPlugin getEventBusImplementation() { return null; } @Override - protected EventBusImplementation newEventBus() { return null; } + protected EventBusPlugin newEventBus() { return null; } } public static final EventBusService NOOP = new Noop(); @@ -223,7 +224,7 @@ public abstract class EventBusService { /** * Lazily populated in {@link #getEventBusImplementation()} as result of the first {@link #post(Object)}. */ - protected EventBusImplementation eventBusImplementation; + protected EventBusPlugin eventBusImplementation; public <T> EventListener<T> addEventListener(final Class<T> targetType, Consumer<T> onEvent) { return Optional.ofNullable(getEventBusImplementation()) @@ -242,7 +243,7 @@ public abstract class EventBusService { * Lazily populates the event bus for the current {@link #getSubscribers() subscribers}. */ @Programmatic - protected EventBusImplementation getEventBusImplementation() { + protected EventBusPlugin getEventBusImplementation() { setupEventBus(); return eventBusImplementation; } @@ -302,7 +303,7 @@ public abstract class EventBusService { /** * Mandatory hook method for subclass to instantiate an appropriately configured Guava event bus. */ - protected abstract EventBusImplementation newEventBus(); + protected abstract EventBusPlugin newEventBus(); /** diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusImplementation.java b/core/commons/src/main/java/org/apache/isis/core/plugins/eventbus/EventBusPlugin.java similarity index 87% rename from core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusImplementation.java rename to core/commons/src/main/java/org/apache/isis/core/plugins/eventbus/EventBusPlugin.java index 625355e..615da10 100644 --- a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/EventBusImplementation.java +++ b/core/commons/src/main/java/org/apache/isis/core/plugins/eventbus/EventBusPlugin.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.isis.applib.services.eventbus; +package org.apache.isis.core.plugins.eventbus; import java.util.function.Consumer; @@ -30,7 +30,7 @@ import org.apache.isis.commons.internal.context._Plugin; * </p> * */ -public interface EventBusImplementation { +public interface EventBusPlugin { /** * For {@link org.apache.isis.applib.services.eventbus.EventBusService} to call on @@ -74,13 +74,13 @@ public interface EventBusImplementation { // -- PLUGIN LOOKUP - public static EventBusImplementation get() { - return _Plugin.getOrElse(EventBusImplementation.class, + public static EventBusPlugin get() { + return _Plugin.getOrElse(EventBusPlugin.class, ambiguousPlugins->{ - throw _Plugin.ambiguityNonRecoverable(EventBusImplementation.class, ambiguousPlugins); + throw _Plugin.ambiguityNonRecoverable(EventBusPlugin.class, ambiguousPlugins); }, ()->{ - throw _Plugin.absenceNonRecoverable(EventBusImplementation.class); + throw _Plugin.absenceNonRecoverable(EventBusPlugin.class); }); } diff --git a/core/plugins/eventbus-axon/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForAxonSimple.java b/core/plugins/eventbus-axon/src/main/java/org/apache/isis/core/plugins/eventbus/EventBusPluginForAxon.java similarity index 92% rename from core/plugins/eventbus-axon/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForAxonSimple.java rename to core/plugins/eventbus-axon/src/main/java/org/apache/isis/core/plugins/eventbus/EventBusPluginForAxon.java index 4a96a07..9958a75 100644 --- a/core/plugins/eventbus-axon/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForAxonSimple.java +++ b/core/plugins/eventbus-axon/src/main/java/org/apache/isis/core/plugins/eventbus/EventBusPluginForAxon.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.isis.core.runtime.services.eventbus.adapter; +package org.apache.isis.core.plugins.eventbus; import java.util.Map; import java.util.Objects; @@ -22,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import org.apache.isis.applib.events.domain.AbstractDomainEvent; -import org.apache.isis.applib.services.eventbus.EventBusImplementation; +import org.apache.isis.core.plugins.eventbus.EventBusPlugin; import org.apache.isis.core.runtime.services.eventbus.EventBusImplementationAbstract; import org.axonframework.domain.EventMessage; import org.axonframework.domain.GenericEventMessage; @@ -34,7 +34,7 @@ import org.axonframework.eventhandling.annotation.AnnotationEventListenerAdapter * A wrapper for an Axon {@link org.axonframework.eventhandling.SimpleEventBus}, * allowing arbitrary events to be posted and subscribed to. */ -public class EventBusImplementationForAxonSimple extends EventBusImplementationAbstract { +public class EventBusPluginForAxon extends EventBusImplementationAbstract { private SimpleEventBus simpleEventBus = new SimpleEventBus(); @@ -64,7 +64,7 @@ public class EventBusImplementationForAxonSimple extends EventBusImplementationA } @Override - public <T> EventBusImplementation.EventListener<T> addEventListener( + public <T> EventBusPlugin.EventListener<T> addEventListener( final Class<T> targetType, final Consumer<T> onEvent) { @@ -74,7 +74,7 @@ public class EventBusImplementationForAxonSimple extends EventBusImplementationA } @Override - public <T> void removeEventListener(EventBusImplementation.EventListener<T> eventListener) { + public <T> void removeEventListener(EventBusPlugin.EventListener<T> eventListener) { if(eventListener instanceof AxonEventListener) { simpleEventBus.unsubscribe(((AxonEventListener<T>)eventListener).proxy()); } @@ -102,7 +102,7 @@ public class EventBusImplementationForAxonSimple extends EventBusImplementationA * @param <T> * @since 2.0.0 */ - static class AxonEventListener<T> implements EventBusImplementation.EventListener<T> { + static class AxonEventListener<T> implements EventBusPlugin.EventListener<T> { private final Consumer<T> eventConsumer; private final EventListenerProxy proxy; private AxonEventListener(final Class<T> targetType, final Consumer<T> eventConsumer) { diff --git a/core/plugins/eventbus-axon/src/main/resources/META-INF/services/org.apache.isis.applib.services.eventbus.EventBusImplementation b/core/plugins/eventbus-axon/src/main/resources/META-INF/services/org.apache.isis.applib.services.eventbus.EventBusImplementation deleted file mode 100644 index 4a07d72..0000000 --- a/core/plugins/eventbus-axon/src/main/resources/META-INF/services/org.apache.isis.applib.services.eventbus.EventBusImplementation +++ /dev/null @@ -1 +0,0 @@ -org.apache.isis.core.runtime.services.eventbus.adapter.EventBusImplementationForAxonSimple \ No newline at end of file diff --git a/core/plugins/eventbus-axon/src/main/resources/META-INF/services/org.apache.isis.core.plugins.eventbus.EventBusPlugin b/core/plugins/eventbus-axon/src/main/resources/META-INF/services/org.apache.isis.core.plugins.eventbus.EventBusPlugin new file mode 100644 index 0000000..5de2937 --- /dev/null +++ b/core/plugins/eventbus-axon/src/main/resources/META-INF/services/org.apache.isis.core.plugins.eventbus.EventBusPlugin @@ -0,0 +1 @@ +org.apache.isis.core.plugins.eventbus.EventBusPluginForAxon \ No newline at end of file diff --git a/core/plugins/eventbus-axon/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxonTest.java b/core/plugins/eventbus-axon/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxonTest.java index fb40738..00ba9c4 100644 --- a/core/plugins/eventbus-axon/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxonTest.java +++ b/core/plugins/eventbus-axon/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxonTest.java @@ -23,8 +23,8 @@ import java.util.concurrent.Callable; import org.apache.isis.applib.fixturescripts.events.FixturesInstallingEvent; import org.apache.isis.applib.services.fixturespec.FixtureScriptsDefault; +import org.apache.isis.core.plugins.eventbus.EventBusPluginForAxon; import org.apache.isis.core.runtime.services.eventbus.EventBusServiceDefault; -import org.apache.isis.core.runtime.services.eventbus.adapter.EventBusImplementationForAxonSimple; import org.junit.Before; import org.junit.Test; @@ -32,7 +32,7 @@ public class QueryResultsCacheUsingAxonTest { private QueryResultsCacheInternal queryResultsCache; private QueryResultsCacheControlInternal control; - private EventBusImplementationForAxonSimple eventBusImplementationAxon; + private EventBusPluginForAxon eventBusImplementationAxon; @Before public void setUp() throws Exception { @@ -43,7 +43,7 @@ public class QueryResultsCacheUsingAxonTest { { allowLateRegistration = true; eventBusImplementation = eventBusImplementationAxon - = new EventBusImplementationForAxonSimple(); + = new EventBusPluginForAxon(); } }; } diff --git a/core/plugins/eventbus-guava/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForGuava.java b/core/plugins/eventbus-guava/src/main/java/org/apache/isis/core/plugins/eventbus/EventBusPluginForGuava.java similarity index 93% rename from core/plugins/eventbus-guava/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForGuava.java rename to core/plugins/eventbus-guava/src/main/java/org/apache/isis/core/plugins/eventbus/EventBusPluginForGuava.java index 535ccc7..fb58bfb 100644 --- a/core/plugins/eventbus-guava/src/main/java/org/apache/isis/core/runtime/services/eventbus/adapter/EventBusImplementationForGuava.java +++ b/core/plugins/eventbus-guava/src/main/java/org/apache/isis/core/plugins/eventbus/EventBusPluginForGuava.java @@ -14,13 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.isis.core.runtime.services.eventbus.adapter; +package org.apache.isis.core.plugins.eventbus; import java.util.Objects; import java.util.function.Consumer; import org.apache.isis.applib.events.domain.AbstractDomainEvent; -import org.apache.isis.applib.services.eventbus.EventBusImplementation; +import org.apache.isis.core.plugins.eventbus.EventBusPlugin; import org.apache.isis.core.runtime.services.eventbus.EventBusImplementationAbstract; import com.google.common.eventbus.SubscriberExceptionContext; @@ -30,7 +30,7 @@ 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 EventBusImplementationForGuava extends EventBusImplementationAbstract { +public class EventBusPluginForGuava extends EventBusImplementationAbstract { private final com.google.common.eventbus.EventBus eventBus = new com.google.common.eventbus.EventBus(newEventBusSubscriberExceptionHandler()); @@ -84,7 +84,7 @@ public class EventBusImplementationForGuava extends EventBusImplementationAbstra // -- HELPER - private static class GuavaEventListener<T> implements EventBusImplementation.EventListener<T> { + private static class GuavaEventListener<T> implements EventBusPlugin.EventListener<T> { private final Class<T> targetType; private final Consumer<T> eventConsumer; private GuavaEventListener(final Class<T> targetType, final Consumer<T> eventConsumer) { diff --git a/core/plugins/eventbus-guava/src/main/resources/META-INF/services/org.apache.isis.applib.services.eventbus.EventBusImplementation b/core/plugins/eventbus-guava/src/main/resources/META-INF/services/org.apache.isis.applib.services.eventbus.EventBusImplementation deleted file mode 100644 index 1aaefda..0000000 --- a/core/plugins/eventbus-guava/src/main/resources/META-INF/services/org.apache.isis.applib.services.eventbus.EventBusImplementation +++ /dev/null @@ -1 +0,0 @@ -org.apache.isis.core.runtime.services.eventbus.adapter.EventBusImplementationForGuava \ No newline at end of file diff --git a/core/plugins/eventbus-guava/src/main/resources/META-INF/services/org.apache.isis.core.plugins.eventbus.EventBusPlugin b/core/plugins/eventbus-guava/src/main/resources/META-INF/services/org.apache.isis.core.plugins.eventbus.EventBusPlugin new file mode 100644 index 0000000..5e78afa --- /dev/null +++ b/core/plugins/eventbus-guava/src/main/resources/META-INF/services/org.apache.isis.core.plugins.eventbus.EventBusPlugin @@ -0,0 +1 @@ +org.apache.isis.core.plugins.eventbus.EventBusPluginForGuava \ No newline at end of file diff --git a/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuavaTest.java b/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuavaTest.java index 9a44cf7..084477b 100644 --- a/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuavaTest.java +++ b/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuavaTest.java @@ -23,8 +23,8 @@ import java.util.concurrent.Callable; import org.apache.isis.applib.fixturescripts.events.FixturesInstallingEvent; import org.apache.isis.applib.services.fixturespec.FixtureScriptsDefault; +import org.apache.isis.core.plugins.eventbus.EventBusPluginForGuava; import org.apache.isis.core.runtime.services.eventbus.EventBusServiceDefault; -import org.apache.isis.core.runtime.services.eventbus.adapter.EventBusImplementationForGuava; import org.junit.Before; import org.junit.Test; @@ -32,7 +32,7 @@ public class QueryResultsCacheUsingGuavaTest { private QueryResultsCacheInternal queryResultsCache; private QueryResultsCacheControlInternal control; - private EventBusImplementationForGuava eventBusImplementationGuava; + private EventBusPluginForGuava eventBusImplementationGuava; @Before public void setUp() throws Exception { @@ -43,7 +43,7 @@ public class QueryResultsCacheUsingGuavaTest { { allowLateRegistration = true; eventBusImplementation = eventBusImplementationGuava - = new EventBusImplementationForGuava(); + = new EventBusPluginForGuava(); } }; } 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 index f36b9dc..0efa3f9 100644 --- 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 @@ -19,12 +19,12 @@ package org.apache.isis.core.runtime.services.eventbus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.isis.applib.events.domain.AbstractDomainEvent; -import org.apache.isis.applib.services.eventbus.EventBusImplementation; import org.apache.isis.core.commons.exceptions.IsisApplicationException; +import org.apache.isis.core.plugins.eventbus.EventBusPlugin; import org.apache.isis.core.runtime.system.session.IsisSessionFactory; import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager; -public abstract class EventBusImplementationAbstract implements EventBusImplementation { +public abstract class EventBusImplementationAbstract implements EventBusPlugin { private static final Logger LOG = LoggerFactory.getLogger(EventBusImplementationAbstract.class); 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 7509418..07de6b9 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 @@ -23,11 +23,11 @@ import javax.enterprise.context.RequestScoped; import org.apache.isis.applib.NonRecoverableException; import org.apache.isis.applib.annotation.Programmatic; -import org.apache.isis.applib.services.eventbus.EventBusImplementation; import org.apache.isis.applib.services.eventbus.EventBusService; import org.apache.isis.applib.services.registry.ServiceRegistry; import org.apache.isis.core.commons.lang.ClassUtil; import org.apache.isis.core.metamodel.facets.Annotations; +import org.apache.isis.core.plugins.eventbus.EventBusPlugin; import org.apache.isis.core.runtime.services.RequestScopedService; import com.google.common.base.Strings; @@ -114,7 +114,7 @@ public abstract class EventBusServiceDefault extends EventBusService { /** * Either <guava> or <axon>, or else the fully qualified class name of an - * implementation of {@link org.apache.isis.applib.services.eventbus.EventBusImplementation}. + * implementation of {@link org.apache.isis.core.plugins.eventbus.EventBusPlugin}. */ private String implementation; String getImplementation() { @@ -122,19 +122,19 @@ public abstract class EventBusServiceDefault extends EventBusService { } @Override - protected org.apache.isis.applib.services.eventbus.EventBusImplementation newEventBus() { - final EventBusImplementation implementation = instantiateEventBus(); + protected org.apache.isis.core.plugins.eventbus.EventBusPlugin newEventBus() { + final EventBusPlugin implementation = instantiateEventBus(); serviceRegistry.injectServicesInto(implementation); return implementation; } - private EventBusImplementation instantiateEventBus() { + private EventBusPlugin instantiateEventBus() { String fqImplementationName = implementation; if( "plugin".equals(implementation) || "auto".equals(implementation) ) { - return EventBusImplementation.get(); + return EventBusPlugin.get(); } else if("guava".equals(implementation)) { // legacy of return new EventBusImplementationForGuava(); @@ -145,9 +145,9 @@ public abstract class EventBusServiceDefault extends EventBusService { } final Class<?> aClass = ClassUtil.forName(fqImplementationName); - if(EventBusImplementation.class.isAssignableFrom(aClass)) { + if(EventBusPlugin.class.isAssignableFrom(aClass)) { try { - return (EventBusImplementation) aClass.newInstance(); + return (EventBusPlugin) aClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new NonRecoverableException(e); } -- To stop receiving notification emails like this one, please contact ahu...@apache.org.