Class AbstractServerTransport
- All Implemented Interfaces:
ServerTransport
,Transport
,org.eclipse.jetty.util.component.Dumpable
- Direct Known Subclasses:
AbstractHttpTransport
,AbstractWebSocketTransport
public abstract class AbstractServerTransport extends AbstractTransport implements ServerTransport, org.eclipse.jetty.util.component.Dumpable
The base class of all server transports.
Each derived Transport class should declare all options that it supports
by calling AbstractTransport.setOption(String, Object)
for each option.
Then during the call the init()
, each transport should
call the variants of AbstractTransport.getOption(String)
to obtained the configured
value for the option.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractServerTransport.Scheduler
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
_logger
static String
ALLOW_MESSAGE_DELIVERY_DURING_HANDSHAKE
static String
HANDSHAKE_RECONNECT_OPTION
static String
INTERVAL_OPTION
static String
JSON_CONTEXT_OPTION
static String
MAX_INTERVAL_OPTION
static String
MAX_LAZY_TIMEOUT_OPTION
static String
MAX_MESSAGE_SIZE_OPTION
static String
MAX_PROCESSING_OPTION
static String
MAX_QUEUE_OPTION
static String
META_CONNECT_DELIVERY_OPTION
static String
TIMEOUT_OPTION
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractServerTransport(BayeuxServerImpl bayeux, String name)
The constructor is passed theBayeuxServerImpl
instance for the transport. -
Method Summary
Modifier and Type Method Description protected boolean
allowMessageDeliveryDuringHandshake(ServerSessionImpl session)
void
destroy()
String
dump()
void
dump(Appendable out, String indent)
Object
getAdvice()
The advice that this transport sends to inform the client about transport (re)connection.BayeuxServerImpl
getBayeux()
long
getInterval()
long
getMaxInterval()
long
getMaxLazyTimeout()
int
getMaxMessageSize()
long
getTimeout()
void
init()
Initializes the transport, resolving default and direct options.boolean
isAllowMessageDeliveryDuringHandshake()
boolean
isHandshakeReconnect()
boolean
isMetaConnectDeliveryOnly()
protected ServerMessage.Mutable[]
parseMessages(BufferedReader reader, boolean jsonDebug)
protected ServerMessage.Mutable[]
parseMessages(String json)
protected ServerMessage.Mutable
processReply(ServerSessionImpl session, ServerMessage.Mutable reply)
protected void
scheduleExpiration(ServerSessionImpl session)
void
setAllowMessageDeliveryDuringHandshake(boolean allow)
void
setHandshakeReconnect(boolean handshakeReconnect)
void
setInterval(long interval)
void
setMaxInterval(long maxInterval)
void
setMaxLazyTimeout(long maxLazyTimeout)
void
setMaxMessageSize(int maxMessageSize)
void
setMetaConnectDeliveryOnly(boolean meta)
void
setTimeout(long timeout)
protected void
sweep()
Housekeeping sweep, called a regular intervalsprotected byte[]
toJSONBytes(ServerMessage message, String encoding)
String
toString()
Methods inherited from class org.cometd.common.AbstractTransport
getName, getOption, getOption, getOption, getOption, getOption, getOptionNames, getOptionPrefix, setOption, setOptionPrefix
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.cometd.bayeux.Transport
getName, getOption, getOptionNames, getOptionPrefix
-
Field Details
-
TIMEOUT_OPTION
- See Also:
- Constant Field Values
-
INTERVAL_OPTION
- See Also:
- Constant Field Values
-
MAX_INTERVAL_OPTION
- See Also:
- Constant Field Values
-
MAX_PROCESSING_OPTION
- See Also:
- Constant Field Values
-
MAX_LAZY_TIMEOUT_OPTION
- See Also:
- Constant Field Values
-
META_CONNECT_DELIVERY_OPTION
- See Also:
- Constant Field Values
-
MAX_QUEUE_OPTION
- See Also:
- Constant Field Values
-
JSON_CONTEXT_OPTION
- See Also:
- Constant Field Values
-
HANDSHAKE_RECONNECT_OPTION
- See Also:
- Constant Field Values
-
ALLOW_MESSAGE_DELIVERY_DURING_HANDSHAKE
- See Also:
- Constant Field Values
-
MAX_MESSAGE_SIZE_OPTION
- See Also:
- Constant Field Values
-
_logger
protected final org.slf4j.Logger _logger
-
-
Constructor Details
-
AbstractServerTransport
The constructor is passed the
BayeuxServerImpl
instance for the transport. TheBayeuxServerImpl.getOptions()
map is populated with the default options known by this transport. The options are then inspected again wheninit()
is called, to set the actual values used. The options are arranged into a naming hierarchy by derived classes adding prefix by calling addAbstractTransport.setOptionPrefix(String)
. Calls toAbstractTransport.getOption(String)
will use the list of prefixes to search for the most specific option set.- Parameters:
bayeux
- the BayeuxServer implementationname
- the name of the transport
-
-
Method Details
-
getAdvice
Description copied from interface:ServerTransport
The advice that this transport sends to inform the client about transport (re)connection.
- Specified by:
getAdvice
in interfaceServerTransport
- Returns:
- the advice object sent by the server transport
-
getInterval
public long getInterval()- Specified by:
getInterval
in interfaceServerTransport
- Returns:
- the interval in milliseconds
-
getMaxInterval
public long getMaxInterval()- Specified by:
getMaxInterval
in interfaceServerTransport
- Returns:
- the maxInterval in milliseconds
-
getMaxLazyTimeout
public long getMaxLazyTimeout()- Specified by:
getMaxLazyTimeout
in interfaceServerTransport
- Returns:
- the max lazy timeout in milliseconds before flushing lazy messages
-
getTimeout
public long getTimeout()- Specified by:
getTimeout
in interfaceServerTransport
- Returns:
- the timeout in milliseconds
-
isMetaConnectDeliveryOnly
public boolean isMetaConnectDeliveryOnly()- Specified by:
isMetaConnectDeliveryOnly
in interfaceServerTransport
- Returns:
- whether the messages are delivered to clients exclusively via the "/meta/connect" channel
-
setMetaConnectDeliveryOnly
public void setMetaConnectDeliveryOnly(boolean meta) -
isHandshakeReconnect
public boolean isHandshakeReconnect() -
setHandshakeReconnect
public void setHandshakeReconnect(boolean handshakeReconnect) -
isAllowMessageDeliveryDuringHandshake
public boolean isAllowMessageDeliveryDuringHandshake() -
setAllowMessageDeliveryDuringHandshake
public void setAllowMessageDeliveryDuringHandshake(boolean allow) -
getMaxMessageSize
public int getMaxMessageSize() -
setMaxMessageSize
public void setMaxMessageSize(int maxMessageSize) -
init
public void init()Initializes the transport, resolving default and direct options. -
destroy
public void destroy() -
parseMessages
protected ServerMessage.Mutable[] parseMessages(BufferedReader reader, boolean jsonDebug) throws ParseException, IOException- Throws:
ParseException
IOException
-
parseMessages
- Throws:
ParseException
-
getBayeux
- Returns:
- the BayeuxServer object
-
setInterval
public void setInterval(long interval)- Parameters:
interval
- the interval in milliseconds
-
setMaxInterval
public void setMaxInterval(long maxInterval)- Parameters:
maxInterval
- the maxInterval in milliseconds
-
setTimeout
public void setTimeout(long timeout)- Parameters:
timeout
- the timeout in milliseconds
-
setMaxLazyTimeout
public void setMaxLazyTimeout(long maxLazyTimeout)- Parameters:
maxLazyTimeout
- the maxLazyTimeout in milliseconds
-
sweep
protected void sweep()Housekeeping sweep, called a regular intervals -
processReply
protected ServerMessage.Mutable processReply(ServerSessionImpl session, ServerMessage.Mutable reply) -
toJSONBytes
-
allowMessageDeliveryDuringHandshake
-
scheduleExpiration
-
dump
- Specified by:
dump
in interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
- Specified by:
dump
in interfaceorg.eclipse.jetty.util.component.Dumpable
- Throws:
IOException
-
toString
-