OPENJPA-2139 reset the BrokerFactory state if an Exception occured

This happens e.g. if the database is not available at the time the
first DB access is performed. This did lead to a complete hook up
until the whole application got restarted after the db reappeared.
This fix will now ensure that all the column-key caching and stuff
will be tried over again until the db is available again.


git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1311191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Struberg 2012-04-09 10:26:49 +00:00
parent 60e42eddda
commit 08b0dd2913
1 changed files with 9 additions and 3 deletions

View File

@ -612,8 +612,9 @@ public abstract class AbstractBrokerFactory
_readOnly = true;
Log log = _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);
if (log.isInfoEnabled())
if (log.isInfoEnabled()) {
log.info(getFactoryInitializationBanner());
}
if (log.isTraceEnabled()) {
Map<String,Object> props = _conf.toProperties(true);
String lineSep = J2DoPrivHelper.getLineSeparator();
@ -644,13 +645,18 @@ public abstract class AbstractBrokerFactory
// avoid synchronization
_conf.setReadOnly(Configuration.INIT_STATE_FREEZING);
_conf.instantiateAll();
if (_conf.isInitializeEagerly())
_conf.setReadOnly(Configuration.INIT_STATE_FROZEN);
if (_conf.isInitializeEagerly()) {
_conf.setReadOnly(Configuration.INIT_STATE_FROZEN);
}
// fire an event for all the broker factory listeners
// registered on the configuration.
_conf.getBrokerFactoryEventManager().fireEvent(
new BrokerFactoryEvent(this,
BrokerFactoryEvent.BROKER_FACTORY_CREATED));
} catch (RuntimeException e) {
// if the db connection is not available we need to reset the state
_readOnly = false;
throw e;
} finally {
unlock();
}