Package com.iizix.comm
Class TransactionComm
java.lang.Object
com.iizix.comm.TransactionComm
- All Implemented Interfaces:
- ITransactionCreator
Class to handle the Transaction protocol.
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescription- TransactionComm- (TransactionCommListener listener, int maxCount, int minLength, int maxLength, boolean isVerbose) Creates a new Transaction processor for the server-side web socket implementation for external web servers such as Jetty or GlassFish.- TransactionComm- (TransactionCommProps properties, Worker worker, TransactionCommListener listener, SSLEngine engine) Creates a new Transaction Client Communication channel as UNINITIALIZED.- TransactionComm- (TransactionCommProps properties, Worker worker, SocketChannel channel, TransactionCommListener listener, WebSocketAcceptor acceptor) Creates a new Transaction Client Communication channel from a socket channel.
- Method SummaryModifier and TypeMethodDescription- boolean- close()Call this method to close the socket.- voidCloses the connection with the close code and reason.- final SendTransactionCreates a Transaction using a Write Cache.- final ObjectGets the attachment object for this communication link.Gets the listener of the communications link.Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.Returns the fully qualified name of the client or the last proxy that sent the request.Returns the remote address to which this channel's socket is connected.- getState()Gets the state of the connection.- boolean- isClosed()Checks if the connection is disposed of.- booleanFlag for supporting software compression on client side.- booleanChecks if the connection is connected, i.e.- void- open()Opens the communication.- void- open- (boolean noTimeouts) Opens the communication.- int- send- (SendTransaction trans, boolean doCompress) Sends a transaction.- int- send- (SendTransaction trans, int serial, boolean doCompress) Sends a transaction.- booleanSends a heart-beat.- final void- setAttachment- (Object attachment) Sets the attachment object for this communication link.- setWebSocket- (IWebSocketComm comm, Object endPoint) Assigns the web socket interface and retrieves the listener for use with external web servers.
- Constructor Details- TransactionCommpublic TransactionComm- (TransactionCommListener listener, int maxCount, int minLength, int maxLength, boolean isVerbose) Creates a new Transaction processor for the server-side web socket implementation for external web servers such as Jetty or GlassFish.- Parameters:
- listener- Listener for transaction.
- maxCount- Maximum count of strings in the cache, zero = disable write cache: range 10-8192.
- minLength- The minimum length of a string in the cache: range 7 to 64.
- maxLength- The maximum length of a string in the cache: range minLength+1 to 256.
- isVerbose- Verbose tracing output flag.
 
- TransactionCommpublic TransactionComm- (TransactionCommProps properties, Worker worker, TransactionCommListener listener, SSLEngine engine) throws IOException Creates a new Transaction Client Communication channel as UNINITIALIZED.- Parameters:
- properties- The Transaction properties.
- worker- The worker thread for transaction processing.
- listener- The listener for Transaction events.
- engine- The SSL engine or null for plain connection.
- Throws:
- IOException- For SSL errors.
 
- TransactionCommpublic TransactionComm- (TransactionCommProps properties, Worker worker, SocketChannel channel, TransactionCommListener listener, WebSocketAcceptor acceptor) throws IOException Creates a new Transaction Client Communication channel from a socket channel.- Parameters:
- properties- The Transaction properties.
- worker- The worker thread for transaction processing.
- channel- The socket channel.
- listener- The listener for Transaction events.
- acceptor- The URI acceptor for WebSocket requests.
- Throws:
- IOException- For I/O exceptions.
 
 
- Method Details- setWebSocketAssigns the web socket interface and retrieves the listener for use with external web servers.- Parameters:
- comm- The comm instance.
- endPoint- The end point.
 
- 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.
 
- getAttachmentGets the attachment object for this communication link.- Returns:
- Object the attachment assigned by setAttachement(object) method, null for none.
 
- setAttachmentSets the attachment object for this communication link.- Parameters:
- attachment- The attachment to assign to this communication link or null for no attachment.
 
- openOpens the communication. Do not call this method when using an external web server.- Throws:
- IOException
 
- openOpens the communication. Do not call this method when using an external web server.- Parameters:
- noTimeouts- Connect with debug = no timeouts! This way we can set breakpoints in Eclipse.
- Throws:
- IOException
 
- isCompressionSupportedpublic boolean isCompressionSupported()Flag for supporting software compression on client side.- Returns:
- The support flag depending on the subProtocol chosen.
 
- getStateGets the state of the connection.- Returns:
- The state.
 
- getListenerGets the listener of the communications link.- Returns:
- The listener of communication events.
 
- getRemoteAddrReturns the Internet Protocol (IP) address of the client or last proxy that sent the request. The IP address format depends if it is an IPv4 or IPv6 address.- Returns:
- a String containing the IP address of the client that sent the request.
 
- getRemoteHostReturns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the host name (to improve performance), this method returns the dotted-string form of the IP address (if IPv4, colon'ed-string for IPv6).- Returns:
- a String containing the fully qualified name of the client.
 
- getSocketAddressReturns the remote address to which this channel's socket is connected.- Where the channel is bound and connected to an Internet Protocol socket address then the return value from this method is of type - InetSocketAddress.- Returns:
- The remote address; nullif the channel's socket is not connected.
 
- sendSends a transaction.- Parameters:
- trans- Transaction to send.
- doCompress- Compress transaction flag.
- Returns:
- The byte size sent.
- Throws:
- IOException- For IO errors sending the transaction.
 
- sendSends a transaction.- Parameters:
- trans- The transaction to send.
- serial- The serial number 0x0001 to 0xFFFF, 0 for none.
- doCompress- Compress transaction flag.
- Returns:
- The byte size sent.
- Throws:
- IOException- For IO errors sending the transaction.
 
- sendHeartBeatSends a heart-beat.- Returns:
- true for success, false for failure (e.g. closing state or closed).
- Throws:
- IOException- For send failures.
 
- isConnectedpublic boolean isConnected()Checks if the connection is connected, i.e. not initialize, connecting, closing or closed.
- isClosedpublic boolean isClosed()Checks if the connection is disposed of.
- closepublic boolean close()Call this method to close the socket.- Returns:
- true if closed, false if already closed.
 
- closeCloses the connection with the close code and reason.- Parameters:
- code- A close code: zero for none, otherwise a code 1000 or range 4000 to 4999.
- reason- The reason code, can be null.