diff --git a/src/main/java/net/engio/mbassy/MBassador.java b/src/main/java/net/engio/mbassy/MBassador.java index 9a9b57a..ff17109 100644 --- a/src/main/java/net/engio/mbassy/MBassador.java +++ b/src/main/java/net/engio/mbassy/MBassador.java @@ -80,12 +80,6 @@ public class MBassador extends AbstractPubSubSupport implements IMessageBus { } - /** - * Synchronously publish a message to all registered listeners (this includes listeners defined for super types) - * The call blocks until every messageHandler has processed the message. - * - * @param message - */ @Override public void publish(Object message) { try { @@ -98,15 +92,6 @@ public class MBassador extends AbstractPubSubSupport implements IMessageBus { } } - /** - * Execute the message publication asynchronously. The behavior of this method depends on the - * configured queuing strategy: - *

- * If an unbound queuing strategy is used the call returns immediately. - * If a bounded queue is used the call might block until the message can be placed in the queue. - * - * @return A message publication that can be used to access information about it's state - */ @Override public void publishAsync(Object message) { try { @@ -116,18 +101,8 @@ public class MBassador extends AbstractPubSubSupport implements IMessageBus { } } - /** - * Execute the message publication asynchronously. The behaviour of this method depends on the - * configured queuing strategy: - *

- * If an unbound queuing strategy is used the call returns immediately. - * If a bounded queue is used the call will block until the message can be placed in the queue - * or the timeout is reached. - * - * @return A message publication that wraps up the publication request - */ @Override - public void publishAsync(Object message, long timeout, TimeUnit unit) { + public void publishAsync(long timeout, TimeUnit unit, Object message) { try { this.pendingMessages.offer(message, timeout, unit); } catch (InterruptedException e) { diff --git a/src/main/java/net/engio/mbassy/PubSubSupport.java b/src/main/java/net/engio/mbassy/PubSubSupport.java index ae57cd6..b6bf8aa 100644 --- a/src/main/java/net/engio/mbassy/PubSubSupport.java +++ b/src/main/java/net/engio/mbassy/PubSubSupport.java @@ -12,7 +12,7 @@ public interface PubSubSupport { /** * Subscribe all handlers of the given listener. Any listener is only subscribed once - * -> subsequent subscriptions of an already subscribed listener will be silently ignored + * subsequent subscriptions of an already subscribed listener will be silently ignored * * @param listener */ @@ -22,7 +22,7 @@ public interface PubSubSupport { * 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 messages (provided that running publications (iterators) in other threads * have not yet obtained a reference to the listener) - *

+ *

* A call to this method passing any object that is not subscribed will not have any effect and is silently ignored. * * @param listener @@ -34,30 +34,129 @@ public interface PubSubSupport { /** * Synchronously publish a message to all registered listeners. This includes listeners defined for super types of the - * given message type, provided they are not configured to reject valid subtype. The call returns when all matching handlers + * given message type, provided they are not configured to reject valid subtypes. The call returns when all matching handlers * of all registered listeners have been notified (invoked) of the message. - * - * @param message */ void publish(Object message); +// /** +// * Synchronously publish TWO messages to all registered listeners (that match the signature). This includes listeners +// * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call +// * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. +// */ +// void publish(Object message1, Object message2); +// +// /** +// * Synchronously publish THREE messages to all registered listeners (that match the signature). This includes listeners +// * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call +// * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. +// */ +// void publish(Object message1, Object message2, Object message3); +// +// /** +// * Synchronously publish ARBITRARY messages to all registered listeners (that match the signature). This includes listeners +// * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call +// * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. +// */ +// void publish(Object... messages); + + + /** - * Execute the message publication asynchronously. The behavior of this method depends on the - * configured queuing strategy: - *

+ * Publish the message asynchronously to all registered listeners (that match the signature). This includes listeners + * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call + * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. + *

+ * The behavior of this method depends on the configured queuing strategy: + *

* If an unbound queuing strategy is used the call returns immediately. * If a bounded queue is used the call might block until the message can be placed in the queue. */ void publishAsync(Object message); +// /** +// * Publish TWO messages asynchronously to all registered listeners (that match the signature). This includes listeners +// * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call +// * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. +// *

+// * The behavior of this method depends on the configured queuing strategy: +// *

+// * If an unbound queuing strategy is used the call returns immediately. +// * If a bounded queue is used the call might block until the message can be placed in the queue. +// */ +// void publishAsync(Object message1, Object message2); +// +// /** +// * Publish THREE messages asynchronously to all registered listeners (that match the signature). This includes listeners +// * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call +// * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. +// *

+// * The behavior of this method depends on the configured queuing strategy: +// *

+// * If an unbound queuing strategy is used the call returns immediately. +// * If a bounded queue is used the call might block until the message can be placed in the queue. +// */ +// void publishAsync(Object message1, Object message2, Object message3); +// +// /** +// * Publish ARBITRARY messages asynchronously to all registered listeners (that match the signature). This includes listeners +// * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call +// * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. +// *

+// * The behavior of this method depends on the configured queuing strategy: +// *

+// * If an unbound queuing strategy is used the call returns immediately. +// * If a bounded queue is used the call might block until the message can be placed in the queue. +// */ +// void publishAsync(Object... messages); + + /** - * Execute the message publication asynchronously. The behavior of this method depends on the - * configured queuing strategy: - *

+ * Publish the message asynchronously to all registered listeners (that match the signature). This includes listeners + * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call + * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. + *

+ * The behavior of this method depends on the configured queuing strategy: + *

* If an unbound queuing strategy is used the call returns immediately. - * If a bounded queue is used the call will block until the message can be placed in the queue - * or the timeout is reached. + * If a bounded queue is used the call might block until the message can be placed in the queue or the timeout is reached. */ - void publishAsync(Object message, long timeout, TimeUnit unit); + void publishAsync(long timeout, TimeUnit unit, Object message); + +// /** +// * Publish TWO messages asynchronously to all registered listeners (that match the signature). This includes listeners +// * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call +// * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. +// *

+// * The behavior of this method depends on the configured queuing strategy: +// *

+// * If an unbound queuing strategy is used the call returns immediately. +// * If a bounded queue is used the call might block until the message can be placed in the queue or the timeout is reached. +// */ +// void publishAsync(long timeout, TimeUnit unit, Object message1, Object message2); +// +// /** +// * Publish THREE messages asynchronously to all registered listeners (that match the signature). This includes listeners +// * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call +// * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. +// *

+// * The behavior of this method depends on the configured queuing strategy: +// *

+// * If an unbound queuing strategy is used the call returns immediately. +// * If a bounded queue is used the call might block until the message can be placed in the queue or the timeout is reached. +// */ +// void publishAsync(long timeout, TimeUnit unit, Object message1, Object message2, Object message3); +// +// /** +// * Publish ARBITRARY messages asynchronously to all registered listeners (that match the signature). This includes listeners +// * defined for super types of the given message type, provided they are not configured to reject valid subtypes. The call +// * returns when all matching handlers of all registered listeners have been notified (invoked) of the message. +// *

+// * The behavior of this method depends on the configured queuing strategy: +// *

+// * If an unbound queuing strategy is used the call returns immediately. +// * If a bounded queue is used the call might block until the message can be placed in the queue or the timeout is reached. +// */ +// void publishAsync(long timeout, TimeUnit unit, Object... messages); }