de.topicmapslab.majortom.database.jdbc.core
Class ConnectionProviderFactory

java.lang.Object
  extended by de.topicmapslab.majortom.database.jdbc.core.ConnectionProviderFactory

public class ConnectionProviderFactory
extends java.lang.Object

Connection factory to create a specific connection provider for a given SQL dialect.

Author:
Sven Krosse

Field Summary
private static ConnectionProviderFactory factory
          the singleton
private static java.util.Map<java.lang.String,java.lang.Class<? extends IConnectionProvider>> protocols
          mapping between SQL dialect and connection provider class
 
Constructor Summary
private ConnectionProviderFactory()
          hidden constructor
 
Method Summary
static ConnectionProviderFactory getFactory()
          Get the internal singleton instance of the factory
 IConnectionProvider newConnectionProvider(SqlDialect dialect)
          Create a new connection provider for the given dialect
 IConnectionProvider newConnectionProvider(java.lang.String dialect)
          Create a new connection provider for the given dialect
 IConnectionProvider newConnectionProvider(java.lang.String dialect, java.lang.String host, java.lang.String database, java.lang.String user, java.lang.String password)
          Create a new connection provider for the given dialect
static void registerConnectionProvider(java.lang.String dialect, java.lang.Class<? extends IConnectionProvider> clazz)
          Register a new connection provider class for the given SQL dialect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

private static ConnectionProviderFactory factory
the singleton


protocols

private static java.util.Map<java.lang.String,java.lang.Class<? extends IConnectionProvider>> protocols
mapping between SQL dialect and connection provider class

Constructor Detail

ConnectionProviderFactory

private ConnectionProviderFactory()
hidden constructor

Method Detail

getFactory

public static final ConnectionProviderFactory getFactory()
Get the internal singleton instance of the factory

Returns:
the factory

registerConnectionProvider

public static void registerConnectionProvider(java.lang.String dialect,
                                              java.lang.Class<? extends IConnectionProvider> clazz)
Register a new connection provider class for the given SQL dialect

Parameters:
dialect - the SQL dialect
clazz - the connection provider class

newConnectionProvider

public IConnectionProvider newConnectionProvider(SqlDialect dialect)
                                          throws java.lang.IllegalArgumentException,
                                                 de.topicmapslab.majortom.model.exception.TopicMapStoreException
Create a new connection provider for the given dialect

Parameters:
dialect - the SQL dialect
Returns:
a new connection provider
Throws:
java.lang.IllegalArgumentException - thrown if the given SQL dialect is unknown
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if the connection provider cannot be initialized

newConnectionProvider

public IConnectionProvider newConnectionProvider(java.lang.String dialect,
                                                 java.lang.String host,
                                                 java.lang.String database,
                                                 java.lang.String user,
                                                 java.lang.String password)
                                          throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Create a new connection provider for the given dialect

Parameters:
dialect - the SQL dialect
host - the database host
database - the database names
user - the user
password - the password
Returns:
a new connection provider
Throws:
java.lang.IllegalArgumentException - thrown if the given SQL dialect is unknown
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if the connection provider cannot be initialized

newConnectionProvider

public IConnectionProvider newConnectionProvider(java.lang.String dialect)
                                          throws de.topicmapslab.majortom.model.exception.TopicMapStoreException
Create a new connection provider for the given dialect

Parameters:
dialect - the SQL dialect
Returns:
a new connection provider
Throws:
java.lang.IllegalArgumentException - thrown if the given SQL dialect is unknown
de.topicmapslab.majortom.model.exception.TopicMapStoreException - thrown if the connection provider cannot be initialized