Package org.firebirdsql.gds.ng
Class AbstractFbAttachment<T extends AbstractConnection<? extends IAttachProperties<?>,? extends FbAttachment>>
- java.lang.Object
-
- org.firebirdsql.gds.ng.AbstractFbAttachment<T>
-
- All Implemented Interfaces:
java.lang.AutoCloseable,FbAttachment,ExceptionListenable
- Direct Known Subclasses:
AbstractFbDatabase,AbstractFbService
public abstract class AbstractFbAttachment<T extends AbstractConnection<? extends IAttachProperties<?>,? extends FbAttachment>> extends java.lang.Object implements FbAttachment
Common behavior forAbstractFbServiceandAbstractFbDatabase.- Since:
- 3.0
- Author:
- Mark Rotteveel
-
-
Field Summary
Fields Modifier and Type Field Description protected Tconnectionprotected ExceptionListenerDispatcherexceptionListenerDispatcher
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFbAttachment(T connection, DatatypeCoder datatypeCoder)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddExceptionListener(ExceptionListener listener)Adds an exception listener to this object.protected abstract voidcheckConnected()Checks if the attachment is connected, and throws aSQLExceptionif it isn't connected.voidforceClose()Forces the connection to close without proper detach or cleanup.DatatypeCodergetDatatypeCoder()EncodinggetEncoding()IEncodingFactorygetEncodingFactory()intgetNetworkTimeout()Gets the current network timeout for this attachment.GDSServerVersiongetServerVersion()protected org.firebirdsql.gds.ng.ServerVersionInformationgetServerVersionInformation()java.lang.ObjectgetSynchronizationObject()Get synchronization object.booleanisAttached()Current attachment status.voidremoveExceptionListener(ExceptionListener listener)Removes an exception listener to this object.protected voidsafelyDetach()PerformsFbAttachment.close()suppressing any exception.protected voidsetAttached()Called when this attachment is attached.protected voidsetDetached()Called when this attachment is detached.protected voidsetServerVersion(java.lang.String... versionStrings)Sets the Firebird version from one or more version string elements.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.firebirdsql.gds.ng.FbAttachment
attach, close, getHandle, setNetworkTimeout
-
-
-
-
Field Detail
-
exceptionListenerDispatcher
protected final ExceptionListenerDispatcher exceptionListenerDispatcher
-
connection
protected final T extends AbstractConnection<? extends IAttachProperties<?>,? extends FbAttachment> connection
-
-
Constructor Detail
-
AbstractFbAttachment
protected AbstractFbAttachment(T connection, DatatypeCoder datatypeCoder)
-
-
Method Detail
-
forceClose
public void forceClose() throws java.sql.SQLExceptionForces the connection to close without proper detach or cleanup.If a given implementation does not support this, then this method should call
FbAttachment.close().Default implementation, calls
FbAttachment.close()- Specified by:
forceClosein interfaceFbAttachment- Throws:
java.sql.SQLException- For problems closing the connection.
-
getServerVersion
public GDSServerVersion getServerVersion()
- Specified by:
getServerVersionin interfaceFbAttachment- Returns:
- Firebird version string
-
setServerVersion
protected final void setServerVersion(java.lang.String... versionStrings)
Sets the Firebird version from one or more version string elements.This method should only be called by this instance.
- Parameters:
versionStrings- Raw version strings
-
getServerVersionInformation
protected org.firebirdsql.gds.ng.ServerVersionInformation getServerVersionInformation()
-
setAttached
protected final void setAttached()
Called when this attachment is attached.Only this
AbstractFbDatabaseinstance should call this method.
-
isAttached
public boolean isAttached()
Description copied from interface:FbAttachmentCurrent attachment status.- Specified by:
isAttachedin interfaceFbAttachment- Returns:
trueif connected to the server and attached to a database or service,falseotherwise.
-
setDetached
protected final void setDetached()
Called when this attachment is detached.Only this
AbstractFbAttachmentinstance should call this method.
-
getSynchronizationObject
public final java.lang.Object getSynchronizationObject()
Description copied from interface:FbAttachmentGet synchronization object.- Specified by:
getSynchronizationObjectin interfaceFbAttachment- Returns:
- object, cannot be
null.
-
getEncodingFactory
public final IEncodingFactory getEncodingFactory()
- Specified by:
getEncodingFactoryin interfaceFbAttachment- Returns:
- The
IEncodingFactoryfor this connection
-
getEncoding
public final Encoding getEncoding()
- Specified by:
getEncodingin interfaceFbAttachment- Returns:
- The connection encoding (should be the same as returned from calling
IEncodingFactory.getDefaultEncoding()on the result ofFbAttachment.getEncodingFactory().
-
getDatatypeCoder
public final DatatypeCoder getDatatypeCoder()
- Specified by:
getDatatypeCoderin interfaceFbAttachment- Returns:
- The
DatatypeCoderfor this database implementation.
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLExceptionDescription copied from interface:FbAttachmentGets the current network timeout for this attachment.- Specified by:
getNetworkTimeoutin interfaceFbAttachment- Returns:
- Timeout in milliseconds, 0 means no timeout
- Throws:
java.sql.SQLException- If this attachment is closedjava.sql.SQLFeatureNotSupportedException- If this attachment doesn't support network timeout
-
addExceptionListener
public final void addExceptionListener(ExceptionListener listener)
Description copied from interface:ExceptionListenableAdds an exception listener to this object.Implementations use
WeakReference.- Specified by:
addExceptionListenerin interfaceExceptionListenable- Parameters:
listener- Listener to register
-
removeExceptionListener
public final void removeExceptionListener(ExceptionListener listener)
Description copied from interface:ExceptionListenableRemoves an exception listener to this object.- Specified by:
removeExceptionListenerin interfaceExceptionListenable- Parameters:
listener- Listener to remove
-
checkConnected
protected abstract void checkConnected() throws java.sql.SQLExceptionChecks if the attachment is connected, and throws aSQLExceptionif it isn't connected.- Throws:
java.sql.SQLException
-
safelyDetach
protected final void safelyDetach()
PerformsFbAttachment.close()suppressing any exception.
-
-