String value = (String) entry.getValue();
if (property.startsWith(ServerConstants.SC_KEY_DBNAME + ".") ||
property.startsWith(ServerConstants.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(ServerConstants.SC_KEY_PORT, value);
} else if ("bind".equals(property)) {
properties.setProperty(ServerConstants.SC_KEY_ADDRESS, value);
} else {
properties.setProperty(property, value);
}
}
properties.setProperty(ServerConstants.SC_KEY_NO_SYSTEM_EXIT, "true");
boolean disabled = Boolean.parseBoolean(properties.getProperty("disabled"));
ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
if (!disabled && containerSystem != null) {
NamingEnumeration<Binding> bindings = null;
try {
bindings = containerSystem.getJNDIContext().listBindings("java:openejb/Resource/");
Set<String> dbnames = new TreeSet<String>();
for (Binding binding : Collections.list(bindings)) {
Object value = binding.getObject();
if (value instanceof BasicDataSource) {
BasicDataSource jdbc = (BasicDataSource) value;
String path = getPath(jdbc);
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(ServerConstants.SC_KEY_DBNAME + "." + dbnames.size(), dbname);