Package net.sf.eBus.client
Class ERequestMonitorFeed.Builder
- java.lang.Object
-
- net.sf.eBus.client.EFeed.Builder<F,T,B>
-
- net.sf.eBus.client.ERequestMonitorFeed.Builder
-
- Enclosing class:
- ERequestMonitorFeed
public static final class ERequestMonitorFeed.Builder extends EFeed.Builder<F,T,B>
ERequestMonitorFeed.Builder
is used to create anERequestMonitorFeed
instance. ABuilder
instance is acquired fromERequestMonitorFeed.builder()
. The following example shows how to create aERequestMonitorFeed
instance using aBuilder
. The example also shows howERequestMonitor
interface methods may be replaced with lambda expressions.@Override public void startup() { final EMessageKey = new EMessageKey(com.acme.CatalogOrder.class, subject); final ERequestMonitorFeed feed (ERequestMonitorFeed.builder()).target(this) .messageKey(key) .requestCallback(this::onRequest) .replyCallback(this::onReply) .cancelCallback(this::onCancel) .build(); ... } private void onRequest(final ERequestMessage request, final String replier) { ... } private void onReply(final EReplyMessage reply, final String replier) { ... } private void onCancel(final ERequestMessage request, final String replier) { ... }
- See Also:
ERequestMonitorFeed.builder()
-
-
Field Summary
-
Fields inherited from class net.sf.eBus.client.EFeed.Builder
mEClient, mLocation, mScope, mTarget, mTargetClass
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ERequestMonitorFeed
buildImpl()
Returns a newERequestMonitorFeed
instance based onthis Builder
's configuration.ERequestMonitorFeed.Builder
cancelCallback(MessageCallback<ERequestMessage> cb)
Puts inbound request cancellation callback in place.protected net.sf.eBus.client.ESubject
getSubject()
Returns eBus subject for the configured message key.ERequestMonitorFeed.Builder
replyCallback(MessageCallback<EReplyMessage> cb)
Puts outbound reply callback in place.ERequestMonitorFeed.Builder
requestCallback(MessageCallback<ERequestMessage> cb)
Puts inbound request callback in place.ERequestMonitorFeed.Builder
scope(EFeed.FeedScope scope)
ThrowsUnsupportedOperationException
because request monitor feeds have local-only scope which may not be overridden.protected ERequestMonitorFeed.Builder
self()
Returnsthis Builder
reference.protected Validator
validate(Validator problems)
Verifies that message key is for a request subject and that both request and reply callbacks are set.-
Methods inherited from class net.sf.eBus.client.EFeed.Builder
build, isOverridden, target
-
-
-
-
Method Detail
-
getSubject
protected net.sf.eBus.client.ESubject getSubject()
Returns eBus subject for the configured message key.- Returns:
- eBus feed subject.
-
validate
protected Validator validate(Validator problems)
Verifies that message key is for a request subject and that both request and reply callbacks are set.- Parameters:
problems
- place invalid configuration settings in this problems list.- Returns:
problems
to allow for method chaining.
-
buildImpl
protected ERequestMonitorFeed buildImpl()
Returns a newERequestMonitorFeed
instance based onthis Builder
's configuration.- Specified by:
buildImpl
in classEFeed.Builder<ERequestMonitorFeed,ERequestMonitor,ERequestMonitorFeed.Builder>
- Returns:
- new request monitor feed.
-
self
protected ERequestMonitorFeed.Builder self()
Returnsthis Builder
reference.- Specified by:
self
in classEFeed.Builder<ERequestMonitorFeed,ERequestMonitor,ERequestMonitorFeed.Builder>
- Returns:
this Builder
reference.
-
scope
public ERequestMonitorFeed.Builder scope(EFeed.FeedScope scope)
ThrowsUnsupportedOperationException
because request monitor feeds have local-only scope which may not be overridden.- Overrides:
scope
in classEFeed.Builder<ERequestMonitorFeed,ERequestMonitor,ERequestMonitorFeed.Builder>
- Parameters:
scope
- feed scope.- Returns:
this Builder
instance.- Throws:
java.lang.UnsupportedOperationException
- default local-only feed scope may not be overridden.
-
requestCallback
public ERequestMonitorFeed.Builder requestCallback(@Nullable MessageCallback<ERequestMessage> cb)
Puts inbound request callback in place. Ifcb
is notnull
, requests will be passed tocb
rather thanERequestMonitor.request(ERequestMessage, String)
. Ifcb
isnull
, then request messages are passed to theERequestMonitor.request(ERequestMessage, String)
override.- Parameters:
cb
- request callback. May benull
.- Returns:
this Builder
instance.
-
replyCallback
public ERequestMonitorFeed.Builder replyCallback(@Nullable MessageCallback<EReplyMessage> cb)
Puts outbound reply callback in place. Ifcb
is notnull
, replies will be passed tocb
rather thanERequestMonitor.reply(EReplyMessage, String)
. Ifcb
isnull
, then reply messages are passed to theERequestMonitor.reply(EReplyMessage, String)
override.- Parameters:
cb
- reply callback. May benull
.- Returns:
this Builder
instance.
-
cancelCallback
public ERequestMonitorFeed.Builder cancelCallback(@Nullable MessageCallback<ERequestMessage> cb)
Puts inbound request cancellation callback in place. ifcb
is notnull
, cancellations will be passed tocb
rather thanERequestMonitor.cancel(ERequestMessage, String)
. Ifcb
isnull
, then request messages are passed to theERequestMonitor.cancel(ERequestMessage, String)
override.- Parameters:
cb
- cancellation callback. May benull
.- Returns:
this Builder
instance.
-
-