Search in sources :

Example 1 with LiferayTomcatServerBehavior

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) LiferayTomcatServerBehavior(com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with LiferayTomcatServerBehavior

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]);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) LiferayTomcatServerBehavior(com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) LiferayTomcatServer(com.liferay.ide.server.tomcat.core.LiferayTomcatServer) ILiferayTomcatServer(com.liferay.ide.server.tomcat.core.ILiferayTomcatServer) Test(org.junit.Test)

Example 3 with LiferayTomcatServerBehavior

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]);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ILiferayTomcatServerWC(com.liferay.ide.server.tomcat.core.ILiferayTomcatServerWC) IServer(org.eclipse.wst.server.core.IServer) LiferayTomcatServerBehavior(com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) Test(org.junit.Test)

Example 4 with LiferayTomcatServerBehavior

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]);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) LiferayTomcatServerBehavior(com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) Test(org.junit.Test)

Example 5 with LiferayTomcatServerBehavior

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);
}
Also used : ServerEvent(org.eclipse.wst.server.core.ServerEvent) LiferayTomcatServerBehavior(com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior) IServerListener(org.eclipse.wst.server.core.IServerListener)

Aggregations

LiferayTomcatServerBehavior (com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior)5 IServer (org.eclipse.wst.server.core.IServer)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)3 Test (org.junit.Test)3 ILiferayTomcatServer (com.liferay.ide.server.tomcat.core.ILiferayTomcatServer)1 ILiferayTomcatServerWC (com.liferay.ide.server.tomcat.core.ILiferayTomcatServerWC)1 LiferayTomcatServer (com.liferay.ide.server.tomcat.core.LiferayTomcatServer)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 IModule (org.eclipse.wst.server.core.IModule)1 IServerListener (org.eclipse.wst.server.core.IServerListener)1 ServerEvent (org.eclipse.wst.server.core.ServerEvent)1