fixed issue #5, added gradle build config

This commit is contained in:
benni 2012-11-30 00:18:28 +01:00
parent 89f44544bd
commit a47b632880
3 changed files with 32 additions and 23 deletions

10
build.gradle Normal file
View File

@ -0,0 +1,10 @@
usePlugin('java')
group="org.mbassy"
version="1.0.2.RC"
dependencies {
addMavenRepo()
testCompile "junit:junit:4.10@jar"
}

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.mbassy</groupId>
<artifactId>mbassador</artifactId>
<version>1.0.1.RC</version>
<version>1.0.2.RC</version>
<packaging>jar</packaging>
<name>mbassador</name>
<description>Mbassador is a fast and flexible message bus system that follows the publish subscribe pattern

View File

@ -52,6 +52,27 @@ public abstract class AbstractMessageBus<T, P extends IMessageBus.IPostCommand>
// 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<Runnable>()));
}
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<T, P extends IMessageBus.IPostCommand>
}
}
public AbstractMessageBus() {
this(2);
}
public AbstractMessageBus(int dispatcherThreadCount) {
this(2, new ThreadPoolExecutor(5, 50, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>()));
}
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<IPublicationErrorHandler> getRegisteredErrorHandlers() {
return Collections.unmodifiableCollection(errorHandlers);