final String value = (String) entry.getValue();
if (property.startsWith(sc_key_dbname + ".") ||
property.startsWith(sc_key_database + ".")) {
throw new ServiceException("Databases cannot be declared in the hsql.properties. " +
"Instead declare a database connection in the openejb.conf file");
}
if ("port".equals(property)) {
properties.setProperty(sc_key_port, value);
} else if ("bind".equals(property)) {
properties.setProperty(sc_key_address, value);
} else {
properties.setProperty(property, value);
}
}
properties.setProperty(sc_key_no_system_exit, "true");
final boolean disabled = Boolean.parseBoolean(properties.getProperty("disabled"));
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
if (!disabled && containerSystem != null) {
final NamingEnumeration<Binding> bindings;
try {
bindings = containerSystem.getJNDIContext().listBindings("openejb/Resource/");
final Set<String> dbnames = new TreeSet<String>();
for (final Binding binding : Collections.list(bindings)) {
final Object value = binding.getObject();
if (value instanceof DataSource) {
final DataSource jdbc = (DataSource) value;
Connection connection = null;
String path = null;
try {
connection = jdbc.getConnection();
final DatabaseMetaData meta = connection.getMetaData();
path = getPath(meta.getDriverName(), meta.getURL());
} catch (final Throwable t) {
continue;
} finally {
if (connection != null) {
try {
connection.close();
} catch (final SQLException sqlEx) {
// no-op
}
}
}
if (path != null) {
if (dbnames.size() > 9) {
throw new ServiceException("Hsql Server can only host 10 database instances");
}
String dbname = path.substring(path.lastIndexOf(':') + 1);
dbname = dbname.substring(dbname.lastIndexOf('/') + 1);
if (!dbnames.contains(dbname)) {
properties.put(sc_key_dbname + "." + dbnames.size(), dbname);