use of com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior in project liferay-ide by liferay.
the class CleanAppServerJob method run.
@Override
protected IStatus run(IProgressMonitor monitor) {
IStatus retval = Status.OK_STATUS;
if (monitor != null) {
monitor.beginTask(Msgs.runningCleanAppServerTask, IProgressMonitor.UNKNOWN);
}
try {
final String appServerDir = ServerUtil.getPortalBundle(project).getAppServerDir().toOSString();
IServer[] servers = ServerCore.getServers();
for (IServer server : servers) {
String mode = server.getServerState() == IServer.STATE_STARTED ? server.getMode() : null;
if (mode != null) {
if (server.getRuntime().getLocation().toOSString().equals(appServerDir))
LiferayTomcatUtil.syncStopServer(server);
}
}
IStatus status = getSDK().cleanAppServer(project, bundleZipLocation, appServerDir, monitor);
assertStatus(status);
for (IServer server : servers) {
// need to mark all other server modules at needing republishing since ext will wipe out webapps folder
IModule[] modules = server.getModules();
for (IModule mod : modules) {
IModule[] m = new IModule[] { mod };
((LiferayTomcatServerBehavior) server.loadAdapter(LiferayTomcatServerBehavior.class, monitor)).setModulePublishState2(m, IServer.PUBLISH_STATE_FULL);
}
}
} catch (Exception ex) {
retval = LiferayTomcatPlugin.createErrorStatus(ex);
}
if (monitor != null) {
monitor.done();
}
return retval;
}
use of com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior in project liferay-ide by liferay.
the class ServerCustomSettingTests method testVMArgsWithCustomMemoryArgsAndUseDefaultSetting.
@Test
public void testVMArgsWithCustomMemoryArgsAndUseDefaultSetting() throws Exception {
if (shouldSkipBundleTests())
return;
final NullProgressMonitor npm = new NullProgressMonitor();
if (runtime == null) {
setupRuntime();
}
assertNotNull(runtime);
final IServerWorkingCopy serverWC = createServerForRuntime("testvmargs", runtime);
LiferayTomcatServer wc = (LiferayTomcatServer) serverWC.loadAdapter(LiferayTomcatServer.class, npm);
wc.setMemoryArgs("-Xmx2048m");
wc.setUseDefaultPortalServerSettings(true);
final IServer newServer = serverWC.save(true, npm);
final LiferayTomcatServerBehavior behavior = (LiferayTomcatServerBehavior) newServer.loadAdapter(LiferayTomcatServerBehavior.class, npm);
assertEquals("-Xmx1024m", behavior.getRuntimeVMArguments()[6]);
}
use of com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior in project liferay-ide by liferay.
the class ServerCustomSettingTests method testVMArgsWithCustomMemoryArgs.
@Test
public void testVMArgsWithCustomMemoryArgs() throws Exception {
if (shouldSkipBundleTests())
return;
final NullProgressMonitor npm = new NullProgressMonitor();
if (runtime == null) {
setupRuntime();
}
assertNotNull(runtime);
final IServerWorkingCopy serverWC = createServerForRuntime("testvmargs", runtime);
ILiferayTomcatServerWC wc = (ILiferayTomcatServerWC) serverWC.loadAdapter(ILiferayTomcatServerWC.class, npm);
wc.setMemoryArgs("-Xmx2048m");
final IServer newServer = serverWC.save(true, npm);
final LiferayTomcatServerBehavior behavior = (LiferayTomcatServerBehavior) newServer.loadAdapter(LiferayTomcatServerBehavior.class, npm);
assertEquals("-Xmx2048m", behavior.getRuntimeVMArguments()[6]);
}
use of com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior in project liferay-ide by liferay.
the class ServerCustomSettingTests method testVMArgsWithDefaultUseDefaultPortalSettings.
@Test
public void testVMArgsWithDefaultUseDefaultPortalSettings() throws Exception {
if (shouldSkipBundleTests())
return;
final NullProgressMonitor npm = new NullProgressMonitor();
if (runtime == null) {
setupRuntime();
}
assertNotNull(runtime);
final IServerWorkingCopy serverWC = createServerForRuntime("testvmargs", runtime);
final IServer newServer = serverWC.save(true, npm);
final LiferayTomcatServerBehavior behavior = (LiferayTomcatServerBehavior) newServer.loadAdapter(LiferayTomcatServerBehavior.class, npm);
assertEquals("-Xmx1024m", behavior.getRuntimeVMArguments()[6]);
}
use of com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior in project liferay-ide by liferay.
the class LiferayTomcatUtil method syncStopServer.
public static void syncStopServer(final IServer server) {
if (server.getServerState() != IServer.STATE_STARTED) {
return;
}
final LiferayTomcatServerBehavior serverBehavior = (LiferayTomcatServerBehavior) server.loadAdapter(LiferayTomcatServerBehavior.class, null);
Thread shutdownThread = new Thread() {
@Override
public void run() {
serverBehavior.stop(true);
synchronized (server) {
try {
server.wait(5000);
} catch (InterruptedException e) {
}
}
}
};
IServerListener shutdownListener = new IServerListener() {
@Override
public void serverChanged(ServerEvent event) {
if (event.getState() == IServer.STATE_STOPPED) {
synchronized (server) {
server.notifyAll();
}
}
}
};
server.addServerListener(shutdownListener);
try {
shutdownThread.start();
shutdownThread.join();
} catch (InterruptedException e) {
}
server.removeServerListener(shutdownListener);
}
Aggregations