Package com.iizix.server
Class AbstractEndPoint
java.lang.Object
com.iizix.server.AbstractEndPoint
- All Implemented Interfaces:
- IServerWebSocketCommListener,- ITransactionCreator,- WebSocketCommListener,- IEndPoint,- IRootPropTransactionSender
- Direct Known Subclasses:
- LoadBalancerEndPoint,- RemoteBuilderEndPoint,- ServerSession,- VirtualizedMonitorEndPoint
public abstract class AbstractEndPoint extends Object implements IEndPoint, IServerWebSocketCommListener, IRootPropTransactionSender
An implementation of a common end point for an Editor, Server or Monitor.
- Author:
- Christopher Mindus
- Nested Class Summary- Nested classes/interfaces inherited from interface com.iizix.server.IEndPoint- IEndPoint.Type
- Field SummaryFieldsModifier and TypeFieldDescription- protected booleanDebug mode, very verbose output.- protected final PropMgrThe property endPointPropertyManager.- protected final IEndPoint.TypeThe end-point type.- protected final StringThe name of this end point.- protected RootPropTransactionSenderRoot property transaction sender.- protected PropCnrThe root container property of the end point.- protected final ServerShellThe main server instance.- protected final longThe server session ID.- protected final SessionInfoThe SessionInfo.- protected final ThreadGroupThe thread group for the end point.- protected final WorkerThe worker of the Editor.- Fields inherited from interface com.iizix.server.IEndPoint- DEFAULT_HEARTBEAT_INTERVAL, STORAGE_NAME- Fields inherited from interface com.iizix.nio.WebSocketCommListener- CC_ABNORMAL_CLOSURE, CC_GOING_AWAY, CC_INTERNAL_ERROR, CC_INVALID_PAYLOAD_DATA, CC_MANDATORY_EXT, CC_MESSAGE_TOO_BIG, CC_NO_STATUS_RECEIVED, CC_NORMAL, CC_POLICY_VIOLATION, CC_PROTOCOL_ERROR, CC_SERVICE_RESTART, CC_TLS_HANDSHAKE, CC_TRY_AGAIN_LATER, CC_UNSUPPORTED_DATA
- Constructor SummaryConstructorsConstructorDescription- AbstractEndPoint- (IEndPoint.Type endPointType, String name, long sessionID, IWebSocketComm comm, ServerShell server, ThreadGroup serverThreadGroup, HashMap<String, - String> classNameMap, ClassLoader contextClassLoader) Creates a new EndPoint instance.
- Method SummaryModifier and TypeMethodDescription- final SendTransactionCreates a Transaction using a Write Cache.- boolean- dispose()Disposes of the end point.- getClientContextMenuReference- (UIContextMenu contextMenu) Gets the reference to use for a context menu.- final IEndPointGets the end-point.Gets the end point name.- final IEndPoint.TypeGets the end point type.- protected longGets the heart-beat interval time in milliseconds, called during start-up in the constructor.- final PropCnrGets the end point properties, i.e.- final PropMgrGets the property manager of the end point.- final ServerShellGets the server.- final longGets the Server Session ID.- final SessionInfoGets the SessionInfo for this end point.Gets the WebSocketCommListener for the end point.- final booleanChecks if the communication link is connected.- protected void- onClientPropsCreated- (PropCnr root) Called when the root is created from a transaction from the client.- void- onCommClosed- (IWebSocketComm comm, int code, String reason) Called when the communication link is closed.- void- onCommClosing- (IWebSocketComm comm) Called when the communication link is closing.- voidCalled when the communication link is connected.- void- onCommData- (IWebSocketComm comm, byte[] _data, int offset, int len) Called when the communication link has received binary data.- void- onCommData- (IWebSocketComm comm, String data) Called when the communication link has received String data.- void- onCommError- (IWebSocketComm comm, Throwable e) Called when the communication link is closed.- void- onCommHeartBeat- (IWebSocketComm comm, long duration) Called when a heart-beat frame is received.- void- onCommOpen- (IWebSocketComm comm) Called when the communication link is opened.- void- onCommTimeout- (IWebSocketComm comm, boolean isReadTimeout) Called when the communication link has timed out on a read or write operation.- protected voidCalled to perform sending of a heart-beat.- protected voidCalled upon connect to enable initialization of e.g.- protected StringFormats the value as a string to add to- paramString.- protected abstract boolean- processQueuedTransaction- (int code, ReadTransaction trans) This method must be implemented in all extending classes.- final void- sendTransaction- (SendTransaction trans) Sends a transaction to the end point.- toString()Returns a string representation of this component and its values.
- Field Details- DEBUGprotected boolean DEBUGDebug mode, very verbose output.
- serverSessionIDprotected final long serverSessionIDThe server session ID.
- nameThe name of this end point.
- workerThe worker of the Editor.
- serverThe main server instance.
- sessionInfoThe SessionInfo.
- threadGroupThe thread group for the end point.
- endPointTypeThe end-point type.
- endPointPropertyManagerThe property endPointPropertyManager.
- rootThe root container property of the end point.
- propTransSenderRoot property transaction sender.
 
- Constructor Details- AbstractEndPointpublic AbstractEndPoint- (IEndPoint.Type endPointType, String name, long sessionID, IWebSocketComm comm, ServerShell server, ThreadGroup serverThreadGroup, HashMap<String, - String> classNameMap, ClassLoader contextClassLoader) throws IOExceptionCreates a new EndPoint instance.- Parameters:
- endPointType- End point type.
- name- Name of end point.
- sessionID- Session ID.
- comm- Communications interface to web sockets.
- server- The server instance.
- serverThreadGroup- The thread group.
- classNameMap- The class name map.
- contextClassLoader- The context class loader.
- Throws:
- IOException- For I/O errors.
 
 
- Method Details- getEndPointGets the end-point.- Specified by:
- getEndPointin interface- IServerWebSocketCommListener
- Returns:
- An instance of com.iizix.server.IEndPoint.
 
