Package org.firebirdsql.gds.ng.wire
Class WireConnection<T extends IAttachProperties<T>,C extends FbWireAttachment>
- java.lang.Object
- 
- org.firebirdsql.gds.ng.AbstractConnection<T,C>
- 
- org.firebirdsql.gds.ng.wire.WireConnection<T,C>
 
 
- 
- Type Parameters:
- T- Type of attach properties
- C- Type of connection handle
 - All Implemented Interfaces:
- java.io.Closeable,- java.lang.AutoCloseable
 - Direct Known Subclasses:
- WireDatabaseConnection,- WireServiceConnection
 
 public abstract class WireConnection<T extends IAttachProperties<T>,C extends FbWireAttachment> extends AbstractConnection<T,C> implements java.io.Closeable Class managing the TCP/IP connection and initial handshaking with the Firebird server.- Since:
- 3.0
- Author:
- Mark Rotteveel
 
- 
- 
Field Summary- 
Fields inherited from class org.firebirdsql.gds.ng.AbstractConnectionattachProperties
 
- 
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedWireConnection(T attachProperties)Creates a WireConnection (without establishing a connection to the server) with the default protocol collection.protectedWireConnection(T attachProperties, IEncodingFactory encodingFactory, ProtocolCollection protocols)Creates a WireConnection (without establishing a connection to the server).
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclearAuthData()Clear authentication data.voidclose()Closes the TCP/IP connection.protected abstract CcreateConnectionHandle(ProtocolDescriptor protocolDescriptor)Creates the connection handle for this type of connection.protected voidfinalize()ClientAuthBlockgetClientAuthBlock()intgetProtocolArchitecture()intgetProtocolMinimumType()intgetProtocolVersion()XdrStreamAccessgetXdrStreamAccess()Cidentify()Performs the connection identification phase of the Wire protocol and returns the FbWireDatabase implementation for the agreed protocol.booleanisConnected()intreadNextOperation()Reads the next operation code.voidresetSocketTimeout()Resets the socket timeout to the configured socketTimeout.voidsetSoTimeout(int socketTimeout)Sets the socket blocking timeout (SO_TIMEOUT) of the socket.voidsocketConnect()Establishes the TCP/IP connection to serverName and portNumber of this ConnectionvoidwriteDirect(byte[] data)Writes directly to theOutputStreamof the underlying socket.- 
Methods inherited from class org.firebirdsql.gds.ng.AbstractConnectioncreateDbCryptCallback, getAttachObjectName, getAttachProperties, getEncoding, getEncodingDefinition, getEncodingFactory, getPortNumber, getServerName
 
- 
 
- 
- 
- 
Constructor Detail- 
WireConnectionprotected WireConnection(T attachProperties) throws java.sql.SQLException Creates a WireConnection (without establishing a connection to the server) with the default protocol collection.- Parameters:
- attachProperties- Attach properties
- Throws:
- java.sql.SQLException
 
 - 
WireConnectionprotected WireConnection(T attachProperties, IEncodingFactory encodingFactory, ProtocolCollection protocols) throws java.sql.SQLException Creates a WireConnection (without establishing a connection to the server).- Parameters:
- attachProperties- Attach properties
- encodingFactory- Factory for encoding definitions
- protocols- The collection of protocols to use for this connection.
- Throws:
- java.sql.SQLException
 
 
- 
 - 
Method Detail- 
isConnectedpublic final boolean isConnected() 
 - 
getProtocolVersionpublic final int getProtocolVersion() 
 - 
getProtocolArchitecturepublic final int getProtocolArchitecture() 
 - 
getProtocolMinimumTypepublic final int getProtocolMinimumType() 
 - 
getClientAuthBlockpublic final ClientAuthBlock getClientAuthBlock() 
 - 
setSoTimeoutpublic final void setSoTimeout(int socketTimeout) throws java.sql.SQLExceptionSets the socket blocking timeout (SO_TIMEOUT) of the socket.This method can also be called if a connection is established - Parameters:
- socketTimeout- Value of the socket timeout (in milliseconds)
- Throws:
- java.sql.SQLException- If the timeout value cannot be changed
 
 - 
resetSocketTimeoutpublic final void resetSocketTimeout() throws java.sql.SQLExceptionResets the socket timeout to the configured socketTimeout. Does nothing if currently not connected.- Throws:
- java.sql.SQLException- If the timeout value cannot be changed
 
 - 
socketConnectpublic final void socketConnect() throws java.sql.SQLExceptionEstablishes the TCP/IP connection to serverName and portNumber of this Connection- Throws:
- java.sql.SQLTimeoutException- If the connection cannot be established within the connect timeout (either explicitly set or implied by the OS timeout of the socket)
- java.sql.SQLException- If the connection cannot be established.
 
 - 
getXdrStreamAccesspublic final XdrStreamAccess getXdrStreamAccess() 
 - 
identifypublic final C identify() throws java.sql.SQLException Performs the connection identification phase of the Wire protocol and returns the FbWireDatabase implementation for the agreed protocol.- Specified by:
- identifyin class- AbstractConnection<T extends IAttachProperties<T>,C extends FbWireAttachment>
- Returns:
- FbWireDatabase
- Throws:
- java.sql.SQLTimeoutException
- java.sql.SQLException
 
 - 
clearAuthDatapublic final void clearAuthData() Clear authentication data.
 - 
createConnectionHandleprotected abstract C createConnectionHandle(ProtocolDescriptor protocolDescriptor) Creates the connection handle for this type of connection.- Parameters:
- protocolDescriptor- The protocol descriptor selected by the identify phase
- Returns:
- Connection handle
 
 - 
readNextOperationpublic final int readNextOperation() throws java.io.IOExceptionReads the next operation code. Skips allWireProtocolConstants.op_dummycodes received.- Returns:
- Operation code
- Throws:
- java.io.IOException- if an error occurs while reading from the underlying InputStream
 
 - 
closepublic final void close() throws java.io.IOExceptionCloses the TCP/IP connection. This is not a normal detach operation.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Throws:
- java.io.IOException- if closing fails
 
 - 
finalizeprotected final void finalize() throws java.lang.Throwable- Overrides:
- finalizein class- java.lang.Object
- Throws:
- java.lang.Throwable
 
 - 
writeDirectpublic final void writeDirect(byte[] data) throws java.io.IOExceptionWrites directly to theOutputStreamof the underlying socket.- Parameters:
- data- Data to write
- Throws:
- java.io.IOException- If there is no socket, the socket is closed, or for errors writing to the socket.
 
 
- 
 
-