public class ClientMessageBusImpl extends Object implements ClientMessageBus
Modifier and Type | Field and Description |
---|---|
MessageCallback |
serverForwarder
Forwards every message received across the communication link to the remote
server bus.
|
Constructor and Description |
---|
ClientMessageBusImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addLifecycleListener(BusLifecycleListener l)
Adds the given listener instance to this bus.
|
void |
addSubscribeListener(SubscribeListener listener)
Adds a subscription listener, so it is possible to add subscriptions to the
client.
|
void |
addTransportErrorHandler(TransportErrorHandler errorHandler)
Adds a global transport error handler to deal with any errors which arise
from communication between the bus and the server.
|
void |
addUncaughtExceptionHandler(com.google.gwt.core.client.GWT.UncaughtExceptionHandler handler) |
void |
addUnsubscribeListener(UnsubscribeListener listener)
Adds an unsubscribe listener, so it is possible for applications to remove
subscriptions from the client
|
void |
attachMonitor(BusMonitor monitor)
Attach a monitor to the bus.
|
boolean |
callErrorHandler(Message message,
Throwable t) |
void |
clearProperties() |
void |
encodeAndTransmit(Message message) |
Collection<TransportHandler> |
getAllAvailableHandlers() |
Set<String> |
getAllRegisteredSubjects()
Returns a set of all reject subjects in the bus.
|
String |
getApplicationLocation(String serviceEntryPoint) |
String |
getClientId() |
String |
getInServiceEntryPoint() |
Set<String> |
getLocalServices() |
String |
getOutServiceEntryPoint() |
Set<String> |
getRemoteServices() |
String |
getSessionId() |
BusState |
getState() |
TransportHandler |
getTransportHandler() |
boolean |
handleTransportError(BusTransportError transportError) |
void |
init()
Takes this message bus from the LOCAL_ONLY state into the CONNECTING state,
as long as remote communication is enabled.
|
boolean |
isSubscribed(String subject)
Checks if subject is already listed in the subscriptions map
|
void |
reconsiderTransport()
When called, the MessageBus assumes that the currently active transport is no longer capable of operating.
|
void |
removeAllUncaughtExceptionHandlers() |
void |
removeLifecycleListener(BusLifecycleListener l)
Removes the given listener from this bus.
|
void |
removeTransportErrorHandler(TransportErrorHandler errorHandler)
Removes the given global transport error handler from this bus.
|
void |
removeUncaughtExceptionHandler(com.google.gwt.core.client.GWT.UncaughtExceptionHandler handler) |
void |
send(Message message)
Sends the message using it's encoded subject.
|
void |
send(Message message,
boolean fireListeners)
Sends the specified message, and notifies the listeners.
|
void |
sendGlobal(Message message)
Globally send message to all receivers.
|
void |
sendLocal(Message msg)
Delivers the given message to all local callbacks that subscribe to its
subject.
|
void |
setProperty(String name,
String value)
Sets a property on the bus.
|
void |
setState(BusState newState)
Puts the bus in the given state, firing all necessary transition events with no reason field.
|
void |
stop(boolean sendDisconnect)
Takes this bus into the "local only" state.
|
Subscription |
subscribe(String subject,
MessageCallback callback)
Add a subscription for the specified subject
|
Subscription |
subscribeLocal(String subject,
MessageCallback callback)
Subscribe a listern locally, but do not advertise or make available the service to remote buses.
|
Subscription |
subscribeShadow(String subject,
MessageCallback callback)
Declares a new shadow subscription.
|
void |
unsubscribeAll(String subject)
Removes all subscriptions attached to the specified subject
|
public final MessageCallback serverForwarder
One instance of this callback can be subscribed to any number of subjects simultaneously.
public void init()
init
in interface ClientMessageBus
BusToolsCli.isRemoteCommunicationEnabled()
,
BusLifecycleListener
public void stop(boolean sendDisconnect)
ClientMessageBus
stop
in interface ClientMessageBus
sendDisconnect
- if true, the server will be notified that we are breaking the
connection. Else, no attempt will be made to notify the server.public String getClientId()
public String getSessionId()
public void unsubscribeAll(String subject)
unsubscribeAll
in interface MessageBus
subject
- - the subject to have all it's subscriptions removedpublic Subscription subscribe(String subject, MessageCallback callback)
subscribe
in interface MessageBus
subject
- - the subject to add a subscription forcallback
- - function called when the message is dispatchedpublic Subscription subscribeLocal(String subject, MessageCallback callback)
MessageBus
subscribeLocal
in interface MessageBus
public Subscription subscribeShadow(String subject, MessageCallback callback)
ClientMessageBus
When a message is sent by an application component to a remote service while the bus is physically disconnected from the server, the bus will consider shadow subscriptions with a matching subject name to deliver the message to.
Shadow subscriptions are considered routable in all bus states except CONNECTING.
subscribeShadow
in interface ClientMessageBus
subject
- the subject name.public void sendGlobal(Message message)
sendGlobal
in interface MessageBus
message
- - The message to be sent.public void send(Message message, boolean fireListeners)
send
in interface MessageBus
message
- - the message to be sentfireListeners
- - true if the appropriate listeners should be firedpublic void send(Message message)
send
in interface MessageBus
message
- -RuntimeException
- - if message does not contain a ToSubject field or if the
message's callback throws an error.public void sendLocal(Message msg)
ClientMessageBus
sendLocal
in interface ClientMessageBus
msg
- The message to deliver to local subscribers.public void encodeAndTransmit(Message message)
public boolean isSubscribed(String subject)
isSubscribed
in interface MessageBus
subject
- subject to look forpublic boolean handleTransportError(BusTransportError transportError)
public void addSubscribeListener(SubscribeListener listener)
addSubscribeListener
in interface MessageBus
listener
- subscription listenerpublic void addUnsubscribeListener(UnsubscribeListener listener)
addUnsubscribeListener
in interface MessageBus
listener
- - unsubscribe listenerpublic void reconsiderTransport()
public void attachMonitor(BusMonitor monitor)
MessageBus
attachMonitor
in interface MessageBus
public Set<String> getAllRegisteredSubjects()
ClientMessageBus
getAllRegisteredSubjects
in interface ClientMessageBus
public void addTransportErrorHandler(TransportErrorHandler errorHandler)
ClientMessageBus
addTransportErrorHandler
in interface ClientMessageBus
errorHandler
- the error handler to add.public void removeTransportErrorHandler(TransportErrorHandler errorHandler)
ClientMessageBus
removeTransportErrorHandler
in interface ClientMessageBus
errorHandler
- the error handler to remove. This method has no effect if the
given handler is null
or it was not already registered.public BusState getState()
public String getOutServiceEntryPoint()
public String getInServiceEntryPoint()
public void addLifecycleListener(BusLifecycleListener l)
ClientMessageBus
addLifecycleListener
in interface ClientMessageBus
l
- The listener that wants to receive lifecycle notifications. Must
not be null. If the same listener is added more than once, it will
receive the corresponding number of callbacks upon each lifecycle
event.public void removeLifecycleListener(BusLifecycleListener l)
ClientMessageBus
removeLifecycleListener
in interface ClientMessageBus
l
- The listener to remove. If the listener was added more than one
time, removing it will decrease by one the number of notifications
that listener receices for each event. If the listener was not
already registered to receive events, this method has no effect.public TransportHandler getTransportHandler()
public Collection<TransportHandler> getAllAvailableHandlers()
public void setProperty(String name, String value)
ClientMessageBus
setProperty
in interface ClientMessageBus
name
- the property namevalue
- the property valuepublic void clearProperties()
clearProperties
in interface ClientMessageBus
public void setState(BusState newState)
public void addUncaughtExceptionHandler(com.google.gwt.core.client.GWT.UncaughtExceptionHandler handler)
public void removeUncaughtExceptionHandler(com.google.gwt.core.client.GWT.UncaughtExceptionHandler handler)
public void removeAllUncaughtExceptionHandlers()
Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.