- getServerSessionIDpublic final long getServerSessionID()Gets the Server Session ID.- Specified by:
- getServerSessionIDin interface- IEndPoint
- Returns:
- The session ID.
 
- getServerGets the server.
- getWebSocketCommListenerGets the WebSocketCommListener for the end point.- Specified by:
- getWebSocketCommListenerin interface- IEndPoint
- Parameters:
- comm- The WebSocket communication instance.
- Returns:
- The WebSocket listener.
 
- getEndPointTypeGets the end point type.- Specified by:
- getEndPointTypein interface- IEndPoint
- Returns:
- The endpoint type.
 
- getEndPointNameGets the end point name.- Specified by:
- getEndPointNamein interface- IEndPoint
- Returns:
- A short descriptive end-point type name.
 
- getHeartBeatIntervalprotected long getHeartBeatInterval()Gets the heart-beat interval time in milliseconds, called during start-up in the constructor.- Returns:
- Interval in milliseconds, zero for none (default is DEFAULT_HEARTBEAT_INTERVAL, i.e. 20 seconds).
 
- onSendHeartHeatprotected void onSendHeartHeat()Called to perform sending of a heart-beat. Override if required. This method is called at regular intervals as specified by the- getHeartBeatInterval()return value.
- onSessionConnectedprotected void onSessionConnected()Called upon connect to enable initialization of e.g. the root property. This method is overridden by subclasses and the base EndPoint implementation does nothing.
- getPropertyManagerGets the property manager of the end point. The property manager for an end point is always of SERVER type.- Returns:
- The singleton PropMgr instance.
 
- getPropertiesGets the end point properties, i.e. the root container.- Returns:
- The root container.
 
- getSessionInfoGets the SessionInfo for this end point.- Specified by:
- getSessionInfoin interface- IEndPoint
- Returns:
- The SessionInfo instance.
 
- disposepublic boolean dispose()Disposes of the end point.
- onCommOpenCalled when the communication link is opened.- Specified by:
- onCommOpenin interface- WebSocketCommListener
- Parameters:
- comm- The WebSocket communication instance.
 
- onCommConnectedCalled when the communication link is connected. The endpoint starts by sending a CREATE transaction of the endpoint root property container.- Specified by:
- onCommConnectedin interface- WebSocketCommListener
- Parameters:
- comm- The WebSocket communication instance.
 
- onCommDataCalled when the communication link has received binary data.- Specified by:
- onCommDatain interface- WebSocketCommListener
- Parameters:
- comm- The WebSocket communication instance.
- _data- The data byte array.
- offset- Offset in buffer.
- len- Length of data.
 
- onCommDataCalled when the communication link has received String data.- Specified by:
- onCommDatain interface- WebSocketCommListener
- Parameters:
- comm- The WebSocket communication instance.
- data- The String data.
 
- onCommHeartBeatCalled when a heart-beat frame is received.- Specified by:
- onCommHeartBeatin interface- WebSocketCommListener
- Parameters:
- duration- Duration of the PING-PONG message exchange in milliseconds.
- comm- The WebSocket communication instance.
 
- onCommTimeoutCalled when the communication link has timed out on a read or write operation.- Specified by:
- onCommTimeoutin interface- WebSocketCommListener
- Parameters:
- comm- The WebSocket communication instance.
- isReadTimeout- Flag indicating read timeout when true, false indicates write timeout.
 
- onCommErrorCalled when the communication link is closed.- Specified by:
- onCommErrorin interface- WebSocketCommListener
- Parameters:
- comm- The WebSocket communication instance.
- e- The exception.
 
- onCommClosingCalled when the communication link is closing.- Specified by:
- onCommClosingin interface- WebSocketCommListener
- Parameters:
- comm- The WebSocket communication instance.
 
- onCommClosedCalled when the communication link is closed.- Specified by:
- onCommClosedin interface- WebSocketCommListener
- Parameters:
- comm- The WebSocket communication instance.
- code- The reason code for closure.
- reason- The reason string explanation for closure.
 
- onClientPropsCreatedCalled when the root is created from a transaction from the client. Override to perform some additional processing such as adding server environment, etc.
- processQueuedTransactionThis method must be implemented in all extending classes.- Parameters:
- code- The transaction code.
- trans- The transaction.
- Returns:
- true if the transaction has been processed, false otherwise.
 
- isConnectedpublic final boolean isConnected()Checks if the communication link is connected.- Specified by:
- isConnectedin interface- IRootPropTransactionSender
- Returns:
- true if the connection has been established, false if closed or if in progress of closing.
 
- createTransactionCreates a Transaction using a Write Cache. This transaction is then used to write data into it. Be careful only to do it from a single thread as the Write Cache is not thread-safe!- Specified by:
- createTransactionin interface- ITransactionCreator
- Returns:
- The transaction with the WriteCache with parameters specified in the properties.
 
- sendTransactionSends a transaction to the end point.- Specified by:
- sendTransactionin interface- IRootPropTransactionSender
- Parameters:
- trans- The transaction to send.
 
- paramStringFormats the value as a string to add to- paramString.- Returns:
- String format of the parameters.
 
- toStringReturns a string representation of this component and its values.
- getClientContextMenuReferenceGets the reference to use for a context menu. Override to process.- Specified by:
- getClientContextMenuReferencein interface- IRootPropTransactionSender
- Parameters:
- contextMenu- The context menu.
- Returns:
- The reference to use, empty string for none (never null).