IDEMPIERE-1218 Improve discovery of hazelcast configuration file.
This commit is contained in:
parent
fa5ba42381
commit
1e27469b0f
|
@ -15,7 +15,6 @@ package org.idempiere.hazelcast.service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -75,21 +74,46 @@ public class Activator implements BundleActivator {
|
||||||
future = executor.submit(new Runnable() {
|
future = executor.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String dataArea = System.getProperty("osgi.install.area");
|
File file = null;
|
||||||
|
//try idempiere home
|
||||||
|
String dataArea = System.getProperty("IDEMPIERE_HOME");
|
||||||
|
if (dataArea != null && dataArea.trim().length() > 0) {
|
||||||
|
try {
|
||||||
|
file = new File(dataArea, "hazelcast.xml");
|
||||||
|
if (!file.exists())
|
||||||
|
file = null;
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
//try working directory
|
||||||
|
if (file == null) {
|
||||||
|
dataArea = System.getProperty("user.dir");
|
||||||
|
if (dataArea != null && dataArea.trim().length() > 0) {
|
||||||
|
try {
|
||||||
|
file = new File(dataArea, "hazelcast.xml");
|
||||||
|
if (!file.exists())
|
||||||
|
file = null;
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//try osgi install area
|
||||||
|
if (file == null) {
|
||||||
|
dataArea = System.getProperty("osgi.install.area");
|
||||||
if (dataArea != null && dataArea.trim().length() > 0) {
|
if (dataArea != null && dataArea.trim().length() > 0) {
|
||||||
try {
|
try {
|
||||||
URL url = new URL(dataArea);
|
URL url = new URL(dataArea);
|
||||||
File file = new File(url.getPath(), "hazelcast.xml");
|
file = new File(url.getPath(), "hazelcast.xml");
|
||||||
if (file.exists()) {
|
if (!file.exists())
|
||||||
|
file = null;
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file != null && file.exists()) {
|
||||||
try {
|
try {
|
||||||
Config config = new FileSystemXmlConfig(file);
|
Config config = new FileSystemXmlConfig(file);
|
||||||
hazelcastInstance = Hazelcast.newHazelcastInstance(config);
|
hazelcastInstance = Hazelcast.newHazelcastInstance(config);
|
||||||
return;
|
return;
|
||||||
} catch (FileNotFoundException e) {}
|
} catch (FileNotFoundException e) {}
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException e1) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hazelcastInstance = Hazelcast.newHazelcastInstance(null);
|
hazelcastInstance = Hazelcast.newHazelcastInstance(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue