com.atlassian.config.bootstrap
Class DefaultAtlassianBootstrapManager

java.lang.Object
  extended by com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager
All Implemented Interfaces:
AtlassianBootstrapManager

public class DefaultAtlassianBootstrapManager
extends Object
implements AtlassianBootstrapManager

Generic Bootstrap Manager using Spring & Hibernate


Field Summary
protected  ApplicationConfiguration applicationConfig
           
protected  String bootstrapFailureReason
           
protected  boolean bootstrapped
           
protected  HibernateConfig hibernateConfig
           
protected  HibernateConfigurator hibernateConfigurator
           
protected  HomeLocator homeLocator
           
static org.apache.log4j.Logger log
           
protected  SetupPersister setupPersister
           
 
Constructor Summary
DefaultAtlassianBootstrapManager()
           
 
Method Summary
protected  void afterConfigurationLoaded()
          Extension point for initialization performed after configuration is loaded
 void bootstrapDatabase(DatabaseDetails dbDetails, boolean embedded)
          Mediates the call to HibernateConfigurator's instance method, configureDatabase(dbDetails, embedded)
 void bootstrapDatasource(String datasourceName, String hibernateDialect)
          Mediates the call to HibernateConfigurator's instance method, configureDatasource(datasourceName, hibernateDialect)
 boolean databaseContainsExistingData(Connection connection)
          Returns true if any of the specified tables exists, otherwise false.
protected  void finishBootstrapInitialisation()
          Generic extension point to run before bootstrapping can be successful.
 ApplicationConfiguration getApplicationConfig()
           
 String getApplicationHome()
           
 String getBootstrapFailureReason()
           
 String getBuildNumber()
          This is the build number of the current version that the user is running under.
 String getConfiguredApplicationHome()
           
protected  String getDbUrl(DatabaseDetails dbDetails)
          Get the URL form the DatabaseDetails object.
 String getFilePathProperty(String key)
           
 HibernateConfig getHibernateConfig()
           
 HibernateConfigurator getHibernateConfigurator()
           
 Properties getHibernateProperties()
          Gets all hibernate properties from the config starting 'hibernate.'
 HomeLocator getHomeLocator()
           
 String getOperation()
           
 Map getPropertiesWithPrefix(String prefix)
          Get a map of all properties with a given prefix.
 Object getProperty(String key)
          Get a single property.
 Collection getPropertyKeys()
          Retrieve all property keys.
 SetupPersister getSetupPersister()
           
 String getString(String key)
          Convenience method to retrieve a property as a string.
 List getTables()
           
 Connection getTestDatabaseConnection(DatabaseDetails databaseDetails)
          Ensure we can open a connection to the configured database.
 Connection getTestDatasourceConnection(String datasourceName)
          Gets a test connection to the datasource.
 void init()
          Does final initialisation of the BootstrapManager, including looking up the confluence home (Previously was the afterPropertiesSet method)
 boolean isApplicationHomeValid()
           
 boolean isBootstrapped()
           
 boolean isPropertyTrue(String prop)
           
 boolean isSetupComplete()
          This should be the first method called before any bootstrapManager logic is performed.
protected  boolean performPersistenceUpgrade()
          Extension point for peforming custom upgardes of dB
protected  void postBootstrapDatabase()
          Allows a custom actions to be performed after bootstrapping the database
 void publishConfiguration()
           
 void removeProperty(String key)
          Remove a single property.
 void save()
           
 void setApplicationConfig(ApplicationConfiguration applicationConfig)
           
 void setBuildNumber(String buildNumber)
           
 void setHibernateConfig(HibernateConfig hibernateConfig)
           
 void setHibernateConfigurator(HibernateConfigurator hibernateConfigurator)
           
 void setHomeLocator(HomeLocator homeLocator)
           
 void setOperation(String operation)
           
 void setProperty(String key, Object value)
          Set a single property.
 void setSetupComplete(boolean complete)
           
 void setSetupPersister(SetupPersister setupPersister)
           
 void setTables(List tables)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log

bootstrapped

protected boolean bootstrapped

bootstrapFailureReason

protected String bootstrapFailureReason

applicationConfig

