private void dynamicReload()
{
final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
final Properties currentSystemProperties = System.getProperties();
boolean hasChanged = false;
Configuration newConfig = null;
try
{
Thread.currentThread().setContextClassLoader(loadingCL);
hasChanged = true;
System.setProperties(loadingSystemProperties);
ConfigurationManager cm = loadConfigurationManager(this, false);
if (cm != null)
{
newConfig = cm.getConfiguration();
}
}
catch (Exception e)
{
if (LOG.isDebugEnabled())
{
LOG.debug("Could not load the new configuration of the root container", e);
}
}
finally
{
if (hasChanged)
{
Thread.currentThread().setContextClassLoader(currentClassLoader);
System.setProperties(currentSystemProperties);
}
}
if (newConfig == null)
{
// We have no way to know if the configuration of the root container has changed so
// we reload everything
LOG.info("The new configuration of the root container could not be loaded,"
+ " thus everything will be reloaded");
reload();
return;
}
Configuration currentConfig = getConfiguration();
if (currentConfig == null)
{
// We have no way to know if the configuration of the root container has changed so
// we reload everything
LOG.info("The current configuration of the root container could not be loaded," +
" thus everything will be reloaded");
reload();
return;
}
if (newConfig.getCurrentSize() != currentConfig.getCurrentSize()
|| newConfig.getCurrentHash() != currentConfig.getCurrentHash())
{
// The root container has changed so we reload everything
LOG.info("The configuration of the root container has changed," +
" thus everything will be reloaded");
reload();