Class AbstractServerTransport
- java.lang.Object
-
- org.cometd.common.AbstractTransport
-
- org.cometd.server.AbstractServerTransport
-
- All Implemented Interfaces:
org.cometd.bayeux.server.ServerTransport,org.cometd.bayeux.Transport,org.eclipse.jetty.util.component.Dumpable
- Direct Known Subclasses:
AbstractHttpTransport
public abstract class AbstractServerTransport extends org.cometd.common.AbstractTransport implements org.cometd.bayeux.server.ServerTransport, org.eclipse.jetty.util.component.DumpableThe 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 theinit(), each transport should call the variants ofAbstractTransport.getOption(String)to obtained the configured value for the option.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAbstractServerTransport.Scheduler
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger_loggerstatic java.lang.StringALLOW_MESSAGE_DELIVERY_DURING_HANDSHAKEstatic java.lang.StringHANDSHAKE_RECONNECT_OPTIONstatic java.lang.StringINTERVAL_OPTIONstatic java.lang.StringJSON_CONTEXT_OPTIONstatic java.lang.StringMAX_INTERVAL_OPTIONstatic java.lang.StringMAX_LAZY_TIMEOUT_OPTIONstatic java.lang.StringMAX_MESSAGE_SIZE_OPTIONstatic java.lang.StringMAX_PROCESSING_OPTIONstatic java.lang.StringMAX_QUEUE_OPTIONstatic java.lang.StringMETA_CONNECT_DELIVERY_OPTIONstatic java.lang.StringTIMEOUT_OPTION
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractServerTransport(BayeuxServerImpl bayeux, java.lang.String name)The constructor is passed theBayeuxServerImplinstance for the transport.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanallowMessageDeliveryDuringHandshake(ServerSessionImpl session)voiddestroy()java.lang.Stringdump()voiddump(java.lang.Appendable out, java.lang.String indent)java.lang.ObjectgetAdvice()BayeuxServerImplgetBayeux()longgetInterval()longgetMaxInterval()longgetMaxLazyTimeout()intgetMaxMessageSize()longgetTimeout()voidinit()Initializes the transport, resolving default and direct options.booleanisAllowMessageDeliveryDuringHandshake()booleanisHandshakeReconnect()booleanisMetaConnectDeliveryOnly()protected org.cometd.bayeux.server.ServerMessage.Mutable[]parseMessages(java.io.BufferedReader reader, boolean jsonDebug)protected org.cometd.bayeux.server.ServerMessage.Mutable[]parseMessages(java.lang.String json)protected org.cometd.bayeux.server.ServerMessage.MutableprocessReply(ServerSessionImpl session, org.cometd.bayeux.server.ServerMessage.Mutable reply)protected voidscheduleExpiration(ServerSessionImpl session)voidsetAllowMessageDeliveryDuringHandshake(boolean allow)voidsetHandshakeReconnect(boolean handshakeReconnect)voidsetInterval(long interval)voidsetMaxInterval(long maxInterval)voidsetMaxLazyTimeout(long maxLazyTimeout)voidsetMaxMessageSize(int maxMessageSize)voidsetMetaConnectDeliveryOnly(boolean meta)voidsetTimeout(long timeout)protected voidsweep()Housekeeping sweep, called a regular intervalsprotected byte[]toJSONBytes(org.cometd.bayeux.server.ServerMessage message, java.lang.String encoding)java.lang.StringtoString()-
Methods inherited from class org.cometd.common.AbstractTransport
getName, getOption, getOption, getOption, getOption, getOption, getOptionNames, getOptionPrefix, setOption, setOptionPrefix
-
-
-
-
Field Detail
-
TIMEOUT_OPTION
public static final java.lang.String TIMEOUT_OPTION
- See Also:
- Constant Field Values
-
INTERVAL_OPTION
public static final java.lang.String INTERVAL_OPTION
- See Also:
- Constant Field Values
-
MAX_INTERVAL_OPTION
public static final java.lang.String MAX_INTERVAL_OPTION
- See Also:
- Constant Field Values
-
MAX_PROCESSING_OPTION
public static final java.lang.String MAX_PROCESSING_OPTION
- See Also:
- Constant Field Values
-
MAX_LAZY_TIMEOUT_OPTION
public static final java.lang.String MAX_LAZY_TIMEOUT_OPTION
- See Also:
- Constant Field Values
-
META_CONNECT_DELIVERY_OPTION
public static final java.lang.String META_CONNECT_DELIVERY_OPTION
- See Also:
- Constant Field Values
-
MAX_QUEUE_OPTION
public static final java.lang.String MAX_QUEUE_OPTION
- See Also:
- Constant Field Values
-
JSON_CONTEXT_OPTION
public static final java.lang.String JSON_CONTEXT_OPTION
- See Also:
- Constant Field Values
-
HANDSHAKE_RECONNECT_OPTION
public static final java.lang.String HANDSHAKE_RECONNECT_OPTION
- See Also:
- Constant Field Values
-
ALLOW_MESSAGE_DELIVERY_DURING_HANDSHAKE
public static final java.lang.String ALLOW_MESSAGE_DELIVERY_DURING_HANDSHAKE
- See Also:
- Constant Field Values
-
MAX_MESSAGE_SIZE_OPTION
public static final java.lang.String MAX_MESSAGE_SIZE_OPTION
- See Also:
- Constant Field Values
-
_logger
protected final org.slf4j.Logger _logger
-
-
Constructor Detail
-
AbstractServerTransport
protected AbstractServerTransport(BayeuxServerImpl bayeux, java.lang.String name)
The constructor is passed the
BayeuxServerImplinstance 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 Detail
-
getAdvice
public java.lang.Object getAdvice()
- Specified by:
getAdvicein interfaceorg.cometd.bayeux.server.ServerTransport
-
getInterval
public long getInterval()
- Specified by:
getIntervalin interfaceorg.cometd.bayeux.server.ServerTransport- Returns:
- the interval in milliseconds
-
getMaxInterval
public long getMaxInterval()
- Specified by:
getMaxIntervalin interfaceorg.cometd.bayeux.server.ServerTransport- Returns:
- the maxInterval in milliseconds
-
getMaxLazyTimeout
public long getMaxLazyTimeout()
- Specified by:
getMaxLazyTimeoutin interfaceorg.cometd.bayeux.server.ServerTransport- Returns:
- the max lazy timeout in milliseconds before flushing lazy messages
-
getTimeout
public long getTimeout()
- Specified by:
getTimeoutin interfaceorg.cometd.bayeux.server.ServerTransport- Returns:
- the timeout in milliseconds
-
isMetaConnectDeliveryOnly
public boolean isMetaConnectDeliveryOnly()
- Specified by:
isMetaConnectDeliveryOnlyin interfaceorg.cometd.bayeux.server.ServerTransport
-
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 org.cometd.bayeux.server.ServerMessage.Mutable[] parseMessages(java.io.BufferedReader reader, boolean jsonDebug) throws java.text.ParseException, java.io.IOException- Throws:
java.text.ParseExceptionjava.io.IOException
-
parseMessages
protected org.cometd.bayeux.server.ServerMessage.Mutable[] parseMessages(java.lang.String json) throws java.text.ParseException- Throws:
java.text.ParseException
-
getBayeux
public BayeuxServerImpl 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 org.cometd.bayeux.server.ServerMessage.Mutable processReply(ServerSessionImpl session, org.cometd.bayeux.server.ServerMessage.Mutable reply)
-
toJSONBytes
protected byte[] toJSONBytes(org.cometd.bayeux.server.ServerMessage message, java.lang.String encoding)
-
allowMessageDeliveryDuringHandshake
protected boolean allowMessageDeliveryDuringHandshake(ServerSessionImpl session)
-
scheduleExpiration
protected void scheduleExpiration(ServerSessionImpl session)
-
dump
public java.lang.String dump()
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-