protected ApplicationConfiguration applicationConfig

setupPersister

protected SetupPersister setupPersister

homeLocator

protected HomeLocator homeLocator

hibernateConfigurator

protected HibernateConfigurator hibernateConfigurator

hibernateConfig

protected HibernateConfig hibernateConfig
Constructor Detail

DefaultAtlassianBootstrapManager

public DefaultAtlassianBootstrapManager()
Method Detail

init

public void init()
          throws BootstrapException
Description copied from interface: AtlassianBootstrapManager
Does final initialisation of the BootstrapManager, including looking up the confluence home (Previously was the afterPropertiesSet method)

Specified by:
init in interface AtlassianBootstrapManager
Throws:
BootstrapException

publishConfiguration

public void publishConfiguration()
Specified by:
publishConfiguration in interface AtlassianBootstrapManager

getProperty

public Object getProperty(String key)
Get a single property.

Specified by:
getProperty in interface AtlassianBootstrapManager

setProperty

public void setProperty(String key,
                        Object value)
Set a single property.

Specified by:
setProperty in interface AtlassianBootstrapManager

isPropertyTrue

public boolean isPropertyTrue(String prop)
Specified by:
isPropertyTrue in interface AtlassianBootstrapManager

removeProperty

public void removeProperty(String key)
Remove a single property.

Specified by:
removeProperty in interface AtlassianBootstrapManager

getString

public String getString(String key)
Convenience method to retrieve a property as a string.

Specified by:
getString in interface AtlassianBootstrapManager

getFilePathProperty

public String getFilePathProperty(String key)
Specified by:
getFilePathProperty in interface AtlassianBootstrapManager

getPropertyKeys

public Collection getPropertyKeys()
Retrieve all property keys.

Specified by:
getPropertyKeys in interface AtlassianBootstrapManager

getPropertiesWithPrefix

public Map getPropertiesWithPrefix(String prefix)
Get a map of all properties with a given prefix.

Specified by:
getPropertiesWithPrefix in interface AtlassianBootstrapManager

save

public void save()
          throws ConfigurationException
Specified by:
save in interface AtlassianBootstrapManager
Throws:
ConfigurationException

getConfiguredApplicationHome

public String getConfiguredApplicationHome()
Specified by:
getConfiguredApplicationHome in interface AtlassianBootstrapManager

isSetupComplete

public boolean isSetupComplete()
This should be the first method called before any bootstrapManager logic is performed.

Specified by:
isSetupComplete in interface AtlassianBootstrapManager
Returns:
true for a complete bootstrapManager, otherwise false

setSetupComplete

public void setSetupComplete(boolean complete)
Specified by:
setSetupComplete in interface AtlassianBootstrapManager

getBuildNumber

public String getBuildNumber()
Description copied from interface: AtlassianBootstrapManager
This is the build number of the current version that the user is running under. This version is stored in their confluence home confluence.cfg.xml file

Specified by:
getBuildNumber in interface AtlassianBootstrapManager

setBuildNumber

public void setBuildNumber(String buildNumber)
Specified by:
setBuildNumber in interface AtlassianBootstrapManager

getHibernateProperties

public Properties getHibernateProperties()
Gets all hibernate properties from the config starting 'hibernate.'

Specified by:
getHibernateProperties in interface AtlassianBootstrapManager
Returns:
all hibernate properties in a Properties map

bootstrapDatabase

public void bootstrapDatabase(DatabaseDetails dbDetails,
                              boolean embedded)
                       throws BootstrapException
Mediates the call to HibernateConfigurator's instance method, configureDatabase(dbDetails, embedded)

Specified by:
bootstrapDatabase in interface AtlassianBootstrapManager
Parameters:
dbDetails - - DatabaseDetails object holding connection details
embedded - - true if using the default Confluence database, HSQLDB
Throws:
BootstrapException

bootstrapDatasource

public void bootstrapDatasource(String datasourceName,
                                String hibernateDialect)
                         throws BootstrapException
Mediates the call to HibernateConfigurator's instance method, configureDatasource(datasourceName, hibernateDialect)

