com.atlassian.jira.config.database
Class DatabaseConfigurationManagerImpl

java.lang.Object
  extended by com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl
All Implemented Interfaces:
DatabaseConfigurationManager

public class DatabaseConfigurationManagerImpl
extends Object
implements DatabaseConfigurationManager

A threadsafe implementation which reads and writes configuration for the database using the given DatabaseConfigurationLoader. Caches configuration.


Constructor Summary
DatabaseConfigurationManagerImpl(JiraHome jiraHome, DatabaseConfigurationLoader databaseConfigLoader, ComponentLocator componentLocator)
           
 
Method Summary
 void activateDatabase()
          Initialises the first connection to the database and causes each enqueued runnable that registered with DatabaseConfigurationManager.doNowOrWhenDatabaseActivated(Runnable, String) to be run.
 void createDbConfigFromEntityDefinition()
          Creates a new dbconfig.xml usinfg the values in entityengine.xml if there are any Allows for upgrade from pre 5.0 instances
 void doNowOrWhenDatabaseActivated(Runnable runnable, String desc)
          Requests that work that needs to read from and write to the database be done.
 void doNowOrWhenDatabaseConfigured(Runnable runnable, String desc)
          Requests that work dependent on the database configuration be done.
 DatabaseConfig getDatabaseConfiguration()
          Gets the current database configuration.
 DatabaseConfig getInternalDatabaseConfiguration()
          Provides the DatabaseConfig that represents the embedded JIRA database.
 boolean isDatabaseSetup()
          Returns true only if the database configuration is available.
 void setDatabaseConfiguration(DatabaseConfig databaseConfiguration)
          Persists the given config as JIRA's database configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseConfigurationManagerImpl

public DatabaseConfigurationManagerImpl(JiraHome jiraHome,
                                        DatabaseConfigurationLoader databaseConfigLoader,
                                        ComponentLocator componentLocator)
Method Detail

setDatabaseConfiguration

public void setDatabaseConfiguration(DatabaseConfig databaseConfiguration)
Description copied from interface: DatabaseConfigurationManager
Persists the given config as JIRA's database configuration. This must only be done once.

Specified by:
setDatabaseConfiguration in interface DatabaseConfigurationManager
Parameters:
databaseConfiguration - the config to use for JIRA's database connection.

getDatabaseConfiguration

public DatabaseConfig getDatabaseConfiguration()
Description copied from interface: DatabaseConfigurationManager
Gets the current database configuration.

Specified by:
getDatabaseConfiguration in interface DatabaseConfigurationManager
Returns:
the config if configured.

createDbConfigFromEntityDefinition

public void createDbConfigFromEntityDefinition()
Description copied from interface: DatabaseConfigurationManager
Creates a new dbconfig.xml usinfg the values in entityengine.xml if there are any Allows for upgrade from pre 5.0 instances

Specified by:
createDbConfigFromEntityDefinition in interface DatabaseConfigurationManager

doNowOrWhenDatabaseActivated

public void doNowOrWhenDatabaseActivated(Runnable runnable,
                                         String desc)
Description copied from interface: DatabaseConfigurationManager
Requests that work that needs to read from and write to the database be done. If the database is already active, the runnable will be run now in the calling thread. If not, it will be enqueued until the database configuration is provided and the database is activated via DatabaseConfigurationManager.activateDatabase(). Then it will be done in the thread that calls DatabaseConfigurationManager.activateDatabase().

Callers can be sure that the database schema will already be updated to fit the model when the given runnable is run.

Specified by:
doNowOrWhenDatabaseActivated in interface DatabaseConfigurationManager
Parameters:
runnable - The work that must be done if or when the database is activated.
desc - A description (for logging purposes) of the work.

doNowOrWhenDatabaseConfigured

public void doNowOrWhenDatabaseConfigured(Runnable runnable,
                                          String desc)
Description copied from interface: DatabaseConfigurationManager
Requests that work dependent on the database configuration be done. If the database is already configured, the runnable will be run now in the calling thread. If not, it will be enqueued until the database configuration is provided but before the database is actually activated via DatabaseConfigurationManager.activateDatabase(). Then it will be done in the thread that calls DatabaseConfigurationManager.activateDatabase().

The puropse of this method is to execute tasks that want to check or read the database configuration before the schema is modified to fit the current model.

Specified by:
doNowOrWhenDatabaseConfigured in interface DatabaseConfigurationManager
Parameters:
runnable - The work that must be done if or when the database is configured.
desc - A description (for logging purposes) of the work.

isDatabaseSetup

public boolean isDatabaseSetup()
Description copied from interface: DatabaseConfigurationManager
Returns true only if the database configuration is available.

Specified by:
isDatabaseSetup in interface DatabaseConfigurationManager
Returns:
whether the database is set up.

activateDatabase

public void activateDatabase()
Description copied from interface: DatabaseConfigurationManager
Initialises the first connection to the database and causes each enqueued runnable that registered with DatabaseConfigurationManager.doNowOrWhenDatabaseActivated(Runnable, String) to be run. Should only be run once per application boot.

Specified by:
activateDatabase in interface DatabaseConfigurationManager

getInternalDatabaseConfiguration

public DatabaseConfig getInternalDatabaseConfiguration()
Description copied from interface: DatabaseConfigurationManager
Provides the DatabaseConfig that represents the embedded JIRA database. This does not imply that this config is current or that there is any current configuration for the JIRA database.

Specified by:
getInternalDatabaseConfiguration in interface DatabaseConfigurationManager
Returns:
the embedded database config.


Copyright © 2002-2012 Atlassian. All Rights Reserved.