/**
* For internal use! This method creates real new PB instances
*/
protected PersistenceBrokerInternal createNewBrokerInstance(PBKey key) throws PBFactoryException
{
if (key == null) throw new PBFactoryException("Could not create new broker with PBkey argument 'null'");
// check if the given key really exists
if (MetadataManager.getInstance().connectionRepository().getDescriptor(key) == null)
{
throw new PBFactoryException("Given PBKey " + key + " does not match in metadata configuration");
}
if (log.isEnabledFor(Logger.INFO))
{
// only count created instances when INFO-Log-Level
log.info("Create new PB instance for PBKey " + key +
", already created persistence broker instances: " + instanceCount);
// useful for testing
++this.instanceCount;
}
PersistenceBrokerInternal instance = null;
Class[] types = {PBKey.class, PersistenceBrokerFactoryIF.class};
Object[] args = {key, this};
try
{
instance = (PersistenceBrokerInternal) ClassHelper.newInstance(implementationClass, types, args);
OjbConfigurator.getInstance().configure(instance);
instance = (PersistenceBrokerInternal) InterceptorFactory.getInstance().createInterceptorFor(instance);
}
catch (Exception e)
{
log.error("Creation of a new PB instance failed", e);
throw new PBFactoryException("Creation of a new PB instance failed", e);
}
return instance;
}