log("Using properties file "+_ojbPropertiesFile.getAbsolutePath(), Project.MSG_INFO);
System.setProperty("OJB.properties", _ojbPropertiesFile.getAbsolutePath());
}
MetadataManager metadataManager = MetadataManager.getInstance();
RepositoryPersistor persistor = new RepositoryPersistor();
if (_repositoryFile != null)
{
if (!_repositoryFile.exists())
{
throw new BuildException("Could not load the specified repository file "+_repositoryFile);
}
log("Loading repository file "+_repositoryFile.getAbsolutePath(), Project.MSG_INFO);
// this will load the info from the specified repository file
// and merge it with the existing info (if it has been loaded)
metadataManager.mergeConnectionRepository(persistor.readConnectionRepository(_repositoryFile.getAbsolutePath()));
metadataManager.mergeDescriptorRepository(persistor.readDescriptorRepository(_repositoryFile.getAbsolutePath()));
}
else if (metadataManager.connectionRepository().getAllDescriptor().isEmpty() &&
metadataManager.getGlobalRepository().getDescriptorTable().isEmpty())
{
// Seems nothing was loaded, probably because we're not starting in the directory
// that the properties file is in, and the repository file path is relative
// So lets try to resolve this path and load the repository info manually
Properties props = new Properties();
props.load(new FileInputStream(_ojbPropertiesFile));
String repositoryPath = props.getProperty("repositoryFile", "repository.xml");
File repositoryFile = new File(repositoryPath);
if (!repositoryFile.exists())
{
repositoryFile = new File(_ojbPropertiesFile.getParentFile(), repositoryPath);
}
metadataManager.mergeConnectionRepository(persistor.readConnectionRepository(repositoryFile.getAbsolutePath()));
metadataManager.mergeDescriptorRepository(persistor.readDescriptorRepository(repositoryFile.getAbsolutePath()));
}
// we might have to determine the default pb key ourselves
if (metadataManager.getDefaultPBKey() == null)
{
for (Iterator it = metadataManager.connectionRepository().getAllDescriptor().iterator(); it.hasNext();)