use of org.eclipse.wst.server.core.internal.Runtime in project liferay-ide by liferay.
the class ServerStartup method importGlobalRuntimes.
private void importGlobalRuntimes(File runtimesFile) {
try {
final IMemento runtimesMemento = XMLMemento.loadMemento(new FileInputStream(runtimesFile));
if (runtimesMemento != null) {
final ResourceManager resourceManager = ResourceManager.getInstance();
final IMemento[] mementos = runtimesMemento.getChildren("runtime");
if (ListUtil.isNotEmpty(mementos)) {
for (IMemento memento : mementos) {
final Runtime runtime = new Runtime(null);
try {
final Method loadFromMemento = Base.class.getDeclaredMethod("loadFromMemento", IMemento.class, IProgressMonitor.class);
if (loadFromMemento != null) {
loadFromMemento.setAccessible(true);
loadFromMemento.invoke(runtime, memento, null);
if (ServerCore.findRuntime(runtime.getId()) == null) {
final Method addRuntime = ResourceManager.class.getDeclaredMethod("addRuntime", IRuntime.class);
if (addRuntime != null) {
addRuntime.setAccessible(true);
addRuntime.invoke(resourceManager, runtime);
}
}
}
} catch (Exception e) {
LiferayServerUI.logError("Unable to load runtime from memento", e);
}
}
}
}
} catch (FileNotFoundException e) {
}
}
Aggregations