Specified by:
bootstrapDatasource in interface AtlassianBootstrapManager
Parameters:
datasourceName -
hibernateDialect -
Throws:
BootstrapException

getTestDatabaseConnection

public Connection getTestDatabaseConnection(DatabaseDetails databaseDetails)
                                     throws BootstrapException
Ensure we can open a connection to the configured database. If this fails, then the database is down or we got the connection string wrong.

Specified by:
getTestDatabaseConnection in interface AtlassianBootstrapManager
Throws:
BootstrapException - if the connection fails for any reason.

getTestDatasourceConnection

public Connection getTestDatasourceConnection(String datasourceName)
                                       throws BootstrapException
Gets a test connection to the datasource.

Specified by:
getTestDatasourceConnection in interface AtlassianBootstrapManager
Throws:
BootstrapException - if a connection cannot be made.

databaseContainsExistingData

public boolean databaseContainsExistingData(Connection connection)
Returns true if any of the specified tables exists, otherwise false.

Specified by:
databaseContainsExistingData in interface AtlassianBootstrapManager
Parameters:
connection - the Connection to the Db to check
See Also:
#setTables(List)}

isApplicationHomeValid

public boolean isApplicationHomeValid()
Specified by:
isApplicationHomeValid in interface AtlassianBootstrapManager

performPersistenceUpgrade

protected boolean performPersistenceUpgrade()
Extension point for peforming custom upgardes of dB

Returns:
true if successful, false if failed

finishBootstrapInitialisation

protected void finishBootstrapInitialisation()
                                      throws ConfigurationException
Generic extension point to run before bootstrapping can be successful. Common things to do here includes setting up the license

Throws:
ConfigurationException - is thrown if bootstrapping should fail

getDbUrl

protected String getDbUrl(DatabaseDetails dbDetails)
Get the URL form the DatabaseDetails object. Allows sub-classes to post-process the URL

Parameters:
dbDetails -
Returns:
database URL

postBootstrapDatabase

protected void postBootstrapDatabase()
Allows a custom actions to be performed after bootstrapping the database


afterConfigurationLoaded

protected void afterConfigurationLoaded()
                                 throws ConfigurationException
Extension point for initialization performed after configuration is loaded

Throws:
ConfigurationException

setApplicationConfig

public void setApplicationConfig(ApplicationConfiguration applicationConfig)

setHomeLocator

public void setHomeLocator(HomeLocator homeLocator)

setSetupPersister

public void setSetupPersister(SetupPersister setupPersister)

getHomeLocator

public HomeLocator getHomeLocator()

getApplicationConfig

public ApplicationConfiguration getApplicationConfig()
Specified by:
getApplicationConfig in interface AtlassianBootstrapManager

getApplicationHome

public String getApplicationHome()
Specified by:
getApplicationHome in interface AtlassianBootstrapManager

getSetupPersister

public SetupPersister getSetupPersister()
Specified by:
getSetupPersister in interface AtlassianBootstrapManager

isBootstrapped

public boolean isBootstrapped()
Specified by:
isBootstrapped in interface AtlassianBootstrapManager
Returns:
boolean indicating whether Confluence is bootstrapped.

getOperation

public String getOperation()
Specified by:
getOperation in interface AtlassianBootstrapManager

setOperation

public void setOperation(String operation)
Specified by:
setOperation in interface AtlassianBootstrapManager

getHibernateConfigurator

public HibernateConfigurator getHibernateConfigurator()
Specified by:
getHibernateConfigurator in interface AtlassianBootstrapManager

setHibernateConfigurator

public void setHibernateConfigurator(HibernateConfigurator hibernateConfigurator)
Specified by:
setHibernateConfigurator in interface AtlassianBootstrapManager

getHibernateConfig

public HibernateConfig getHibernateConfig()
Specified by:
getHibernateConfig in interface AtlassianBootstrapManager

setHibernateConfig

public void setHibernateConfig(HibernateConfig hibernateConfig)

getBootstrapFailureReason

public String getBootstrapFailureReason()
Specified by:
getBootstrapFailureReason in interface AtlassianBootstrapManager

getTables

public List getTables()

setTables

public void setTables(List tables)


Atlassian Config is developed by Atlassian Software Systems.