org.firebirdsql.gds.impl
Class GDSFactory

java.lang.Object
  extended by org.firebirdsql.gds.impl.GDSFactory

public class GDSFactory
extends Object

The class GDSFactory exists to provide a way to obtain objects implementing GDS and Clumplet.

Version:
1.0
Author:
David Jencks

Constructor Summary
GDSFactory()
           
 
Method Summary
static Class getConnectionClass(GDSType gdsType)
          Get class extending the AbstractConnection that will be instantiated when new connection is created.
static String getDatabasePath(GDSType gdsType, String jdbcUrl)
          Get path to the database from the specified JDBC URL.
static String getDatabasePath(GDSType gdsType, String server, Integer port, String path)
          Get connection string for the specified server name, port and database name/path.
static GDS getDefaultGDS()
          Get an instance of the default GDS implemenation.
static GDSType getDefaultGDSType()
          Get default GDS type.
static GDS getGDSForType(GDSType gdsType)
          Get an instance of the specified implemenation of GDS.
static String getJdbcUrl(GDSType gdsType, String databasePath)
          Create JDBC URL for the specified GDS type and database path.
static Set getSupportedProtocols()
          Get collection of the supported JDBC protocols.
static GDSType getTypeForProtocol(String jdbcUrl)
          Get GDS type for the specified JDBC URL.
static void registerPlugin(GDSFactoryPlugin plugin)
          Register plugin for this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GDSFactory

public GDSFactory()
Method Detail

registerPlugin

public static void registerPlugin(GDSFactoryPlugin plugin)
Register plugin for this factory. Usually there is no need to register plugins, since this happens automatically during initialization of this class. However, there might be a situation when automatic plugin registration does not work.

Parameters:
plugin - instance of GDSFactoryPlugin to register.

getDefaultGDS

public static GDS getDefaultGDS()
Get an instance of the default GDS implemenation.

Returns:
A default GDS instance

getDefaultGDSType

public static GDSType getDefaultGDSType()
Get default GDS type.

Returns:
instance of GDSType.

getGDSForType

public static GDS getGDSForType(GDSType gdsType)
Get an instance of the specified implemenation of GDS.

Parameters:
gdsType - The type of the GDS instance to be returned
Returns:
A GDS implementation of the given type

getDatabasePath

public static String getDatabasePath(GDSType gdsType,
                                     String server,
                                     Integer port,
                                     String path)
                              throws GDSException
Get connection string for the specified server name, port and database name/path. This method delegates call to the factory plugin corresponding to the specified type.

Parameters:
gdsType - instance of GDSType for which connection string should be returned.
server - name or IP address of the database server, applies only to IPC and TCP connection modes, in other cases should be null.
port - port on which database server opened listening socket, applies to TCP connection mode only, may be null.
path - database name or path to the database
Returns:
full connection string that can be passed to GDS.iscAttachDatabase(String, IscDbHandle, DatabaseParameterBuffer) method.
Throws:
GDSException - if connection string cannot be obtained.

getDatabasePath

public static String getDatabasePath(GDSType gdsType,
                                     String jdbcUrl)
                              throws GDSException
Get path to the database from the specified JDBC URL. This method finds the appropriate plugin and delegates the call to it. Plugin is responsible for the call execution.

Parameters:
gdsType - type of the plugin, to which operation will be delegated to.
jdbcUrl - JDBC url from which the database path must be extracted.
Returns:
path to the database specified in the JDBC URL.
Throws:
GDSException - error when database path cannot be extracted.

getSupportedProtocols

public static Set getSupportedProtocols()
Get collection of the supported JDBC protocols.

Returns:
set of the supported protocols.

getJdbcUrl

public static String getJdbcUrl(GDSType gdsType,
                                String databasePath)
Create JDBC URL for the specified GDS type and database path.

Parameters:
gdsType - type of the plugin, to which operation will be delegated to.
databasePath - path to the database.
Returns:
newly created JDBC URL.

getTypeForProtocol

public static GDSType getTypeForProtocol(String jdbcUrl)
Get GDS type for the specified JDBC URL. This method finds the plugin corresponding to the specified type and delegates the call to it.

Parameters:
jdbcUrl - JDBC URL for which GDS type should be obtained.
Returns:
instance of GDSType.

getConnectionClass

public static Class getConnectionClass(GDSType gdsType)
Get class extending the AbstractConnection that will be instantiated when new connection is created. This method finds the plugin for the specified type and delegates the call to it.

Parameters:
gdsType - instance of GDSType
Returns:
class to instantiate for the database connection.


Copyright © 2001-2010. All Rights Reserved.