Errai 3.0.1-SNAPSHOT

org.jboss.errai.bus.client.framework.transports
Class HttpPollingHandler

java.lang.Object
  extended by org.jboss.errai.bus.client.framework.transports.HttpPollingHandler
All Implemented Interfaces:
TransportHandler, TransportStatistics

public class HttpPollingHandler
extends Object
implements TransportHandler, TransportStatistics

Author:
Mike Brock

Field Summary
static int POLL_FREQUENCY_MS
           
static int THROTTLE_TIME_MS
           
 
Fields inherited from interface org.jboss.errai.bus.client.framework.transports.TransportHandler
EXTRA_URI_PARMS_RESOURCE, UNSUPPORTED_MESSAGE_NO_CLIENT_SUPPORT, UNSUPPORTED_MESSAGE_NO_SERVER_SUPPORT
 
Method Summary
 void close()
          Permanently closes this transport handler.
 void configure(Message capabilitiesMessage)
          Called to configure the transport.
 long getConnectedTime()
           
 long getLastTransmissionTime()
           
 int getMeasuredLatency()
           
 int getMessagesReceived()
           
 int getMessagesSent()
           
 int getNextRequestNumber()
           
 int getPendingMessages()
           
 String getRxEndpoint()
           
 TransportStatistics getStatistics()
          Returns the TransportStatistics instance.
 String getTransportDescription()
           
 String getTxEndpoint()
           
 String getUnsupportedDescription()
           
 void handleProtocolExtension(Message message)
          Allows extension to the standard ErraiBus Protocol by optionally handling any unknown protocol verbs from the wire.
 boolean isCancelled()
           
 boolean isFullDuplex()
           
 boolean isUsable()
          Indicates whether the transport is usable.
static HttpPollingHandler newLongPollingInstance(ClientMessageBusImpl messageBus)
           
static HttpPollingHandler newNoPollingInstance(ClientMessageBusImpl messageBus)
           
static HttpPollingHandler newShortPollingInstance(ClientMessageBusImpl messageBus)
           
 void performPoll()
           
 com.google.gwt.http.client.Request sendPollingRequest(String payload, Map<String,String> extraParameters, com.google.gwt.http.client.RequestCallback callback)
          Sends the given string oon the outbound communication channel (as a POST request to the server).
 void start()
          Called to start the transport.
 Collection<Message> stop(boolean stopAllCurrentRequests)
          Called to stop the transport.
 String toString()
           
 void transmit(List<Message> txMessages)
          Transmits the specified list of Message to the remote bus over the transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

THROTTLE_TIME_MS

public static int THROTTLE_TIME_MS

POLL_FREQUENCY_MS

public static int POLL_FREQUENCY_MS
Method Detail

newLongPollingInstance

public static HttpPollingHandler newLongPollingInstance(ClientMessageBusImpl messageBus)

newShortPollingInstance

public static HttpPollingHandler newShortPollingInstance(ClientMessageBusImpl messageBus)

newNoPollingInstance

public static HttpPollingHandler newNoPollingInstance(ClientMessageBusImpl messageBus)

configure

public void configure(Message capabilitiesMessage)
Description copied from interface: TransportHandler
Called to configure the transport. The Message instance passed to the handler, is the initial response message from the server during the ErraiBus protocol handshake, which contains the capabilities data for the remote bus.

Specified by:
configure in interface TransportHandler
Parameters:
capabilitiesMessage - the capabilities message from the message bus on handshake.

isUsable

public boolean isUsable()
Description copied from interface: TransportHandler
Indicates whether the transport is usable. This method is called during transport switching by the bus to determine which transport to use. The first usable transport is chosen and started.

Specified by:
isUsable in interface TransportHandler
Returns:
true if the handler is usable.

start

public void start()
Description copied from interface: TransportHandler
Called to start the transport.

Specified by:
start in interface TransportHandler

transmit

public void transmit(List<Message> txMessages)
Description copied from interface: TransportHandler
Transmits the specified list of Message to the remote bus over the transport.

Specified by:
transmit in interface TransportHandler
Parameters:
txMessages - a list of Message to be transmitted.

performPoll

public void performPoll()

stop

public Collection<Message> stop(boolean stopAllCurrentRequests)
Description copied from interface: TransportHandler
Called to stop the transport.

Specified by:
stop in interface TransportHandler
Parameters:
stopAllCurrentRequests - specifying true will cause any in-flight messages which have not returned to be immediately cancelled.
Returns:
a list of messages which were not delivered before the transport was stopped.

isCancelled

public boolean isCancelled()

handleProtocolExtension

public void handleProtocolExtension(Message message)
Description copied from interface: TransportHandler
Allows extension to the standard ErraiBus Protocol by optionally handling any unknown protocol verbs from the wire.

Specified by:
handleProtocolExtension in interface TransportHandler

sendPollingRequest

public com.google.gwt.http.client.Request sendPollingRequest(String payload,
                                                             Map<String,String> extraParameters,
                                                             com.google.gwt.http.client.RequestCallback callback)
                                                      throws com.google.gwt.http.client.RequestException
Sends the given string oon the outbound communication channel (as a POST request to the server).

Parameters:
payload - The message to send. It is sent verbatim.
callback - The callback to receive success or error notification. Note that this callback IS NOT CALLED if the request is cancelled.
extraParameters - Extra paramets to include in the HTTP request (key is parameter name; value is parameter value).
Throws:
com.google.gwt.http.client.RequestException - if the request cannot be sent at all.

getNextRequestNumber

public int getNextRequestNumber()

toString

public String toString()
Overrides:
toString in class Object

getStatistics

public TransportStatistics getStatistics()
Description copied from interface: TransportHandler
Returns the TransportStatistics instance.

Specified by:
getStatistics in interface TransportHandler
Returns:

getTransportDescription

public String getTransportDescription()
Specified by:
getTransportDescription in interface TransportStatistics

getMessagesSent

public int getMessagesSent()
Specified by:
getMessagesSent in interface TransportStatistics

getMessagesReceived

public int getMessagesReceived()
Specified by:
getMessagesReceived in interface TransportStatistics

getConnectedTime

public long getConnectedTime()
Specified by:
getConnectedTime in interface TransportStatistics

getLastTransmissionTime

public long getLastTransmissionTime()
Specified by:
getLastTransmissionTime in interface TransportStatistics

getMeasuredLatency

public int getMeasuredLatency()
Specified by:
getMeasuredLatency in interface TransportStatistics

isFullDuplex

public boolean isFullDuplex()
Specified by:
isFullDuplex in interface TransportStatistics

getRxEndpoint

public String getRxEndpoint()
Specified by:
getRxEndpoint in interface TransportStatistics

getTxEndpoint

public String getTxEndpoint()
Specified by:
getTxEndpoint in interface TransportStatistics

getUnsupportedDescription

public String getUnsupportedDescription()
Specified by:
getUnsupportedDescription in interface TransportStatistics

getPendingMessages

public int getPendingMessages()
Specified by:
getPendingMessages in interface TransportStatistics

close

public void close()
Description copied from interface: TransportHandler
Permanently closes this transport handler. Once closed, a TransportHandler cannot be used again. It is imperative that a TransportHandler is closed when it is no longer needed; failing to do so may leak resources and lead to client bus malfunctions.

Specified by:
close in interface TransportHandler

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.