From a47b63288097d5c34a6819769acebe1cff15587b Mon Sep 17 00:00:00 2001 From: benni Date: Fri, 30 Nov 2012 00:18:28 +0100 Subject: [PATCH] fixed issue #5, added gradle build config --- build.gradle | 10 +++++ pom.xml | 2 +- .../java/org/mbassy/AbstractMessageBus.java | 43 +++++++++---------- 3 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 build.gradle diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..71256c3 --- /dev/null +++ b/build.gradle @@ -0,0 +1,10 @@ +usePlugin('java') + +group="org.mbassy" +version="1.0.2.RC" + +dependencies { + addMavenRepo() + + testCompile "junit:junit:4.10@jar" +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 90464ef..5595a95 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.mbassy mbassador - 1.0.1.RC + 1.0.2.RC jar mbassador Mbassador is a fast and flexible message bus system that follows the publish subscribe pattern diff --git a/src/main/java/org/mbassy/AbstractMessageBus.java b/src/main/java/org/mbassy/AbstractMessageBus.java index 40de146..00f7207 100644 --- a/src/main/java/org/mbassy/AbstractMessageBus.java +++ b/src/main/java/org/mbassy/AbstractMessageBus.java @@ -52,6 +52,27 @@ public abstract class AbstractMessageBus // it can be customized by implementing the getSubscriptionFactory() method private final SubscriptionFactory subscriptionFactory; + + + + public AbstractMessageBus() { + this(2); + } + + public AbstractMessageBus(int dispatcherThreadCount) { + this(dispatcherThreadCount, new ThreadPoolExecutor(5, 50, 1, TimeUnit.MINUTES, new LinkedBlockingQueue())); + } + + public AbstractMessageBus(int dispatcherThreadCount, ExecutorService executor) { + this.executor = executor; + initDispatcherThreads(dispatcherThreadCount > 0 ? dispatcherThreadCount : 2); + addErrorHandler(new IPublicationErrorHandler.ConsoleLogger()); + subscriptionFactory = getSubscriptionFactory(); + } + + // use this method to introduce a custom subscription factory for extension + protected abstract SubscriptionFactory getSubscriptionFactory(); + // initialize the dispatch workers private void initDispatcherThreads(int numberOfThreads) { for (int i = 0; i < numberOfThreads; i++) { @@ -74,28 +95,6 @@ public abstract class AbstractMessageBus } } - - public AbstractMessageBus() { - this(2); - } - - public AbstractMessageBus(int dispatcherThreadCount) { - this(2, new ThreadPoolExecutor(5, 50, 1, TimeUnit.MINUTES, new LinkedBlockingQueue())); - } - - public AbstractMessageBus(int dispatcherThreadCount, ExecutorService executor) { - this.executor = executor; - initDispatcherThreads(dispatcherThreadCount > 0 ? dispatcherThreadCount : 2); - addErrorHandler(new IPublicationErrorHandler.ConsoleLogger()); - subscriptionFactory = getSubscriptionFactory(); - initialize(); - } - - protected abstract SubscriptionFactory getSubscriptionFactory(); - - protected void initialize() { - } - @Override public Collection getRegisteredErrorHandlers() { return Collections.unmodifiableCollection(errorHandlers);