use of org.eclipse.wst.server.core.model.ServerDelegate in project liferay-ide by liferay.
the class ServerStartup method importGlobalServers.
private void importGlobalServers(File serversFile) {
try {
final IMemento serversMemento = XMLMemento.loadMemento(new FileInputStream(serversFile));
if (serversMemento != null) {
final ResourceManager resourceManager = ResourceManager.getInstance();
final IMemento[] mementos = serversMemento.getChildren("server");
if (ListUtil.isNotEmpty(mementos)) {
for (IMemento memento : mementos) {
final Server server = new Server(null);
try {
final Method loadFromMemento = Base.class.getDeclaredMethod("loadFromMemento", IMemento.class, IProgressMonitor.class);
if (loadFromMemento != null) {
loadFromMemento.setAccessible(true);
loadFromMemento.invoke(server, memento, null);
if (ServerCore.findServer(server.getId()) == null) {
final Method addServer = ResourceManager.class.getDeclaredMethod("addServer", IServer.class);
if (addServer != null) {
addServer.setAccessible(true);
addServer.invoke(resourceManager, server);
final IServerWorkingCopy wc = server.createWorkingCopy();
ServerDelegate delegate = (ServerDelegate) wc.loadAdapter(ServerDelegate.class, null);
delegate.importRuntimeConfiguration(wc.getRuntime(), null);
wc.save(true, null);
}
}
}
} catch (Exception e) {
LiferayServerUI.logError("Unable to load server from memento", e);
}
}
}
}
} catch (FileNotFoundException e) {
}
}
use of org.eclipse.wst.server.core.model.ServerDelegate in project liferay-ide by liferay.
the class PortalBundleTests method testPortalServerDelegateName.
@Test
@Ignore
public void testPortalServerDelegateName() throws Exception {
if (shouldSkipBundleTests())
return;
IServerType portalServerType = ServerCore.findServerType(PortalServer.ID);
assertNotNull(portalServerType);
IProgressMonitor monitor = new NullProgressMonitor();
IServerWorkingCopy newServer = portalServerType.createServer(null, null, monitor);
assertNotNull(newServer);
assertEquals("Liferay 7.x at localhost", newServer.getName());
newServer.setHost("127.0.0.1");
ServerDelegate delegate = (ServerDelegate) newServer.loadAdapter(ServerDelegate.class, monitor);
delegate.newServerDetailsChanged(monitor);
assertEquals("Liferay 7.x at 127.0.0.1", newServer.getName());
}
use of org.eclipse.wst.server.core.model.ServerDelegate in project liferay-ide by liferay.
the class ServerCoreBase method setupServer.
protected void setupServer() throws Exception {
final NullProgressMonitor npm = new NullProgressMonitor();
final IServerWorkingCopy serverWC = createServerForRuntime("6.2.0", runtime);
ServerDelegate delegate = (ServerDelegate) serverWC.loadAdapter(ServerDelegate.class, null);
delegate.importRuntimeConfiguration(serverWC.getRuntime(), null);
server = serverWC.save(true, npm);
assertNotNull(server);
}
Aggregations