de.smartics.properties.spi.config.ds
Class DefaultDataSourceManager.Builder

Package class diagram package DefaultDataSourceManager.Builder
java.lang.Object
  extended by de.smartics.properties.spi.config.ds.AbstractDataSourceDescriptor.Builder
      extended by de.smartics.properties.spi.config.ds.DefaultDataSourceManager.Builder
Direct Known Subclasses:
PropertiesStore.Builder
Enclosing class:
DefaultDataSourceManager

public static class DefaultDataSourceManager.Builder
     
     
extends AbstractDataSourceDescriptor.Builder

The builder of manager instances.


Field Summary
protected  DataSourceProxy dataSourceProxy
          The proxy to provide access to a data source.
static String DEFAULT_CREATE_TABLE_TEMPLATE
          The default table template.
protected  String insertOrUpdateSqlStatementTemplate
          The template to create an SQL statement to insert or update a value in the table, dependent on if the value is already in the database or not.
 
Constructor Summary
DefaultDataSourceManager.Builder()
           
 
Method Summary
 DefaultDataSourceManager build()
          Creates the instance.
 void setCreateTableSqlStatementTemplate(String createTableSqlStatementTemplate)
          Sets the template to create an SQL statement to create the configuration table.
 void setDataSourceProxy(DataSourceProxy dataSourceProxy)
          Sets the proxy to provide access to a data source.
 void setDropTable(boolean dropTable)
          Sets the value for dropTable.
 void setIgnoreTableCreationProblems(boolean ignoreTableCreationProblems)
          Sets the flag signals that any problems encountered on creating the table should be ignored.
 void setInitialProperties(Map<String,Map<String,String>> initialProperties)
          Sets the properties to fill the database initially.
 void setInsertOrUpdateSqlStatementTemplate(String insertOrUpdateSqlStatementTemplate)
          Set the template to insert or update a value in the configuration table.
 
Methods inherited from class de.smartics.properties.spi.config.ds.AbstractDataSourceDescriptor.Builder
setConfigColumn, setNameColumn, setTable, setValueColumn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CREATE_TABLE_TEMPLATE

public static final String DEFAULT_CREATE_TABLE_TEMPLATE
The default table template.

The value of this constant is "CREATE TABLE IF NOT EXISTS ${table} (${configColumn} VARCHAR(128) NOT NULL, ${nameColumn} VARCHAR(64) NOT NULL, ${valueColumn} VARCHAR(255), CONSTRAINT prime UNIQUE (${configColumn}, ${nameColumn}))".

Constant Field Value:
"CREATE TABLE IF NOT EXISTS ${table} (${configColumn} VARCHAR(128) NOT NULL, ${nameColumn} VARCHAR(64) NOT NULL, ${valueColumn} VARCHAR(255), CONSTRAINT prime UNIQUE (${configColumn}, ${nameColumn}))"

dataSourceProxy

protected DataSourceProxy dataSourceProxy
The proxy to provide access to a data source.


insertOrUpdateSqlStatementTemplate

protected String insertOrUpdateSqlStatementTemplate
The template to create an SQL statement to insert or update a value in the table, dependent on if the value is already in the database or not. Use ${table}, ${configColumn}, ${nameColumn} and ${valueColumn} to reference the name of the configuration table, the column that stores the property names and the column storing the property values.

Constructor Detail

DefaultDataSourceManager.Builder

public DefaultDataSourceManager.Builder()
Method Detail

setCreateTableSqlStatementTemplate

public final void setCreateTableSqlStatementTemplate(String createTableSqlStatementTemplate)
Sets the template to create an SQL statement to create the configuration table. Use ${table}, ${configColumn}, ${nameColumn} and ${valueColumn} to reference the name of the configuration table, the column that stores the property names and the column storing the property values.

Per default the default table template is used.

Parameters:
createTableSqlStatementTemplate - the template to create an SQL statement to create the configuration table.
See Also:
DEFAULT_CREATE_TABLE_TEMPLATE

setInsertOrUpdateSqlStatementTemplate

public void setInsertOrUpdateSqlStatementTemplate(String insertOrUpdateSqlStatementTemplate)
Set the template to insert or update a value in the configuration table.

Parameters:
insertOrUpdateSqlStatementTemplate - the template to set.

setDataSourceProxy

public final void setDataSourceProxy(DataSourceProxy dataSourceProxy)
                              throws NullPointerException
Sets the proxy to provide access to a data source.

Parameters:
dataSourceProxy - the proxy to provide access to a data source.
Throws:
NullPointerException - of dataSourceProxy is null.

setInitialProperties

public final void setInitialProperties(Map<String,Map<String,String>> initialProperties)
Sets the properties to fill the database initially. May be null.

Parameters:
initialProperties - the properties to fill the database initially.

setDropTable

public final void setDropTable(boolean dropTable)
Sets the value for dropTable.

Signals to drop the properties table before creation.

Parameters:
dropTable - the value for dropTable.

setIgnoreTableCreationProblems

public final void setIgnoreTableCreationProblems(boolean ignoreTableCreationProblems)
Sets the flag signals that any problems encountered on creating the table should be ignored. Useful if there are no means to check is a database table already exists.

Parameters:
ignoreTableCreationProblems - the flag signals that any problems encountered on creating the table should be ignored.

build

public DefaultDataSourceManager build()
                               throws NullPointerException
Creates the instance.

Returns:
the created instance.
Throws:
NullPointerException - if no data source proxy has been provided.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.