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 int
BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description FBServiceManager()
Create a new instance ofFBServiceManager
based on the default GDSType.FBServiceManager(java.lang.String gdsType)
Create a new instance ofFBServiceManager
based on a given GDSType.FBServiceManager(GDSType gdsType)
Create a new instance ofFBServiceManager
based on a given GDSType.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected FbDatabase
attachDatabase()
FbService
attachServiceManager()
java.util.Map<ConnectionProperty,java.lang.Object>
connectionPropertyValues()
An unmodifiable view on the connection properties held by this BaseProperties implementation.protected ServiceRequestBuffer
createRequestBuffer(FbService service, int operation, int options)
protected void
executeServicesOperation(FbService service, ServiceRequestBuffer srb)
protected void
executeServicesOperation(ServiceRequestBuffer srb)
Deprecated.java.lang.String
getAuthPlugins()
Get the list of authentication plugins to try.java.lang.Boolean
getBooleanProperty(java.lang.String name)
Retrieves aboolean
property value by name.java.lang.String
getCharSet()
Java character set configured for the connection.java.lang.String
getDatabase()
Returns the database path for the connection to the service manager.java.lang.String
getDbCryptConfig()
Get the database encryption plugin configuration.java.lang.String
getExpectedDb()
Gets the expected db (isc_spb_expected_db
; defaults tonull
).java.lang.String
getHost()
Deprecated.java.lang.Integer
getIntProperty(java.lang.String name)
Retrieves anint
property value by name.java.io.OutputStream
getLogger()
Returns the logger for the connection to the service manager.java.lang.String
getPassword()
int
getPort()
Deprecated.int
getPortNumber()
Get the port number of the server.java.lang.String
getProperty(java.lang.String name)
Retrieves a string property value by name.java.lang.String
getServerName()
Get the hostname or IP address of the Firebird server.GDSServerVersion
getServerVersion()
Obtains the server version through a service call.java.lang.String
getServiceName()
Gets the service name (defaults to"service_mgr"
).java.lang.String
getUser()
java.lang.String
getWireCrypt()
Get the wire encryption level.WireCrypt
getWireCryptAsEnum()
Get the wire encryption level.boolean
isWireCompression()
Get if wire compression should be enabled.void
queueService(FbService service)
void
setAuthPlugins(java.lang.String authPlugins)
Sets the authentication plugins to try.void
setBooleanProperty(java.lang.String name, java.lang.Boolean value)
Sets aboolean
property by name.void
setCharSet(java.lang.String charSet)
Set the Java character set for the connection.void
setDatabase(java.lang.String database)
Sets the database path for the connection to the service manager.void
setDbCryptConfig(java.lang.String dbCryptConfig)
Sets the database encryption plugin configuration.void
setExpectedDb(java.lang.String expectedDb)
Filename or alias of the database expected to be accessed by the service operation (isc_spb_expected_db
).void
setHost(java.lang.String host)
Deprecated.void
setIntProperty(java.lang.String name, java.lang.Integer value)
Sets anint
property by name.void
setLogger(java.io.OutputStream logger)
Sets the logger for the connection to the service manager.void
setPassword(java.lang.String password)
void
setPort(int port)
Deprecated.void
setPortNumber(int portNumber)
Set the port number of the server.void
setProperty(java.lang.String name, java.lang.String value)
Sets a property by name.void
setServerName(java.lang.String serverName)
Set the hostname or IP address of the Firebird server.void
setServiceName(java.lang.String serviceName)
Sets the service namevoid
setType(java.lang.String type)
void
setUser(java.lang.String user)
void
setWireCompression(boolean wireCompression)
Sets if the connection should try to enable wire compression.void
setWireCryptAsEnum(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 ofFBServiceManager
based on the default GDSType.
-
FBServiceManager
public FBServiceManager(java.lang.String gdsType)
Create a new instance ofFBServiceManager
based on a given GDSType.- Parameters:
gdsType
- type must be PURE_JAVA, EMBEDDED, or NATIVE
-
FBServiceManager
public FBServiceManager(GDSType gdsType)
Create a new instance ofFBServiceManager
based 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:
setType
in 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:AttachmentProperties
Set the Java character set for the connection.It is possible to set both the
charSet
andencoding
to achieve a character set conversion effect, but in general only one of both properties should be set.- Specified by:
setCharSet
in interfaceAttachmentProperties
- Parameters:
charSet
- Character set for the connection. Similar toencoding
property, but accepts Java names instead of Firebird ones.- See Also:
AttachmentProperties.setEncoding(String)
-
getCharSet
public java.lang.String getCharSet()
Description copied from interface:AttachmentProperties
Java character set configured for the connection.After connect, the actual Java character set applied can be obtained from
FbAttachment.getEncoding()
(propertycharsetName
), orFbAttachment.getEncodingFactory()
(propertiesdefaultEncoding.charsetName
or {code defaultEncodingDefinition.javaCharset}).- Specified by:
getCharSet
in interfaceAttachmentProperties
- Returns:
- Java character set for the connection (
null
when not explicitly configured).
-
setUser
public void setUser(java.lang.String user)
- Specified by:
setUser
in interfaceAttachmentProperties
- Parameters:
user
- Name of the user to authenticate to the server.
-
getUser
public java.lang.String getUser()
- Specified by:
getUser
in interfaceAttachmentProperties
- Returns:
- Name of the user to authenticate to the server.
-
setPassword
public void setPassword(java.lang.String password)
- Specified by:
setPassword
in interfaceAttachmentProperties
- Parameters:
password
- Password to authenticate to the server.
-
getPassword
public java.lang.String getPassword()
- Specified by:
getPassword
in interfaceAttachmentProperties
- Returns:
- Password to authenticate to the server.
-
getServerName
public java.lang.String getServerName()
Description copied from interface:AttachmentProperties
Get the hostname or IP address of the Firebird server.- Specified by:
getServerName
in 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:AttachmentProperties
Set the hostname or IP address of the Firebird server.When set to
null
(the default), thedatabaseName
orserviceName
is used as the full identification of the database host, port and database path/alias. Protocol implementations, for examplePURE_JAVA
, may default tolocalhost
when this property isnull
, butdatabaseName
/serviceName
does not (seem to) contain a host name.- Specified by:
setServerName
in interfaceAttachmentProperties
- Parameters:
serverName
- Hostname or IP address of the server
-
getPortNumber
public int getPortNumber()
Description copied from interface:AttachmentProperties
Get the port number of the server.- Specified by:
getPortNumber
in interfaceAttachmentProperties
- Returns:
- Port number of the server
- See Also:
AttachmentProperties.setPortNumber(int)
-
setPortNumber
public void setPortNumber(int portNumber)
Description copied from interface:AttachmentProperties
Set the port number of the server.Defaults to
3050
. This property value will be ignored ifserverName
isnull
, unless the protocol implementation needs a hostname, but cannot find a hostname indatabaseName
/serviceName
.- Specified by:
setPortNumber
in interfaceAttachmentProperties
- Parameters:
portNumber
- Port number of the server- See Also:
AttachmentProperties.setServerName(String)
-
getServiceName
public java.lang.String getServiceName()
Description copied from interface:ServiceConnectionProperties
Gets the service name (defaults to"service_mgr"
).- Specified by:
getServiceName
in interfaceServiceConnectionProperties
- Returns:
- database name
- See Also:
ServiceConnectionProperties.setServiceName(String)
-
setServiceName
public void setServiceName(java.lang.String serviceName)
Description copied from interface:ServiceConnectionProperties
Sets the service nameWhen
serverName
isnull
, 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
fbclient
connection URLs — NATIVE, (EMBEDDED will behave as NATIVE, protocols like PURE_JAVA may interpret the protocol name as a host name - Custom
type
implementations may support other URL formats
Some protocols, for example PURE_JAVA, when
serverName
is not set, butserviceName
doesn't seem to contain a host name, may default to attempting to connect to localhost withserviceName
as the service.When
serverName
is set, the value is taken as the database path or alias. Examples:- service_mgr
- empty string TODO verify if that works
null
- Specified by:
setServiceName
in 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:
setExpectedDb
in interfaceServiceConnectionProperties
- Parameters:
expectedDb
- Expected database
-
getExpectedDb
public java.lang.String getExpectedDb()
Description copied from interface:ServiceConnectionProperties
Gets the expected db (isc_spb_expected_db
; defaults tonull
).- Specified by:
getExpectedDb
in interfaceServiceConnectionProperties
- Returns:
- expected database
- See Also:
ServiceConnectionProperties.setExpectedDb(String)
-
setDatabase
public void setDatabase(java.lang.String database)
Description copied from interface:ServiceManager
Sets the database path for the connection to the service manager.Will also set the
expectedDb
property. If a different value must be used, it must be set after calling this method.- Specified by:
setDatabase
in interfaceServiceManager
- Parameters:
database
- path for the connection to the service manager.
-
getDatabase
public java.lang.String getDatabase()
Description copied from interface:ServiceManager
Returns the database path for the connection to the service manager.- Specified by:
getDatabase
in interfaceServiceManager
- Returns:
- the database path for the connection to the service manager.
-
getHost
@Deprecated public java.lang.String getHost()
Deprecated.Description copied from interface:ServiceManager
Returns the host for the connection to the service manager.- Specified by:
getHost
in 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:ServiceManager
Sets the host for the connection to the service manager.See
AttachmentProperties.setServerName(String)
for details.- Specified by:
setHost
in interfaceServiceManager
- Parameters:
host
- for the connection to the service manager.
-
getPort
@Deprecated public int getPort()
Deprecated.Description copied from interface:ServiceManager
Returns the port for the connection to the service manager.- Specified by:
getPort
in interfaceServiceManager
- Returns:
- the port for the connection to the service manager.
-
setPort
@Deprecated public void setPort(int port)
Deprecated.Description copied from interface:ServiceManager
Sets the port for the connection to the service manager.- Specified by:
setPort
in interfaceServiceManager
- Parameters:
port
- for the connection to the service manager.
-
getWireCrypt
public java.lang.String getWireCrypt()
Description copied from interface:AttachmentProperties
Get the wire encryption level.- Specified by:
getWireCrypt
in interfaceAttachmentProperties
- Returns:
- Wire encryption level
-
getWireCryptAsEnum
public WireCrypt getWireCryptAsEnum()
Description copied from interface:ServiceManager
Get the wire encryption level.- Specified by:
getWireCryptAsEnum
in interfaceServiceManager
- Returns:
- Wire encryption level
-
setWireCryptAsEnum
public void setWireCryptAsEnum(WireCrypt wireCrypt)
Description copied from interface:ServiceManager
Set the wire encryption level.- Specified by:
setWireCryptAsEnum
in interfaceServiceManager
- Parameters:
wireCrypt
- Wire encryption level (null
not allowed)
-
getDbCryptConfig
public java.lang.String getDbCryptConfig()
Description copied from interface:AttachmentProperties
Get the database encryption plugin configuration.- Specified by:
getDbCryptConfig
in interfaceAttachmentProperties
- Returns:
- Database encryption plugin configuration, meaning plugin specific
-
setDbCryptConfig
public void setDbCryptConfig(java.lang.String dbCryptConfig)
Description copied from interface:AttachmentProperties
Sets the database encryption plugin configuration.- Specified by:
setDbCryptConfig
in interfaceAttachmentProperties
- Parameters:
dbCryptConfig
- Database encryption plugin configuration, meaning plugin specific
-
getAuthPlugins
public java.lang.String getAuthPlugins()
Description copied from interface:AttachmentProperties
Get the list of authentication plugins to try.- Specified by:
getAuthPlugins
in interfaceAttachmentProperties
- Returns:
- comma-separated list of authentication plugins
-
setAuthPlugins
public void setAuthPlugins(java.lang.String authPlugins)
Description copied from interface:AttachmentProperties
Sets the authentication plugins to try.Invalid names are skipped during authentication.
- Specified by:
setAuthPlugins
in interfaceAttachmentProperties
- Parameters:
authPlugins
- comma-separated list of authentication plugins
-
isWireCompression
public boolean isWireCompression()
Description copied from interface:AttachmentProperties
Get 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.conf
read by the client library will be used.- Specified by:
isWireCompression
in interfaceAttachmentProperties
- Returns:
true
wire compression enabled
-
setWireCompression
public void setWireCompression(boolean wireCompression)
Description copied from interface:AttachmentProperties
Sets if the connection should try to enable wire compression.- Specified by:
setWireCompression
in interfaceAttachmentProperties
- Parameters:
wireCompression
-true
enable wire compression,false
disable wire compression (the default)- See Also:
AttachmentProperties.isWireCompression()
-
getProperty
public java.lang.String getProperty(java.lang.String name)
Description copied from interface:BaseProperties
Retrieves a string property value by name.For properties with an explicit default, this method should return the string presentation of that default, not
null
. Forint
orboolean
the string equivalent is returned.- Specified by:
getProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)- Returns:
- Value of the property, or
null
when not set or not a known property
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)
Description copied from interface:BaseProperties
Sets a property by name.This method can be used to set all defined properties, but also properties not known by Jaybird. When setting
int
orboolean
properties, the appropriate conversions are applied. Usingnull
will reset to the default value. Forboolean
properties, an empty string is taken to meantrue
.- Specified by:
setProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)value
- Property value (usenull
to apply default)
-
getIntProperty
public java.lang.Integer getIntProperty(java.lang.String name)
Description copied from interface:BaseProperties
Retrieves anint
property 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
int
instead of checking if something is actually anint
property- Specified by:
getIntProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)- Returns:
- Integer with value of the property, or
null
when not set
-
setIntProperty
public void setIntProperty(java.lang.String name, java.lang.Integer value)
Description copied from interface:BaseProperties
Sets anint
property by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setIntProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)value
- Property value (usenull
to apply default)
-
getBooleanProperty
public java.lang.Boolean getBooleanProperty(java.lang.String name)
Description copied from interface:BaseProperties
Retrieves aboolean
property 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
boolean
instead of checking if something is actually anint
property- Specified by:
getBooleanProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)- Returns:
- Integer with value of the property, or
null
when not set
-
setBooleanProperty
public void setBooleanProperty(java.lang.String name, java.lang.Boolean value)
Description copied from interface:BaseProperties
Sets aboolean
property by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setBooleanProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)value
- Property value (usenull
to apply default)
-
connectionPropertyValues
public java.util.Map<ConnectionProperty,java.lang.Object> connectionPropertyValues()
Description copied from interface:BaseProperties
An 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:
connectionPropertyValues
in interfaceBaseProperties
- Returns:
- An unmodifiable view on the property values held in this properties instance
-
getLogger
public java.io.OutputStream getLogger()
Description copied from interface:ServiceManager
Returns the logger for the connection to the service manager.- Specified by:
getLogger
in interfaceServiceManager
- Returns:
- Returns the out.
-
setLogger
public void setLogger(java.io.OutputStream logger)
Description copied from interface:ServiceManager
Sets the logger for the connection to the service manager.- Specified by:
setLogger
in 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.SQLException
java.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:ServiceManager
Obtains the server version through a service call.- Specified by:
getServerVersion
in interfaceServiceManager
- Returns:
- Parsed server version, or
GDSServerVersion.INVALID_VERSION
if parsing failed. - Throws:
java.sql.SQLException
- For errors connecting to the service manager.
-
-