Class FBServiceManager
- java.lang.Object
-
- org.firebirdsql.management.FBServiceManager
-
- All Implemented Interfaces:
AttachmentProperties,BaseProperties,ServiceConnectionProperties,ServiceManager
- Direct Known Subclasses:
FBBackupManagerBase,FBMaintenanceManager,FBNBackupManager,FBStatisticsManager,FBTraceManager,FBUserManager
public class FBServiceManager extends java.lang.Object implements ServiceManager
An implementation of the basic Firebird Service API functionality.- Author:
- Roman Rokytskyy, Mark Rotteveel
-
-
Field Summary
Fields Modifier and Type Field Description static intBUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description FBServiceManager()Create a new instance ofFBServiceManagerbased on the default GDSType.FBServiceManager(java.lang.String gdsType)Create a new instance ofFBServiceManagerbased on a given GDSType.FBServiceManager(GDSType gdsType)Create a new instance ofFBServiceManagerbased on a given GDSType.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected FbDatabaseattachDatabase()FbServiceattachServiceManager()java.util.Map<ConnectionProperty,java.lang.Object>connectionPropertyValues()An unmodifiable view on the connection properties held by this BaseProperties implementation.protected ServiceRequestBuffercreateRequestBuffer(FbService service, int operation, int options)protected voidexecuteServicesOperation(FbService service, ServiceRequestBuffer srb)protected voidexecuteServicesOperation(ServiceRequestBuffer srb)Deprecated.java.lang.StringgetAuthPlugins()Get the list of authentication plugins to try.java.lang.BooleangetBooleanProperty(java.lang.String name)Retrieves abooleanproperty value by name.java.lang.StringgetCharSet()Java character set configured for the connection.java.lang.StringgetDatabase()Returns the database path for the connection to the service manager.java.lang.StringgetDbCryptConfig()Get the database encryption plugin configuration.java.lang.StringgetExpectedDb()Gets the expected db (isc_spb_expected_db; defaults tonull).java.lang.StringgetHost()Deprecated.java.lang.IntegergetIntProperty(java.lang.String name)Retrieves anintproperty value by name.java.io.OutputStreamgetLogger()Returns the logger for the connection to the service manager.java.lang.StringgetPassword()intgetPort()Deprecated.intgetPortNumber()Get the port number of the server.java.lang.StringgetProperty(java.lang.String name)Retrieves a string property value by name.java.lang.StringgetServerName()Get the hostname or IP address of the Firebird server.GDSServerVersiongetServerVersion()Obtains the server version through a service call.java.lang.StringgetServiceName()Gets the service name (defaults to"service_mgr").java.lang.StringgetUser()java.lang.StringgetWireCrypt()Get the wire encryption level.WireCryptgetWireCryptAsEnum()Get the wire encryption level.booleanisWireCompression()Get if wire compression should be enabled.voidqueueService(FbService service)voidsetAuthPlugins(java.lang.String authPlugins)Sets the authentication plugins to try.voidsetBooleanProperty(java.lang.String name, java.lang.Boolean value)Sets abooleanproperty by name.voidsetCharSet(java.lang.String charSet)Set the Java character set for the connection.voidsetDatabase(java.lang.String database)Sets the database path for the connection to the service manager.voidsetDbCryptConfig(java.lang.String dbCryptConfig)Sets the database encryption plugin configuration.voidsetExpectedDb(java.lang.String expectedDb)Filename or alias of the database expected to be accessed by the service operation (isc_spb_expected_db).voidsetHost(java.lang.String host)Deprecated.voidsetIntProperty(java.lang.String name, java.lang.Integer value)Sets anintproperty by name.voidsetLogger(java.io.OutputStream logger)Sets the logger for the connection to the service manager.voidsetPassword(java.lang.String password)voidsetPort(int port)Deprecated.voidsetPortNumber(int portNumber)Set the port number of the server.voidsetProperty(java.lang.String name, java.lang.String value)Sets a property by name.voidsetServerName(java.lang.String serverName)Set the hostname or IP address of the Firebird server.voidsetServiceName(java.lang.String serviceName)Sets the service namevoidsetType(java.lang.String type)voidsetUser(java.lang.String user)voidsetWireCompression(boolean wireCompression)Sets if the connection should try to enable wire compression.voidsetWireCryptAsEnum(WireCrypt wireCrypt)Set the wire encryption level.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.firebirdsql.jaybird.props.AttachmentProperties
getConnectTimeout, getEncoding, getParallelWorkers, getProcessId, getProcessName, getRoleName, getSocketBufferSize, getSoTimeout, getType, setConnectTimeout, setEncoding, setParallelWorkers, setProcessId, setProcessName, setRoleName, setSocketBufferSize, setSoTimeout, setWireCrypt
-
Methods inherited from interface org.firebirdsql.jaybird.props.BaseProperties
getBooleanProperty, getIntProperty, getProperty
-
-
-
-
Field Detail
-
BUFFER_SIZE
public static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FBServiceManager
public FBServiceManager()
Create a new instance ofFBServiceManagerbased on the default GDSType.
-
FBServiceManager
public FBServiceManager(java.lang.String gdsType)
Create a new instance ofFBServiceManagerbased on a given GDSType.- Parameters:
gdsType- type must be PURE_JAVA, EMBEDDED, or NATIVE
-
FBServiceManager
public FBServiceManager(GDSType gdsType)
Create a new instance ofFBServiceManagerbased on a given GDSType.- Parameters:
gdsType- The GDS implementation type to use
-
-
Method Detail
-
setType
public final void setType(java.lang.String type)
- Specified by:
setTypein interfaceAttachmentProperties- Parameters:
type- type of the connection, for example, "PURE_JAVA", "NATIVE", "EMBEDDED", depends on the GDS implementations installed in the system.
-
setCharSet
public void setCharSet(java.lang.String charSet)
Description copied from interface:AttachmentPropertiesSet the Java character set for the connection.It is possible to set both the
charSetandencodingto achieve a character set conversion effect, but in general only one of both properties should be set.- Specified by:
setCharSetin interfaceAttachmentProperties- Parameters:
charSet- Character set for the connection. Similar toencodingproperty, but accepts Java names instead of Firebird ones.- See Also:
AttachmentProperties.setEncoding(String)
-
getCharSet
public java.lang.String getCharSet()
Description copied from interface:AttachmentPropertiesJava character set configured for the connection.After connect, the actual Java character set applied can be obtained from
FbAttachment.getEncoding()(propertycharsetName), orFbAttachment.getEncodingFactory()(propertiesdefaultEncoding.charsetNameor {code defaultEncodingDefinition.javaCharset}).- Specified by:
getCharSetin interfaceAttachmentProperties- Returns:
- Java character set for the connection (
nullwhen not explicitly configured).
-
setUser
public void setUser(java.lang.String user)
- Specified by:
setUserin interfaceAttachmentProperties- Parameters:
user- Name of the user to authenticate to the server.
-
getUser
public java.lang.String getUser()
- Specified by:
getUserin interfaceAttachmentProperties- Returns:
- Name of the user to authenticate to the server.
-
setPassword
public void setPassword(java.lang.String password)
- Specified by:
setPasswordin interfaceAttachmentProperties- Parameters:
password- Password to authenticate to the server.
-
getPassword
public java.lang.String getPassword()
- Specified by:
getPasswordin interfaceAttachmentProperties- Returns:
- Password to authenticate to the server.
-
getServerName
public java.lang.String getServerName()
Description copied from interface:AttachmentPropertiesGet the hostname or IP address of the Firebird server.- Specified by:
getServerNamein interfaceAttachmentProperties- Returns:
- Hostname or IP address of the server
- See Also:
AttachmentProperties.setServerName(String)
-
setServerName
public void setServerName(java.lang.String serverName)
Description copied from interface:AttachmentPropertiesSet the hostname or IP address of the Firebird server.When set to
null(the default), thedatabaseNameorserviceNameis used as the full identification of the database host, port and database path/alias. Protocol implementations, for examplePURE_JAVA, may default tolocalhostwhen this property isnull, butdatabaseName/serviceNamedoes not (seem to) contain a host name.- Specified by:
setServerNamein interfaceAttachmentProperties- Parameters:
serverName- Hostname or IP address of the server
-
getPortNumber
public int getPortNumber()
Description copied from interface:AttachmentPropertiesGet the port number of the server.- Specified by:
getPortNumberin interfaceAttachmentProperties- Returns:
- Port number of the server
- See Also:
AttachmentProperties.setPortNumber(int)
-
setPortNumber
public void setPortNumber(int portNumber)
Description copied from interface:AttachmentPropertiesSet the port number of the server.Defaults to
3050. This property value will be ignored ifserverNameisnull, unless the protocol implementation needs a hostname, but cannot find a hostname indatabaseName/serviceName.- Specified by:
setPortNumberin interfaceAttachmentProperties- Parameters:
portNumber- Port number of the server- See Also:
AttachmentProperties.setServerName(String)
-
getServiceName
public java.lang.String getServiceName()
Description copied from interface:ServiceConnectionPropertiesGets the service name (defaults to"service_mgr").- Specified by:
getServiceNamein interfaceServiceConnectionProperties- Returns:
- database name
- See Also:
ServiceConnectionProperties.setServiceName(String)
-
setServiceName
public void setServiceName(java.lang.String serviceName)
Description copied from interface:ServiceConnectionPropertiesSets the service nameWhen
serverNameisnull, then the value is taken as the URL of the service, and exact interpretation depends on the protocol implementation (type). Examples:- //localhost/ — PURE_JAVA, OOREMOTE, NATIVE (for NATIVE, this format is parsed and transformed to the next example; will fail on Firebird 2.5 and earlier)
- localhost — NATIVE, PURE_JAVA, OOREMOTE
- //localhost:3051/ — PURE_JAVA, OOREMOTE, NATIVE (for NATIVE, this format is parsed and transformed to the next example; will fail on Firebird 2.5 and earlier)
- //localhost/service_mgr — PURE_JAVA, OOREMOTE, NATIVE (for NATIVE, this format is parsed and transformed to the next example)
- localhost:service_mgr — NATIVE, PURE_JAVA, OOREMOTE
- //localhost:3051/service_mgr — PURE_JAVA, OOREMOTE, NATIVE (for NATIVE, this format is parsed and transformed to the next example)
- localhost/3051:service_mgr — NATIVE, PURE_JAVA, OOREMOTE
- service_mgr — NATIVE, EMBEDDED, PURE_JAVA, OOREMOTE (PURE_JAVA and OOREMOTE will use localhost
as
serverName, depending on the Firebird version and platform, NATIVE may use Firebird Embedded) - xnet://service_mgr — NATIVE (EMBEDDED will behave as NATIVE, protocols like PURE_JAVA may
attempt to connect to a server called
xnet) TODO: Check if actually valid - other Firebird
fbclientconnection URLs — NATIVE, (EMBEDDED will behave as NATIVE, protocols like PURE_JAVA may interpret the protocol name as a host name - Custom
typeimplementations may support other URL formats
Some protocols, for example PURE_JAVA, when
serverNameis not set, butserviceNamedoesn't seem to contain a host name, may default to attempting to connect to localhost withserviceNameas the service.When
serverNameis set, the value is taken as the database path or alias. Examples:- service_mgr
- empty string TODO verify if that works
null
- Specified by:
setServiceNamein interfaceServiceConnectionProperties- Parameters:
serviceName- service name
-
setExpectedDb
public void setExpectedDb(java.lang.String expectedDb)
Filename or alias of the database expected to be accessed by the service operation (isc_spb_expected_db).For Firebird 3.0 and higher when using a non-default security database, so Firebird knows which database to use to authenticate. When using the default security database, this property does not need to be set.
Some service implementations (e.g.
BackupManager) may explicitly set this as part of their operation when its current value isnull.NOTE: The
setDatabase(String)property will also set this property, so in general this property doesn't need to be set explicitly.- Specified by:
setExpectedDbin interfaceServiceConnectionProperties- Parameters:
expectedDb- Expected database
-
getExpectedDb
public java.lang.String getExpectedDb()
Description copied from interface:ServiceConnectionPropertiesGets the expected db (isc_spb_expected_db; defaults tonull).- Specified by:
getExpectedDbin interfaceServiceConnectionProperties- Returns:
- expected database
- See Also:
ServiceConnectionProperties.setExpectedDb(String)
-
setDatabase
public void setDatabase(java.lang.String database)
Description copied from interface:ServiceManagerSets the database path for the connection to the service manager.Will also set the
expectedDbproperty. If a different value must be used, it must be set after calling this method.- Specified by:
setDatabasein interfaceServiceManager- Parameters:
database- path for the connection to the service manager.
-
getDatabase
public java.lang.String getDatabase()
Description copied from interface:ServiceManagerReturns the database path for the connection to the service manager.- Specified by:
getDatabasein interfaceServiceManager- Returns:
- the database path for the connection to the service manager.
-
getHost
@Deprecated public java.lang.String getHost()
Deprecated.Description copied from interface:ServiceManagerReturns the host for the connection to the service manager.- Specified by:
getHostin interfaceServiceManager- Returns:
- the host for the connection to the service manager.
-
setHost
@Deprecated public void setHost(java.lang.String host)
Deprecated.Description copied from interface:ServiceManagerSets the host for the connection to the service manager.See
AttachmentProperties.setServerName(String)for details.- Specified by:
setHostin interfaceServiceManager- Parameters:
host- for the connection to the service manager.
-
getPort
@Deprecated public int getPort()
Deprecated.Description copied from interface:ServiceManagerReturns the port for the connection to the service manager.- Specified by:
getPortin interfaceServiceManager- Returns:
- the port for the connection to the service manager.
-
setPort
@Deprecated public void setPort(int port)
Deprecated.Description copied from interface:ServiceManagerSets the port for the connection to the service manager.- Specified by:
setPortin interfaceServiceManager- Parameters:
port- for the connection to the service manager.
-
getWireCrypt
public java.lang.String getWireCrypt()
Description copied from interface:AttachmentPropertiesGet the wire encryption level.- Specified by:
getWireCryptin interfaceAttachmentProperties- Returns:
- Wire encryption level
-
getWireCryptAsEnum
public WireCrypt getWireCryptAsEnum()
Description copied from interface:ServiceManagerGet the wire encryption level.- Specified by:
getWireCryptAsEnumin interfaceServiceManager- Returns:
- Wire encryption level
-
setWireCryptAsEnum
public void setWireCryptAsEnum(WireCrypt wireCrypt)
Description copied from interface:ServiceManagerSet the wire encryption level.- Specified by:
setWireCryptAsEnumin interfaceServiceManager- Parameters:
wireCrypt- Wire encryption level (nullnot allowed)
-
getDbCryptConfig
public java.lang.String getDbCryptConfig()
Description copied from interface:AttachmentPropertiesGet the database encryption plugin configuration.- Specified by:
getDbCryptConfigin interfaceAttachmentProperties- Returns:
- Database encryption plugin configuration, meaning plugin specific
-
setDbCryptConfig
public void setDbCryptConfig(java.lang.String dbCryptConfig)
Description copied from interface:AttachmentPropertiesSets the database encryption plugin configuration.- Specified by:
setDbCryptConfigin interfaceAttachmentProperties- Parameters:
dbCryptConfig- Database encryption plugin configuration, meaning plugin specific
-
getAuthPlugins
public java.lang.String getAuthPlugins()
Description copied from interface:AttachmentPropertiesGet the list of authentication plugins to try.- Specified by:
getAuthPluginsin interfaceAttachmentProperties- Returns:
- comma-separated list of authentication plugins
-
setAuthPlugins
public void setAuthPlugins(java.lang.String authPlugins)
Description copied from interface:AttachmentPropertiesSets the authentication plugins to try.Invalid names are skipped during authentication.
- Specified by:
setAuthPluginsin interfaceAttachmentProperties- Parameters:
authPlugins- comma-separated list of authentication plugins
-
isWireCompression
public boolean isWireCompression()
Description copied from interface:AttachmentPropertiesGet if wire compression should be enabled.Wire compression requires Firebird 3 or higher, and the server must have the zlib library. If compression cannot be negotiated, the connection will be made without wire compression.
This property will be ignored for native connections. For native connections, the configuration in
firebird.confread by the client library will be used.- Specified by:
isWireCompressionin interfaceAttachmentProperties- Returns:
truewire compression enabled
-
setWireCompression
public void setWireCompression(boolean wireCompression)
Description copied from interface:AttachmentPropertiesSets if the connection should try to enable wire compression.- Specified by:
setWireCompressionin interfaceAttachmentProperties- Parameters:
wireCompression-trueenable wire compression,falsedisable wire compression (the default)- See Also:
AttachmentProperties.isWireCompression()
-
getProperty
public java.lang.String getProperty(java.lang.String name)
Description copied from interface:BasePropertiesRetrieves a string property value by name.For properties with an explicit default, this method should return the string presentation of that default, not
null. Forintorbooleanthe string equivalent is returned.- Specified by:
getPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)- Returns:
- Value of the property, or
nullwhen not set or not a known property
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)Description copied from interface:BasePropertiesSets a property by name.This method can be used to set all defined properties, but also properties not known by Jaybird. When setting
intorbooleanproperties, the appropriate conversions are applied. Usingnullwill reset to the default value. Forbooleanproperties, an empty string is taken to meantrue.- Specified by:
setPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)value- Property value (usenullto apply default)
-
getIntProperty
public java.lang.Integer getIntProperty(java.lang.String name)
Description copied from interface:BasePropertiesRetrieves anintproperty value by name.For properties with an explicit default, this method should return the integer presentation of that default. For implementation simplicity, it is allowed to convert any string property to
intinstead of checking if something is actually anintproperty- Specified by:
getIntPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)- Returns:
- Integer with value of the property, or
nullwhen not set
-
setIntProperty
public void setIntProperty(java.lang.String name, java.lang.Integer value)Description copied from interface:BasePropertiesSets anintproperty by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setIntPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)value- Property value (usenullto apply default)
-
getBooleanProperty
public java.lang.Boolean getBooleanProperty(java.lang.String name)
Description copied from interface:BasePropertiesRetrieves abooleanproperty value by name.For properties with an explicit default, this method should return the boolean presentation of that default. For implementation simplicity, it is allowed to convert any string property to
booleaninstead of checking if something is actually anintproperty- Specified by:
getBooleanPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)- Returns:
- Integer with value of the property, or
nullwhen not set
-
setBooleanProperty
public void setBooleanProperty(java.lang.String name, java.lang.Boolean value)Description copied from interface:BasePropertiesSets abooleanproperty by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setBooleanPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)value- Property value (usenullto apply default)
-
connectionPropertyValues
public java.util.Map<ConnectionProperty,java.lang.Object> connectionPropertyValues()
Description copied from interface:BasePropertiesAn unmodifiable view on the connection properties held by this BaseProperties implementation.Be aware, implementations can have additional properties that are not mapped from
ConnectionProperty. Such properties will need to be retrieved in an implementation-specific manner.- Specified by:
connectionPropertyValuesin interfaceBaseProperties- Returns:
- An unmodifiable view on the property values held in this properties instance
-
getLogger
public java.io.OutputStream getLogger()
Description copied from interface:ServiceManagerReturns the logger for the connection to the service manager.- Specified by:
getLoggerin interfaceServiceManager- Returns:
- Returns the out.
-
setLogger
public void setLogger(java.io.OutputStream logger)
Description copied from interface:ServiceManagerSets the logger for the connection to the service manager.- Specified by:
setLoggerin interfaceServiceManager- Parameters:
logger- The out to set.
-
attachServiceManager
public FbService attachServiceManager() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
attachDatabase
protected FbDatabase attachDatabase() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
queueService
public void queueService(FbService service) throws java.sql.SQLException, java.io.IOException
- Throws:
java.sql.SQLExceptionjava.io.IOException
-
executeServicesOperation
@Deprecated protected void executeServicesOperation(ServiceRequestBuffer srb) throws java.sql.SQLException
Deprecated.Execute a Services API operation in the database. All output from the operation is sent to thisServiceManager's logger.- Parameters:
srb- The buffer containing the task request- Throws:
java.sql.SQLException- if a database access error occurs or incorrect parameters are supplied
-
executeServicesOperation
protected final void executeServicesOperation(FbService service, ServiceRequestBuffer srb) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
createRequestBuffer
protected ServiceRequestBuffer createRequestBuffer(FbService service, int operation, int options)
-
getServerVersion
public GDSServerVersion getServerVersion() throws java.sql.SQLException
Description copied from interface:ServiceManagerObtains the server version through a service call.- Specified by:
getServerVersionin interfaceServiceManager- Returns:
- Parsed server version, or
GDSServerVersion.INVALID_VERSIONif parsing failed. - Throws:
java.sql.SQLException- For errors connecting to the service manager.
-
-