diff --git a/README.md b/README.md
index 4ca5ea1..73f3b31 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ data structure to allow high throughput for concurrent access.
Read this documentation to get an overview of its features. You can also check out the performance comparison
which also contains a partial list of the features of the compared implementations.
-The current version is 1.1.3 and it is available from the Maven Central Repository. See the release notes for more details.
+The current version is 1.1.4 and it is available from the Maven Central Repository. See the release notes for more details.
Table of contents:
+ [Features](#features)
@@ -33,10 +33,11 @@ This means that listeners will also receivesubtypes of the message type they are
+ Synchronous and asynchronous message delivery: A handler can be invoked to handle a message either synchronously or
asynchronously. This is configurable for each handler via annotations. Message publication itself supports synchronous (method
blocks until messages are delivered to all handlers) or asynchronous (fire and forget) dispatch
-+ Weak references: MBassador uses weak references to all listening objects to relieve the programmer of the burden to explicitly unregister
++ Weak references: By default, MBassador uses weak references to all listening objects to relieve the programmer of the burden to explicitly unregister
listeners that are not used anymore (of course it is also possible to explicitly unregister a listener if needed). This is very comfortable
in certain environments where listeners are managed by frameworks, i.e. spring, guice etc. Just stuff everything into the message bus, it will
ignore objects without message handlers and automatically clean-up orphaned weak references after the garbage collector has done its job.
++ Strong references: Instead of using weak references, the bus can be configured to use strong references.
+ Filtering: MBassador offers static message filtering. Filters are configured using annotations and multiple filters can be attached to
a single message handler
+ Message envelopes: Message handlers can declare to receive an enveloped message. The envelope can wrap different
@@ -58,7 +59,7 @@ sending messages to your listeners using one of MBassador's publication methods
Usage
-Listener definition (in any bean):
+Handler definition (in any bean):
// every message of type TestMessage or any subtype will be delivered
// to this handler
@@ -67,8 +68,15 @@ Listener definition (in any bean):
// do something
}
- // this handler will be invoked concurrently
- @Handler(delivery = Mode.Concurrent)
+ // every message of type TestMessage or any subtype will be delivered
+ // to this handler
+ @Handler
+ public void handleTestMessageStrong(TestMessage message) {
+ // do something
+ }
+
+ // this handler will be invoked asynchronously (in a different thread)
+ @Handler(delivery = Invoke.Asynchronously)
public void handleSubTestMessage(SubTestMessage message) {
// do something more expensive here
}
@@ -90,6 +98,15 @@ Listener definition (in any bean):
}
+ // configure a listener to be stored using strong instead of weak references
+ @Listener(references = References.Strong)
+ public class MessageListener{
+
+ // any handler definitions
+
+ }
+
+
Creation of message bus and registration of listeners:
// create as many instances as necessary
@@ -113,22 +130,8 @@ Message publication:
bus.post(subMessage).now(); // same as above
Installation
-Beginning with version 1.1.0 MBassador is available from the Maven Central Repository (Hooray!). Older versions are
-still available from the included maven repository in this github repo but will be deleted in the future.
-The recommended way of using MBassador in your project is to add the dependency as shown in step two. Step one is only necessary
-if you want to use an older version that is not available in the central repository.
+Beginning with version 1.1.0 MBassador is available from the Maven Central Repository using the following coordinates:
- 1. Add the repository location to your pom.xml
-
- 2. Add the MBassador dependency to your pom.xml. You can check which versions are available by browsing
- the git repository online.
<dependency>
<groupId>net.engio</groupId>
@@ -136,7 +139,6 @@ if you want to use an older version that is not available in the central reposit
<version>1.1.0</version>
</dependency>
- 3. Run mvn clean package to have maven download and install the required version into your local repository
Of course you can always clone the repository and build from source.
@@ -147,6 +149,18 @@ to avoid confusion and misunderstanding.
Release Notes
+
1.1.4
+
+ + Added support for choosing between strong and weak references using the new @Listener annotation. @Listener can be
+ added to any class that defines message handlers and allows to configure which reference type is used
+ + Custom handler invocations: It is possible to provide a custom handler invocation for each message handler, see "invocation"
+ property of @Handler
+ + Changed packaging to "bundle" to support OSGI environments
+ + Synchronization of message handlers via @Synchronized: Handlers that are not thread-safe can be synchronized to guarantee
+ that only one thread at a time can invoke that handler
+ + Created a message bus implementation that does not use threading to support use in non-multi-threaded environments like GWT,
+ see ISyncMessageBus
+
1.1.3
+ Added support for FilteredMessage event
@@ -179,7 +193,7 @@ First stable release!
+ Fixed behaviour with capacity bound blocking queue such that there now are two methods to schedule a message
asynchronously. One will block until capacity becomes available, the other will timeout after a specified amount of
time.
- + Added unit tests
+ + Additional unit tests
1.0.5.RC
diff --git a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.jar b/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.jar
deleted file mode 100644
index e9fe134..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.jar.md5 b/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.jar.md5
deleted file mode 100644
index 4bb0b1e..0000000
--- a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-d53edd50a68307a4c209fd21fa0625d7
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.jar.sha1 b/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.jar.sha1
deleted file mode 100644
index dc96805..0000000
--- a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-f2ed26a15178d83c80212ccce73584e97e7d6fb8
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.pom b/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.pom
deleted file mode 100644
index 5826b60..0000000
--- a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.pom
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
- org.mbassy
- mbassador
- 1.0.0.RC
- jar
- mbassador
- Mbassador is a fast and flexible message bus system that follows the publish subscribe pattern
-
-
-
- UTF-8
- 1.6
- file://${project.basedir}/maven
-
-
-
-
-
- junit
- junit
- 4.10
- test
-
-
-
-
-
-
- mbassador-github-repo
- ${github.url}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- ${project.build.java.version}
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- false
-
-
-
-
-
-
diff --git a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.pom.md5 b/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.pom.md5
deleted file mode 100644
index ce93c9f..0000000
--- a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-760688c8fb33fc90918146e68dab2646
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.pom.sha1 b/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.pom.sha1
deleted file mode 100644
index 0c831da..0000000
--- a/maven/org/mbassy/mbassador/1.0.0.RC/mbassador-1.0.0.RC.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-0abf762df11d85841f8f8b7f28361ff19549f019
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.jar b/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.jar
deleted file mode 100644
index a84d113..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.jar.md5 b/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.jar.md5
deleted file mode 100644
index c66d198..0000000
--- a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-933328ff6220f5910770b9b5f13f2eeb
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.jar.sha1 b/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.jar.sha1
deleted file mode 100644
index ece776c..0000000
--- a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-003aa85106cfbab5ce618ffd1a6fe36cd0e37b71
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.pom b/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.pom
deleted file mode 100644
index 90464ef..0000000
--- a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.pom
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
- org.mbassy
- mbassador
- 1.0.1.RC
- jar
- mbassador
- Mbassador is a fast and flexible message bus system that follows the publish subscribe pattern
-
-
-
- UTF-8
- 1.6
- file://${project.basedir}/maven
-
-
-
-
-
- junit
- junit
- 4.10
- test
-
-
-
-
-
-
- mbassador-github-repo
- ${github.url}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- ${project.build.java.version}
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- false
-
-
-
-
-
-
diff --git a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.pom.md5 b/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.pom.md5
deleted file mode 100644
index d88057e..0000000
--- a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-5959d236fd411d499f3b46ecedc28a84
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.pom.sha1 b/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.pom.sha1
deleted file mode 100644
index 9727a29..0000000
--- a/maven/org/mbassy/mbassador/1.0.1.RC/mbassador-1.0.1.RC.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-5203632e409974a234ff8ce0ea88c5897a8cbffe
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.jar b/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.jar
deleted file mode 100644
index e4b8220..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.jar.md5 b/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.jar.md5
deleted file mode 100644
index 1f9b48d..0000000
--- a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-5ad621adc6addc2292ee1fc7a2bd756d
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.jar.sha1 b/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.jar.sha1
deleted file mode 100644
index 201e316..0000000
--- a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-258a17785e15390e868efe2a51d5370aeb602129
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.pom b/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.pom
deleted file mode 100644
index 5595a95..0000000
--- a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.pom
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
- org.mbassy
- mbassador
- 1.0.2.RC
- jar
- mbassador
- Mbassador is a fast and flexible message bus system that follows the publish subscribe pattern
-
-
-
- UTF-8
- 1.6
- file://${project.basedir}/maven
-
-
-
-
-
- junit
- junit
- 4.10
- test
-
-
-
-
-
-
- mbassador-github-repo
- ${github.url}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- ${project.build.java.version}
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- false
-
-
-
-
-
-
diff --git a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.pom.md5 b/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.pom.md5
deleted file mode 100644
index 66edd8c..0000000
--- a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-f7972cec0f8ebde2a2a17a678ef36eb6
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.pom.sha1 b/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.pom.sha1
deleted file mode 100644
index 607a740..0000000
--- a/maven/org/mbassy/mbassador/1.0.2.RC/mbassador-1.0.2.RC.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-f8c24fe42f192dbdd1f5d2b29bff0220d40039dd
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.jar b/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.jar
deleted file mode 100644
index 1603cba..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.jar.md5 b/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.jar.md5
deleted file mode 100644
index 74e0f26..0000000
--- a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-2bcfd233f83cb6fc4241c91a99f74030
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.jar.sha1 b/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.jar.sha1
deleted file mode 100644
index 37363fa..0000000
--- a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-20df67988104be77a9c3e2edbb8ba615a664671b
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.pom b/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.pom
deleted file mode 100644
index 672013e..0000000
--- a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.pom
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
- org.mbassy
- mbassador
- 1.0.3.RC
- jar
- mbassador
- Mbassador is a fast and flexible message bus system that follows the publish subscribe pattern
-
-
-
- UTF-8
- 1.6
- file://${project.basedir}/maven
-
-
-
-
-
- junit
- junit
- 4.10
- test
-
-
-
-
-
-
- mbassador-github-repo
- ${github.url}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- ${project.build.java.version}
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- false
-
-
-
-
-
-
diff --git a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.pom.md5 b/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.pom.md5
deleted file mode 100644
index eb940fa..0000000
--- a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-d766622aea3238ee52a60920313274d1
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.pom.sha1 b/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.pom.sha1
deleted file mode 100644
index 2eb3bea..0000000
--- a/maven/org/mbassy/mbassador/1.0.3.RC/mbassador-1.0.3.RC.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-55c27ec10ee4067843f05fb735a2af95bc2c06cf
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.jar b/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.jar
deleted file mode 100644
index 15d5a54..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.jar.md5 b/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.jar.md5
deleted file mode 100644
index 7e766e5..0000000
--- a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-2dcb34daf560ac4b9a87a95924aa7be6
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.jar.sha1 b/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.jar.sha1
deleted file mode 100644
index 0149eeb..0000000
--- a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-275d892046554f6a86226d813202c5ab8a22cf92
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.pom b/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.pom
deleted file mode 100644
index f53981a..0000000
--- a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.pom
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
- org.mbassy
- mbassador
- 1.0.4.RC
- jar
- mbassador
- Mbassador is a fast and flexible message bus system that follows the publish subscribe pattern
-
-
-
- UTF-8
- 1.6
- file://${project.basedir}/maven
-
-
-
-
-
- junit
- junit
- 4.10
- test
-
-
-
-
-
-
- mbassador-github-repo
- ${github.url}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- ${project.build.java.version}
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- false
-
-
-
-
-
-
diff --git a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.pom.md5 b/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.pom.md5
deleted file mode 100644
index 7bbab14..0000000
--- a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-75dda79a70a43a84877c3d62fdef401d
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.pom.sha1 b/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.pom.sha1
deleted file mode 100644
index ae3f6d3..0000000
--- a/maven/org/mbassy/mbassador/1.0.4.RC/mbassador-1.0.4.RC.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-ed21bd9587e9ee76e63b31ede3cbb6eedb04fa70
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.jar b/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.jar
deleted file mode 100644
index d583821..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.jar.md5 b/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.jar.md5
deleted file mode 100644
index 73b5650..0000000
--- a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-3ad14134e9752e3a073c75ab296427ef
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.jar.sha1 b/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.jar.sha1
deleted file mode 100644
index ca57baf..0000000
--- a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-bedef44bb92cbfafcba48624c91e185d692ea39d
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.pom b/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.pom
deleted file mode 100644
index 12d88d5..0000000
--- a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.pom
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
- org.mbassy
- mbassador
- 1.0.5.RC
- jar
- mbassador
- Mbassador is a fast and flexible message bus system that follows the publish subscribe pattern
-
-
-
- UTF-8
- 1.6
- file://${project.basedir}/maven
-
-
-
-
-
- junit
- junit
- 4.10
- test
-
-
-
-
-
-
- mbassador-github-repo
- ${github.url}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- ${project.build.java.version}
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- false
-
-
-
-
-
-
diff --git a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.pom.md5 b/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.pom.md5
deleted file mode 100644
index aabc0b6..0000000
--- a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-0a781a5e9f22e5dafeb7f48fff65e46d
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.pom.sha1 b/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.pom.sha1
deleted file mode 100644
index 121ebfa..0000000
--- a/maven/org/mbassy/mbassador/1.0.5.RC/mbassador-1.0.5.RC.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-4378b82fa04f4c31f21321424d0c4c328905d3ad
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.jar b/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.jar
deleted file mode 100644
index 8554bc9..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.jar.md5 b/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.jar.md5
deleted file mode 100644
index 1487a66..0000000
--- a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-dac16b8c129ee38d08e63d4cd487bdc9
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.jar.sha1 b/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.jar.sha1
deleted file mode 100644
index de87fa1..0000000
--- a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-110fd15551d0a40fafd46cc4e66c590e4d1b2fc7
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.pom b/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.pom
deleted file mode 100644
index 946afa5..0000000
--- a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.pom
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
- org.mbassy
- mbassador
- 1.0.6.RC
- jar
- mbassador
- Mbassador is a fast and flexible message bus system that follows the publish subscribe pattern
-
-
-
- UTF-8
- 1.6
- file://${project.basedir}/maven
-
-
-
-
-
- junit
- junit
- 4.10
- test
-
-
-
-
-
-
- mbassador-github-repo
- ${github.url}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- ${project.build.java.version}
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- false
-
-
-
-
-
-
diff --git a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.pom.md5 b/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.pom.md5
deleted file mode 100644
index ab78db3..0000000
--- a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-ebf2e22bfe53d858092befaa865d0bf4
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.pom.sha1 b/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.pom.sha1
deleted file mode 100644
index 2d480c2..0000000
--- a/maven/org/mbassy/mbassador/1.0.6.RC/mbassador-1.0.6.RC.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-950ca7e831a9060060f943ca02d313f7c7f5ccbf
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/maven-metadata.xml b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/maven-metadata.xml
deleted file mode 100644
index 0ac50ee..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/maven-metadata.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
- org.mbassy
- mbassador
- 1.0.7.RC-SNAPSHOT
-
-
- 20121229.133808
- 1
-
- 20121229133808
-
-
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/maven-metadata.xml.md5 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/maven-metadata.xml.md5
deleted file mode 100644
index 9ff2df9..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/maven-metadata.xml.md5
+++ /dev/null
@@ -1 +0,0 @@
-732608242394f6b316a7cf631208b635
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/maven-metadata.xml.sha1 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/maven-metadata.xml.sha1
deleted file mode 100644
index e8163e1..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/maven-metadata.xml.sha1
+++ /dev/null
@@ -1 +0,0 @@
-2cae8933661f8cf18afc2c923436c2457e0b3809
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-javadoc.jar b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-javadoc.jar
deleted file mode 100644
index 5bdb1dd..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-javadoc.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-javadoc.jar.md5 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-javadoc.jar.md5
deleted file mode 100644
index 04d9196..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-javadoc.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-d20f34dc532b790786a74566598e5e68
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-javadoc.jar.sha1 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-javadoc.jar.sha1
deleted file mode 100644
index d32ad4b..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-javadoc.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-13de5221308cf546ff55aa6b5a35ec1f78ecf691
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-sources.jar b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-sources.jar
deleted file mode 100644
index 9562a81..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-sources.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-sources.jar.md5 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-sources.jar.md5
deleted file mode 100644
index 0ae4ace..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-sources.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-ec63e6aa1e908e4036cca782675742df
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-sources.jar.sha1 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-sources.jar.sha1
deleted file mode 100644
index 449d649..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1-sources.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-79eb0716f839f2b63cf5d3d9796800967d54fdb5
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.jar b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.jar
deleted file mode 100644
index c8ce605..0000000
Binary files a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.jar and /dev/null differ
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.jar.md5 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.jar.md5
deleted file mode 100644
index e0d2a74..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-21ac5231ee676ba2461e31392e210b54
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.jar.sha1 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.jar.sha1
deleted file mode 100644
index f9d3314..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-9cfcc0fe9534d2a530b48445331d451b97ca3342
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.pom b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.pom
deleted file mode 100644
index 5761d5e..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.pom
+++ /dev/null
@@ -1,152 +0,0 @@
-
-
- 4.0.0
- org.mbassy
- mbassador
- 1.0.7.RC-SNAPSHOT
- jar
- mbassador
-
- Mbassador is a fast and flexible message bus system following the publish subscribe pattern.
- It is designed for ease of use and aims to be feature rich and extensible
- while preserving resource efficiency and performance.
-
- It features:
- declarative listener definition via annotations,
- sync and/or async message delivery,
- weak-references,
- message filtering,
- ordering of message handlers etc.
-
-
-
- https://github.com/bennidi/mbassador
-
-
- MIT license
- http://www.opensource.org/licenses/mit-license.php
-
-
-
- scm:git:git@github.com:bennidi/mbassador.git
- scm:git:git@github.com:bennidi/mbassador.git
-
-
-
-
- bennidi
- Benjamin Diedrichsen
- +1
-
-
-
-
- UTF-8
- 1.6
- file://${project.basedir}/maven
-
-
-
-
-
- junit
- junit
- 4.10
- test
-
-
-
-
-
-
- mbassador-github-repo
- ${github.url}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- ${project.build.java.version}
-
-
-
-
- org.apache.maven.plugins
- maven-release-plugin
- 2.4
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- false
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- attach-sources
-
- jar
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
-
-
-
-
-
- release-sign-artifacts
-
-
- performRelease
- true
-
-
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 1.4
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
-
-
-
-
-
-
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.pom.md5 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.pom.md5
deleted file mode 100644
index d4d779a..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-05e16f4d46db6bc39529ebe889ff552d
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.pom.sha1 b/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.pom.sha1
deleted file mode 100644
index 7393001..0000000
--- a/maven/org/mbassy/mbassador/1.0.7.RC-SNAPSHOT/mbassador-1.0.7.RC-20121229.133808-1.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-5e078c7f168816392ca34e41cbc8f58c81b8c5d9
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/maven-metadata.xml b/maven/org/mbassy/mbassador/maven-metadata.xml
deleted file mode 100644
index 08b6b73..0000000
--- a/maven/org/mbassy/mbassador/maven-metadata.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
- org.mbassy
- mbassador
- 1.0.0.RC
-
-
- 1.0.0.RC
- 1.0.1.RC
- 1.0.2.RC
- 1.0.3.RC
- 1.0.4.RC
- 1.0.5.RC
- 1.0.6.RC
- 1.0.7.RC-SNAPSHOT
-
- 20121229133808
-
-
diff --git a/maven/org/mbassy/mbassador/maven-metadata.xml.md5 b/maven/org/mbassy/mbassador/maven-metadata.xml.md5
deleted file mode 100644
index 8158d92..0000000
--- a/maven/org/mbassy/mbassador/maven-metadata.xml.md5
+++ /dev/null
@@ -1 +0,0 @@
-46231d9bfb55280deeea69a9e18ed52b
\ No newline at end of file
diff --git a/maven/org/mbassy/mbassador/maven-metadata.xml.sha1 b/maven/org/mbassy/mbassador/maven-metadata.xml.sha1
deleted file mode 100644
index e152e77..0000000
--- a/maven/org/mbassy/mbassador/maven-metadata.xml.sha1
+++ /dev/null
@@ -1 +0,0 @@
-3608eef0e3183c20460c8b1839c6a3d5740dd63e
\ No newline at end of file
diff --git a/src/docs/wiki-bus-overview.md b/src/docs/wiki-bus-overview.md
index 6b34ee8..81b0eed 100644
--- a/src/docs/wiki-bus-overview.md
+++ b/src/docs/wiki-bus-overview.md
@@ -18,9 +18,10 @@ The basic contract of the bus is that it will deliver a specific message exactly
Currently, message handlers will be invoked in inverse sequence of subscription but any
client using this bus should not rely on this assumption.
-The bus uses weak references to all listeners such that registered listeners do not need to
+By default, the bus uses weak references to all listeners such that registered listeners do not need to
be explicitly unregistered to be eligible for garbage collection. Dead (garbage collected) listeners are
-removed on-the-fly as messages get published.
+removed on-the-fly as messages get published. It is possible to enable the use of strong references on the message handler
+level.
Unsubscribing a listener means removing all subscribed message handlers of that listener. This remove operation
immediately effects all running publications processes -> A removed listener will under no circumstances receive any message publications.
diff --git a/src/docs/wiki-listener-def.md b/src/docs/wiki-listener-def.md
index 1bde8d0..b047af0 100644
--- a/src/docs/wiki-listener-def.md
+++ b/src/docs/wiki-listener-def.md
@@ -10,10 +10,17 @@ filters, delivery modes etc.
delivery
-
Message delivery can either run sequentially(i.e. one listener at a time) or concurrently
- (i.e. multiple threads are used to deliver the same message to different listeners).
- Note:The number of parallel threads is configurable per instance using the BusConfiguration
-
Sequential
+
Message handler invocation can be configured to run
+
+
Synchronously: One handler at a time within a given message publication. Each invocation occurs from the same thread
+
Asynchronously: Multiple threads are used within a given message publication. Each handler invocation
+ runs in a separate thread.Note:The number of parallel threads is configurable per instance using the BusConfiguration
+
+ Note: Use @Synchronized if your handler does not allow multiple, concurrent message publications, i.e.
+ handlers that are not thread-safe but are used in a multi-threaded environment where asynchronous message publication
+ is possible.
+
+
Synchronously
@@ -42,6 +49,21 @@ filters, delivery modes etc.
true
+
+
strongReferencess
+
Whether the bus should use storng references to the listeners instead of weak references
+
+
false
+
+
+
invocation
+
Specify a custom implementation for the handler invocation. By default, a generic implementation
+ that uses reflection will be used. Note: A custom implementation will not be faster than the generic one
+ since there are heavy optimizations by the JVM using JIT-Compiler and more.
+
+
false
+
+
@@ -59,22 +81,22 @@ receive all messages of type TestEvent or any subtype sequentially.
-This handler will receive all messages of type SubTestEvent or any subtype concurrently
+This handler will receive all messages of type SubTestEvent or any subtype
- // this handler will be invoked concurrently
- @Handler(delivery = Mode.Concurrent)
+ // handler invocation will occur in a different thread
+ @Handler(delivery = Invoke.Asynchronously)
public void handleSubTestEvent(SubTestEvent event) {
// do something more expensive here
}
-This handler will receive all messages of type SubTestEvent or any subtype sequentially,
+This handler will receive all messages of type SubTestEvent or any subtype,
given that they pass the specified filters. This handler will be invoked before the formerly
defined one, since it specifies a higher priority
// this handler will receive messages of type SubTestEvent
// or any of its sub types that passe the given filter(s)
@Handler(priority = 10,
- dispatch = Mode.Synchronous,
+ dispatch = Invoke.Synchronously,
filters = {@Filter(Filters.SpecialEvent.class)})
public void handleFiltered(SubTestEvent event) {
//do something special here
@@ -112,8 +134,8 @@ Message handler inheritance corresponds to inheritance of methods as defined in
A subclass of any class that defines message handlers will inherit these handler and their configuration.
It is possible to change (override) the configuration simply by overriding the super class' method and
specifying a different configuration. This way, it is also possible to deactivate a message handler of
-a super class by using the "enabled" property on the overridden method.
-If a class overrides a method that is configured as a message handler in one of its super classes
+a super class by setting the "enabled" property to "false" on the overridden method.
+If a class overrides a method that is already configured as a message handler
it is still considered a message handler but of course the implementation of the overriding class
will be used.
diff --git a/src/main/java/net/engio/mbassy/MessageBusException.java b/src/main/java/net/engio/mbassy/MessageBusException.java
new file mode 100644
index 0000000..7fcde70
--- /dev/null
+++ b/src/main/java/net/engio/mbassy/MessageBusException.java
@@ -0,0 +1,29 @@
+package net.engio.mbassy;
+
+/**
+ * Todo: Add javadoc
+ *
+ * @author bennidi
+ * Date: 3/29/13
+ */
+public class MessageBusException extends Exception{
+
+ public MessageBusException() {
+ }
+
+ public MessageBusException(String message) {
+ super(message);
+ }
+
+ public MessageBusException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MessageBusException(Throwable cause) {
+ super(cause);
+ }
+
+ public MessageBusException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/src/main/java/net/engio/mbassy/bus/AbstractSyncAsyncMessageBus.java b/src/main/java/net/engio/mbassy/bus/AbstractSyncAsyncMessageBus.java
new file mode 100644
index 0000000..bacfddc
--- /dev/null
+++ b/src/main/java/net/engio/mbassy/bus/AbstractSyncAsyncMessageBus.java
@@ -0,0 +1,100 @@
+package net.engio.mbassy.bus;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.*;
+
+/**
+ * The base class for all message bus implementations.
+ *
+ * @param
+ * @param
+ */
+public abstract class AbstractSyncAsyncMessageBus extends AbstractSyncMessageBus implements IMessageBus {
+
+ // executor for asynchronous message handlers
+ private final ExecutorService executor;
+
+ // all threads that are available for asynchronous message dispatching
+ private final List dispatchers;
+
+ // all pending messages scheduled for asynchronous dispatch are queued here
+ private final BlockingQueue pendingMessages;
+
+ public AbstractSyncAsyncMessageBus(BusConfiguration configuration) {
+ super(configuration);
+ this.executor = configuration.getExecutor();
+ pendingMessages = new LinkedBlockingQueue(configuration.getMaximumNumberOfPendingMessages());
+ dispatchers = new ArrayList(configuration.getNumberOfMessageDispatchers());
+ initDispatcherThreads(configuration.getNumberOfMessageDispatchers());
+ }
+
+
+ // initialize the dispatch workers
+ private void initDispatcherThreads(int numberOfThreads) {
+ for (int i = 0; i < numberOfThreads; i++) {
+ // each thread will run forever and process incoming
+ //dispatch requests
+ Thread dispatcher = new Thread(new Runnable() {
+ public void run() {
+ while (true) {
+ try {
+ pendingMessages.take().execute();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return;
+ }
+ }
+ }
+ });
+ dispatcher.setDaemon(true); // do not prevent the JVM from exiting
+ dispatchers.add(dispatcher);
+ dispatcher.start();
+ }
+ }
+
+
+ // this method enqueues a message delivery request
+ protected MessagePublication addAsynchronousDeliveryRequest(MessagePublication request) {
+ try {
+ pendingMessages.put(request);
+ return request.markScheduled();
+ } catch (InterruptedException e) {
+ return request.setError();
+ }
+ }
+
+ // this method enqueues a message delivery request
+ protected MessagePublication addAsynchronousDeliveryRequest(MessagePublication request, long timeout, TimeUnit unit) {
+ try {
+ return pendingMessages.offer(request, timeout, unit)
+ ? request.markScheduled()
+ : request.setError();
+ } catch (InterruptedException e) {
+ return request.setError();
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ shutdown();
+ super.finalize();
+ }
+
+ public void shutdown() {
+ for (Thread dispatcher : dispatchers) {
+ dispatcher.interrupt();
+ }
+ executor.shutdown();
+ }
+
+ public boolean hasPendingMessages() {
+ return pendingMessages.size() > 0;
+ }
+
+ @Override
+ public Executor getExecutor() {
+ return executor;
+ }
+
+}
diff --git a/src/main/java/net/engio/mbassy/bus/AbstractMessageBus.java b/src/main/java/net/engio/mbassy/bus/AbstractSyncMessageBus.java
similarity index 68%
rename from src/main/java/net/engio/mbassy/bus/AbstractMessageBus.java
rename to src/main/java/net/engio/mbassy/bus/AbstractSyncMessageBus.java
index 7a0e439..f5a2cf1 100644
--- a/src/main/java/net/engio/mbassy/bus/AbstractMessageBus.java
+++ b/src/main/java/net/engio/mbassy/bus/AbstractSyncMessageBus.java
@@ -9,22 +9,8 @@ import net.engio.mbassy.subscription.Subscription;
import net.engio.mbassy.subscription.SubscriptionContext;
import net.engio.mbassy.subscription.SubscriptionFactory;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
+import java.util.*;
+import java.util.concurrent.*;
/**
* The base class for all message bus implementations.
@@ -32,10 +18,8 @@ import java.util.concurrent.TimeUnit;
* @param
* @param
*/
-public abstract class AbstractMessageBus implements IMessageBus {
+public abstract class AbstractSyncMessageBus implements ISyncMessageBus {
- // executor for asynchronous listeners using unbound queuing strategy to ensure that no events get lost
- private final ExecutorService executor;
// the metadata reader that is used to parse objects passed to the subscribe method
private final MetadataReader metadataReader;
@@ -58,12 +42,6 @@ public abstract class AbstractMessageBus
// this handler will receive all errors that occur during message dispatch or message handling
private final List errorHandlers = new CopyOnWriteArrayList();
- // all threads that are available for asynchronous message dispatching
- private final List dispatchers = new CopyOnWriteArrayList();
-
- // all pending messages scheduled for asynchronous dispatch are queued here
- private final BlockingQueue pendingMessages;
-
// this factory is used to create specialized subscriptions based on the given message handler configuration
// it can be customized by implementing the getSubscriptionFactory() method
private final SubscriptionFactory subscriptionFactory;
@@ -71,40 +49,13 @@ public abstract class AbstractMessageBus
private final MessagePublication.Factory publicationFactory;
- public AbstractMessageBus(BusConfiguration configuration) {
- this.executor = configuration.getExecutor();
+ public AbstractSyncMessageBus(SyncBusConfiguration configuration) {
subscriptionFactory = configuration.getSubscriptionFactory();
this.metadataReader = configuration.getMetadataReader();
this.publicationFactory = configuration.getMessagePublicationFactory();
- pendingMessages = new LinkedBlockingQueue(configuration.getMaximumNumberOfPendingMessages());
- initDispatcherThreads(configuration.getNumberOfMessageDispatchers());
addErrorHandler(new IPublicationErrorHandler.ConsoleLogger());
}
-
- // initialize the dispatch workers
- private void initDispatcherThreads(int numberOfThreads) {
- for (int i = 0; i < numberOfThreads; i++) {
- // each thread will run forever and process incoming
- //dispatch requests
- Thread dispatcher = new Thread(new Runnable() {
- public void run() {
- while (true) {
- try {
- pendingMessages.take().execute();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- return;
- }
- }
- }
- });
- dispatcher.setDaemon(true); // do not prevent the JVM from exiting
- dispatchers.add(dispatcher);
- dispatcher.start();
- }
- }
-
protected MessagePublication.Factory getPublicationFactory() {
return publicationFactory;
}
@@ -179,26 +130,7 @@ public abstract class AbstractMessageBus
errorHandlers.add(handler);
}
- // this method enqueues a message delivery request
- protected MessagePublication addAsynchronousDeliveryRequest(MessagePublication request) {
- try {
- pendingMessages.put(request);
- return request.markScheduled();
- } catch (InterruptedException e) {
- return request.setError();
- }
- }
- // this method enqueues a message delivery request
- protected MessagePublication addAsynchronousDeliveryRequest(MessagePublication request, long timeout, TimeUnit unit) {
- try {
- return pendingMessages.offer(request, timeout, unit)
- ? request.markScheduled()
- : request.setError();
- } catch (InterruptedException e) {
- return request.setError();
- }
- }
// obtain the set of subscriptions for the given message type
// Note: never returns null!
@@ -241,26 +173,4 @@ public abstract class AbstractMessageBus
}
}
- @Override
- protected void finalize() throws Throwable {
- shutdown();
- super.finalize();
- }
-
- private void shutdown() {
- for (Thread dispatcher : dispatchers) {
- dispatcher.interrupt();
- }
- executor.shutdown();
- }
-
- public boolean hasPendingMessages() {
- return pendingMessages.size() > 0;
- }
-
- @Override
- public Executor getExecutor() {
- return executor;
- }
-
}
diff --git a/src/main/java/net/engio/mbassy/bus/BusConfiguration.java b/src/main/java/net/engio/mbassy/bus/BusConfiguration.java
index 03b1572..b13ee45 100644
--- a/src/main/java/net/engio/mbassy/bus/BusConfiguration.java
+++ b/src/main/java/net/engio/mbassy/bus/BusConfiguration.java
@@ -1,14 +1,6 @@
package net.engio.mbassy.bus;
-import net.engio.mbassy.listener.MetadataReader;
-import net.engio.mbassy.subscription.SubscriptionFactory;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
/**
* The bus configuration holds various parameters that can be used to customize the bus' runtime behaviour.
@@ -16,7 +8,7 @@ import java.util.concurrent.TimeUnit;
* @author bennidi
* Date: 12/8/12
*/
-public class BusConfiguration {
+public class BusConfiguration extends SyncBusConfiguration {
private static final ThreadFactory DaemonThreadFactory = new ThreadFactory() {
@Override
@@ -37,36 +29,11 @@ public class BusConfiguration {
private int maximumNumberOfPendingMessages;
- private SubscriptionFactory subscriptionFactory;
-
- private MetadataReader metadataReader;
-
- private MessagePublication.Factory messagePublicationFactory;
-
public BusConfiguration() {
+ super();
this.numberOfMessageDispatchers = 2;
this.maximumNumberOfPendingMessages = Integer.MAX_VALUE;
- this.subscriptionFactory = new SubscriptionFactory();
this.executor = new ThreadPoolExecutor(10, 10, 1, TimeUnit.MINUTES, new LinkedBlockingQueue(), DaemonThreadFactory);
- this.metadataReader = new MetadataReader();
- this.messagePublicationFactory = new MessagePublication.Factory();
- }
-
- public MessagePublication.Factory getMessagePublicationFactory() {
- return messagePublicationFactory;
- }
-
- public void setMessagePublicationFactory(MessagePublication.Factory messagePublicationFactory) {
- this.messagePublicationFactory = messagePublicationFactory;
- }
-
- public MetadataReader getMetadataReader() {
- return metadataReader;
- }
-
- public BusConfiguration setMetadataReader(MetadataReader metadataReader) {
- this.metadataReader = metadataReader;
- return this;
}
public int getNumberOfMessageDispatchers() {
@@ -78,6 +45,10 @@ public class BusConfiguration {
return this;
}
+ /**
+ * By default an unbound queuing strategy is used to ensure that no events get lost
+ * @return
+ */
public ExecutorService getExecutor() {
return executor;
}
@@ -98,12 +69,4 @@ public class BusConfiguration {
return this;
}
- public SubscriptionFactory getSubscriptionFactory() {
- return subscriptionFactory;
- }
-
- public BusConfiguration setSubscriptionFactory(SubscriptionFactory subscriptionFactory) {
- this.subscriptionFactory = subscriptionFactory;
- return this;
- }
}
diff --git a/src/main/java/net/engio/mbassy/bus/IMessageBus.java b/src/main/java/net/engio/mbassy/bus/IMessageBus.java
index b4764c8..f80dbda 100644
--- a/src/main/java/net/engio/mbassy/bus/IMessageBus.java
+++ b/src/main/java/net/engio/mbassy/bus/IMessageBus.java
@@ -1,8 +1,5 @@
package net.engio.mbassy.bus;
-import net.engio.mbassy.IPublicationErrorHandler;
-
-import java.util.Collection;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
@@ -47,56 +44,10 @@ import java.util.concurrent.TimeUnit;
* @Author bennidi
* Date: 2/8/12
*/
-public interface IMessageBus {
+public interface IMessageBus extends ISyncMessageBus {
/**
- * Subscribe all listeners of the given message to receive message publications.
- * Any message may only be subscribed once (subsequent subscriptions of an already subscribed
- * message will be silently ignored)
- *
- * @param listener
- */
- void subscribe(Object listener);
-
- /**
- * Immediately remove all registered message handlers (if any) of the given listener. When this call returns all handlers
- * have effectively been removed and will not receive any message publications (including asynchronously scheduled
- * publications that have been published when the message listener was still subscribed).
- *
- * A call to this method passing null, an already unsubscribed listener or any object that does not define any message
- * handlers will not have any effect and is silently ignored.
- *
- * @param listener
- * @return true, if the listener was found and successfully removed
- * false otherwise
- */
- boolean unsubscribe(Object listener);
-
- /**
- * @param message
- * @return
- */
- P post(T message);
-
- /**
- * Publication errors may occur at various points of time during message delivery. A handler may throw an exception,
- * may not be accessible due to security constraints or is not annotated properly.
- * In any of all possible cases a publication error is created and passed to each of the registered error handlers.
- * A call to this method will add the given error handler to the chain
- *
- * @param errorHandler
- */
- void addErrorHandler(IPublicationErrorHandler errorHandler);
-
- /**
- * Returns an immutable collection containing all the registered error handlers
- *
- * @return
- */
- Collection getRegisteredErrorHandlers();
-
- /**
- * Get the executor service that is used to asynchronous message publication.
+ * Get the executor service that is used for asynchronous message publications.
* The executor is passed to the message bus at creation time.
*
* @return
@@ -111,17 +62,20 @@ public interface IMessageBus {
boolean hasPendingMessages();
/**
- * A post command is used as an intermediate object created by a call to the message bus' post method.
- * It encapsulates the functionality provided by the message bus that created the command.
- * Subclasses may extend this interface and add functionality, e.g. different dispatch schemes.
+ * Shutdown the bus such that it will stop delivering asynchronous messages. Executor service and
+ * other internally used threads will be shutdown gracefully. After calling shutdown it is not safe
+ * to further use the message bus.
*/
- interface IPostCommand {
+ void shutdown();
- /**
- * Execute the message publication immediately. This call blocks until every matching message handler
- * has been invoked.
- */
- void now();
+ /**
+ * @param message
+ * @return
+ */
+ P post(T message);
+
+
+ interface IPostCommand extends ISyncPostCommand {
/**
* Execute the message publication asynchronously. The behaviour of this method depends on the
@@ -146,4 +100,5 @@ public interface IMessageBus {
*/
MessagePublication asynchronously(long timeout, TimeUnit unit);
}
+
}
diff --git a/src/main/java/net/engio/mbassy/bus/ISyncMessageBus.java b/src/main/java/net/engio/mbassy/bus/ISyncMessageBus.java
new file mode 100644
index 0000000..3c187d5
--- /dev/null
+++ b/src/main/java/net/engio/mbassy/bus/ISyncMessageBus.java
@@ -0,0 +1,77 @@
+package net.engio.mbassy.bus;
+
+import net.engio.mbassy.IPublicationErrorHandler;
+
+import java.util.Collection;
+
+/**
+ *
+ *
+ * @author bennidi
+ * Date: 3/29/13
+ */
+public interface ISyncMessageBus {
+
+
+ /**
+ * Subscribe all listeners of the given message to receive message publications.
+ * Any message may only be subscribed once (subsequent subscriptions of an already subscribed
+ * message will be silently ignored)
+ *
+ * @param listener
+ */
+ void subscribe(Object listener);
+
+ /**
+ * Immediately remove all registered message handlers (if any) of the given listener. When this call returns all handlers
+ * have effectively been removed and will not receive any message publications (including asynchronously scheduled
+ * publications that have been published when the message listener was still subscribed).
+ *
+ * A call to this method passing null, an already unsubscribed listener or any object that does not define any message
+ * handlers will not have any effect and is silently ignored.
+ *
+ * @param listener
+ * @return true, if the listener was found and successfully removed
+ * false otherwise
+ */
+ boolean unsubscribe(Object listener);
+
+ /**
+ * @param message
+ * @return
+ */
+ P post(T message);
+
+ /**
+ * Publication errors may occur at various points of time during message delivery. A handler may throw an exception,
+ * may not be accessible due to security constraints or is not annotated properly.
+ * In any of all possible cases a publication error is created and passed to each of the registered error handlers.
+ * A call to this method will add the given error handler to the chain
+ *
+ * @param errorHandler
+ */
+ void addErrorHandler(IPublicationErrorHandler errorHandler);
+
+ /**
+ * Returns an immutable collection containing all the registered error handlers
+ *
+ * @return
+ */
+ Collection getRegisteredErrorHandlers();
+
+
+
+ /**
+ * A post command is used as an intermediate object created by a call to the message bus' post method.
+ * It encapsulates the functionality provided by the message bus that created the command.
+ * Subclasses may extend this interface and add functionality, e.g. different dispatch schemes.
+ */
+ interface ISyncPostCommand {
+
+ /**
+ * Execute the message publication immediately. This call blocks until every matching message handler
+ * has been invoked.
+ */
+ void now();
+ }
+}
diff --git a/src/main/java/net/engio/mbassy/bus/MBassador.java b/src/main/java/net/engio/mbassy/bus/MBassador.java
index fffa567..6bf1941 100644
--- a/src/main/java/net/engio/mbassy/bus/MBassador.java
+++ b/src/main/java/net/engio/mbassy/bus/MBassador.java
@@ -8,7 +8,7 @@ import java.util.Collection;
import java.util.concurrent.TimeUnit;
-public class MBassador extends AbstractMessageBus> {
+public class MBassador extends AbstractSyncAsyncMessageBus> {
public MBassador(BusConfiguration configuration) {
super(configuration);
diff --git a/src/main/java/net/engio/mbassy/bus/SyncBusConfiguration.java b/src/main/java/net/engio/mbassy/bus/SyncBusConfiguration.java
new file mode 100644
index 0000000..07bebe9
--- /dev/null
+++ b/src/main/java/net/engio/mbassy/bus/SyncBusConfiguration.java
@@ -0,0 +1,49 @@
+package net.engio.mbassy.bus;
+
+import net.engio.mbassy.listener.MetadataReader;
+import net.engio.mbassy.subscription.SubscriptionFactory;
+
+/**
+ * Todo: Add javadoc
+ *
+ * @author bennidi
+ * Date: 3/29/13
+ */
+public class SyncBusConfiguration> {
+
+ protected SubscriptionFactory subscriptionFactory;
+ protected MetadataReader metadataReader;
+ protected MessagePublication.Factory messagePublicationFactory;
+
+ public SyncBusConfiguration() {
+ this.metadataReader = new MetadataReader();
+ this.subscriptionFactory = new SubscriptionFactory();
+ this.messagePublicationFactory = new MessagePublication.Factory();
+ }
+
+ public MessagePublication.Factory getMessagePublicationFactory() {
+ return messagePublicationFactory;
+ }
+
+ public void setMessagePublicationFactory(MessagePublication.Factory messagePublicationFactory) {
+ this.messagePublicationFactory = messagePublicationFactory;
+ }
+
+ public MetadataReader getMetadataReader() {
+ return metadataReader;
+ }
+
+ public Config setMetadataReader(MetadataReader metadataReader) {
+ this.metadataReader = metadataReader;
+ return (Config)this;
+ }
+
+ public SubscriptionFactory getSubscriptionFactory() {
+ return subscriptionFactory;
+ }
+
+ public Config setSubscriptionFactory(SubscriptionFactory subscriptionFactory) {
+ this.subscriptionFactory = subscriptionFactory;
+ return (Config)this;
+ }
+}
diff --git a/src/main/java/net/engio/mbassy/common/AbstractConcurrentSet.java b/src/main/java/net/engio/mbassy/common/AbstractConcurrentSet.java
new file mode 100644
index 0000000..3af5ea2
--- /dev/null
+++ b/src/main/java/net/engio/mbassy/common/AbstractConcurrentSet.java
@@ -0,0 +1,134 @@
+package net.engio.mbassy.common;
+
+
+import java.util.Map;
+
+/**
+ * This data structure is optimized for non-blocking reads even when write operations occur.
+ * Running read iterators will not be affected by add operations since writes always insert at the head of the
+ * structure. Remove operations can affect any running iterator such that a removed element that has not yet
+ * been reached by the iterator will not appear in that iterator anymore.
+ *
+ * @author bennidi
+ * Date: 2/12/12
+ */
+public abstract class AbstractConcurrentSet implements IConcurrentSet {
+
+ // Internal state
+ private final Object lock = new Object();
+ private final Map> entries; // maintain a map of entries for O(log n) lookup
+ protected Entry head; // reference to the first element
+
+ protected AbstractConcurrentSet(Map> entries) {
+ this.entries = entries;
+ }
+
+ protected abstract Entry createEntry(T value, Entry next);
+
+ @Override
+ public IConcurrentSet add(T element) {
+ if (element == null || entries.containsKey(element)) {
+ return this;
+ }
+ synchronized (lock) {
+ insert(element);
+ }
+ return this;
+ }
+
+ @Override
+ public boolean contains(T element) {
+ ISetEntry entry = entries.get(element);
+ return entry != null && entry.getValue() != null;
+ }
+
+ private void insert(T element) {
+ if (entries.containsKey(element)) {
+ return;
+ }
+ head = createEntry(element, head);
+ entries.put(element, head);
+ }
+
+ @Override
+ public int size() {
+ return entries.size();
+ }
+
+ @Override
+ public IConcurrentSet addAll(Iterable elements) {
+ synchronized (lock) {
+ for (T element : elements) {
+ if (element == null || entries.containsKey(element)) {
+ return this;
+ }
+
+ insert(element);
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public boolean remove(T element) {
+ if (!entries.containsKey(element)) {
+ return false;
+ }
+ synchronized (lock) {
+ ISetEntry listelement = entries.get(element);
+ if (listelement == null) {
+ return false; //removed by other thread
+ }
+ if (listelement != head) {
+ listelement.remove();
+ } else {
+ ISetEntry oldHead = head;
+ head = head.next();
+ oldHead.clear(); // optimize for GC
+ }
+ entries.remove(element);
+ }
+ return true;
+ }
+
+
+ public abstract static class Entry implements ISetEntry {
+
+ private Entry next;
+
+ private Entry predecessor;
+
+ protected Entry(Entry next) {
+ this.next = next;
+ next.predecessor = this;
+ }
+
+ protected Entry() {
+ }
+
+ // not thread-safe! must be synchronized in enclosing context
+ @Override
+ public void remove() {
+ if (predecessor != null) {
+ predecessor.next = next;
+ if (next != null) {
+ next.predecessor = predecessor;
+ }
+ } else if (next != null) {
+ next.predecessor = null;
+ }
+ next = null;
+ predecessor = null;
+ }
+
+ @Override
+ public Entry next() {
+ return next;
+ }
+
+ @Override
+ public void clear() {
+ next = null;
+ }
+ }
+}
diff --git a/src/main/java/net/engio/mbassy/common/ConcurrentSet.java b/src/main/java/net/engio/mbassy/common/ConcurrentSet.java
deleted file mode 100644
index 6c5b9fd..0000000
--- a/src/main/java/net/engio/mbassy/common/ConcurrentSet.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package net.engio.mbassy.common;
-
-
-import java.lang.ref.WeakReference;
-import java.util.Iterator;
-import java.util.WeakHashMap;
-
-/**
- * This data structure is optimized for non-blocking reads even when write operations occur.
- * Running read iterators will not be affected by add operations since writes always insert at the head of the
- * structure. Remove operations can affect any running iterator such that a removed element that has not yet
- * been reached by the iterator will not appear in that iterator anymore.
- *
- * The structure uses weak references to the elements. Iterators automatically perform cleanups of
- * garbage collected objects during iteration -> no dedicated maintenance operations need to be called or run in background.
- *
- *
- *
- *
- * @author bennidi
- * Date: 2/12/12
- */
-public class ConcurrentSet implements Iterable {
-
- // Internal state
- private final Object lock = new Object();
- private WeakHashMap> entries = new WeakHashMap>(); // maintain a map of entries for O(log n) lookup
- private Entry head; // reference to the first element
-
- public ConcurrentSet add(T element) {
- if (element == null || entries.containsKey(element)) {
- return this;
- }
- synchronized (lock) {
- insert(element);
- }
- return this;
- }
-
- public boolean contains(T element) {
- Entry entry = entries.get(element);
- return entry != null && entry.getValue() != null;
- }
-
- private void insert(T element) {
- if (entries.containsKey(element)) {
- return;
- }
- if (head == null) {
- head = new Entry(element);
- } else {
- head = new Entry(element, head);
- }
- entries.put(element, head);
- }
-
- public int size() {
- return entries.size();
- }
-
- public ConcurrentSet addAll(Iterable elements) {
- synchronized (lock) {
- for (T element : elements) {
- if (element == null || entries.containsKey(element)) {
- return this;
- }
-
- insert(element);
- }
- }
- return this;
- }
-
- public boolean remove(T element) {
- if (!entries.containsKey(element)) {
- return false;
- }
- synchronized (lock) {
- Entry listelement = entries.get(element);
- if (listelement == null) {
- return false; //removed by other thread
- }
- if (listelement != head) {
- listelement.remove();
- } else {
- Entry oldHead = head;
- head = head.next();
- oldHead.next = null; // optimize for GC
- }
- entries.remove(element);
- }
- return true;
- }
-
- public Iterator iterator() {
- return new Iterator() {
-
- private Entry current = head;
-
- public boolean hasNext() {
- if (current == null) return false;
- if (current.getValue() == null) { // auto-removal of orphan references
- do {
- remove();
- } while(current != null && current.getValue() == null);
- return hasNext();
- } else {
- return true;
- }
- }
-
- public T next() {
- if (current == null) {
- return null;
- }
- T value = current.getValue();
- if (value == null) { // auto-removal of orphan references
- do {
- remove();
- } while(current != null && current.getValue() == null);
- return next();
- } else {
- current = current.next();
- return value;
- }
- }
-
- public void remove() {
- if (current == null) {
- return;
- }
- Entry newCurrent = current.next();
- ConcurrentSet.this.remove(current.getValue());
- current = newCurrent;
- }
- };
- }
-
-
- public class Entry {
-
- private WeakReference value;
-
- private Entry next;
-
- private Entry predecessor;
-
-
- private Entry(T value) {
- this.value = new WeakReference(value);
- }
-
- private Entry(T value, Entry next) {
- this(value);
- this.next = next;
- next.predecessor = this;
- }
-
- public T getValue() {
- return value.get();
- }
-
- // not thread-safe! must be synchronized in enclosing context
- public void remove() {
- if (predecessor != null) {
- predecessor.next = next;
- if (next != null) {
- next.predecessor = predecessor;
- }
- } else if (next != null) {
- next.predecessor = null;
- }
- next = null;
- predecessor = null;
- }
-
- public Entry next() {
- return next;
- }
-
-
- }
-}
diff --git a/src/main/java/net/engio/mbassy/common/IConcurrentSet.java b/src/main/java/net/engio/mbassy/common/IConcurrentSet.java
new file mode 100644
index 0000000..432e4ed
--- /dev/null
+++ b/src/main/java/net/engio/mbassy/common/IConcurrentSet.java
@@ -0,0 +1,20 @@
+package net.engio.mbassy.common;
+
+/**
+ * Todo: Add javadoc
+ *
+ * @author bennidi
+ * Date: 3/29/13
+ */
+public interface IConcurrentSet extends Iterable {
+
+ IConcurrentSet add(T element);
+
+ boolean contains(T element);
+
+ int size();
+
+ IConcurrentSet addAll(Iterable elements);
+
+ boolean remove(T element);
+}
diff --git a/src/main/java/net/engio/mbassy/common/ISetEntry.java b/src/main/java/net/engio/mbassy/common/ISetEntry.java
new file mode 100644
index 0000000..aabb826
--- /dev/null
+++ b/src/main/java/net/engio/mbassy/common/ISetEntry.java
@@ -0,0 +1,19 @@
+package net.engio.mbassy.common;
+
+/**
+ * Todo: Add javadoc
+ *
+ * @author bennidi
+ * Date: 3/29/13
+ */
+public interface ISetEntry {
+
+ T getValue();
+
+ // not thread-safe! must be synchronized in enclosing context
+ void remove();
+
+ ISetEntry next();
+
+ void clear();
+}
diff --git a/src/main/java/net/engio/mbassy/common/StrongConcurrentSet.java b/src/main/java/net/engio/mbassy/common/StrongConcurrentSet.java
new file mode 100644
index 0000000..ad42994
--- /dev/null
+++ b/src/main/java/net/engio/mbassy/common/StrongConcurrentSet.java
@@ -0,0 +1,84 @@
+package net.engio.mbassy.common;
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * This implementation uses weak references to the elements. Iterators automatically perform cleanups of
+ * garbage collected objects during iteration -> no dedicated maintenance operations need to be called or run in background.
+ *
+ *
+ *
+ *
+ * @author bennidi
+ * Date: 2/12/12
+ */
+public class StrongConcurrentSet extends AbstractConcurrentSet{
+
+
+ public StrongConcurrentSet() {
+ super(new HashMap>());
+ }
+
+ public Iterator iterator() {
+ return new Iterator() {
+
+ private ISetEntry current = head;
+
+ public boolean hasNext() {
+ return current != null;
+ }
+
+ public T next() {
+ if (current == null) {
+ return null;
+ }
+ else {
+ T value = current.getValue();
+ current = current.next();
+ return value;
+ }
+ }
+
+ public void remove() {
+ if (current == null) {
+ return;
+ }
+ ISetEntry newCurrent = current.next();
+ StrongConcurrentSet.this.remove(current.getValue());
+ current = newCurrent;
+ }
+ };
+ }
+
+ @Override
+ protected Entry createEntry(T value, Entry next) {
+ return next != null ? new StrongEntry(value, next) : new StrongEntry(value);
+ }
+
+
+ public static class StrongEntry extends Entry {
+
+ private T value;
+
+ private StrongEntry(T value, Entry next) {
+ super(next);
+ this.value = value;
+ }
+
+ private StrongEntry(T value) {
+ super();
+ this.value = value;
+ }
+
+ @Override
+ public T getValue() {
+ return value;
+ }
+
+
+
+
+ }
+}
diff --git a/src/main/java/net/engio/mbassy/common/WeakConcurrentSet.java b/src/main/java/net/engio/mbassy/common/WeakConcurrentSet.java
new file mode 100644
index 0000000..d5caf9a
--- /dev/null
+++ b/src/main/java/net/engio/mbassy/common/WeakConcurrentSet.java
@@ -0,0 +1,98 @@
+package net.engio.mbassy.common;
+
+
+import java.lang.ref.WeakReference;
+import java.util.Iterator;
+import java.util.WeakHashMap;
+
+/**
+ * This implementation uses weak references to the elements. Iterators automatically perform cleanups of
+ * garbage collected objects during iteration -> no dedicated maintenance operations need to be called or run in background.
+ *
+ *
+ *
+ *
+ * @author bennidi
+ * Date: 2/12/12
+ */
+public class WeakConcurrentSet extends AbstractConcurrentSet{
+
+
+ public WeakConcurrentSet() {
+ super(new WeakHashMap>());
+ }
+
+ public Iterator iterator() {
+ return new Iterator() {
+
+ private ISetEntry current = head;
+
+ public boolean hasNext() {
+ if (current == null) return false;
+ if (current.getValue() == null) { // auto-removal of orphan references
+ do {
+ remove();
+ } while(current != null && current.getValue() == null);
+ return hasNext();
+ } else {
+ return true;
+ }
+ }
+
+ public T next() {
+ if (current == null) {
+ return null;
+ }
+ T value = current.getValue();
+ if (value == null) { // auto-removal of orphan references
+ do {
+ remove();
+ } while(current != null && current.getValue() == null);
+ return next();
+ } else {
+ current = current.next();
+ return value;
+ }
+ }
+
+ public void remove() {
+ if (current == null) {
+ return;
+ }
+ ISetEntry newCurrent = current.next();
+ WeakConcurrentSet.this.remove(current.getValue());
+ current = newCurrent;
+ }
+ };
+ }
+
+ @Override
+ protected Entry createEntry(T value, Entry next) {
+ return next != null ? new WeakEntry(value, next) : new WeakEntry(value);
+ }
+
+
+ public static class WeakEntry extends Entry {
+
+ private WeakReference value;
+
+ private WeakEntry(T value, Entry next) {
+ super(next);
+ this.value = new WeakReference(value);
+ }
+
+ private WeakEntry(T value) {
+ super();
+ this.value = new WeakReference(value);
+ }
+
+ @Override
+ public T getValue() {
+ return value.get();
+ }
+
+
+
+
+ }
+}
diff --git a/src/main/java/net/engio/mbassy/dispatch/AsynchronousHandlerInvocation.java b/src/main/java/net/engio/mbassy/dispatch/AsynchronousHandlerInvocation.java
index 5d7ffbb..24e1994 100644
--- a/src/main/java/net/engio/mbassy/dispatch/AsynchronousHandlerInvocation.java
+++ b/src/main/java/net/engio/mbassy/dispatch/AsynchronousHandlerInvocation.java
@@ -1,5 +1,6 @@
package net.engio.mbassy.dispatch;
+import net.engio.mbassy.bus.IMessageBus;
import net.engio.mbassy.subscription.AbstractSubscriptionContextAware;
/**
@@ -8,7 +9,7 @@ import net.engio.mbassy.subscription.AbstractSubscriptionContextAware;
* @author bennidi
* Date: 11/23/12
*/
-public class AsynchronousHandlerInvocation extends AbstractSubscriptionContextAware implements IHandlerInvocation {
+public class AsynchronousHandlerInvocation extends AbstractSubscriptionContextAware implements IHandlerInvocation