Search in sources :

Example 1 with TomcatServer

use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.

the class ContextPublisherDelegate method execute.

public IStatus execute(int kind, IProgressMonitor monitor, IAdaptable info) throws CoreException {
    // this publisher only runs when there is a UI
    if (info == null)
        return Status.OK_STATUS;
    final Shell shell = (Shell) info.getAdapter(Shell.class);
    if (shell == null)
        return Status.OK_STATUS;
    IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
    TomcatServer tomcatServer = (TomcatServer) server.loadAdapter(TomcatServer.class, monitor);
    final TomcatConfiguration configuration = tomcatServer.getTomcatConfiguration();
    final boolean[] save = new boolean[1];
    List modules = (List) getTaskModel().getObject(TaskModel.TASK_MODULES);
    int size = modules.size();
    for (int i = 0; i < size; i++) {
        IModule[] module = (IModule[]) modules.get(i);
        final IModule m = module[module.length - 1];
        IWebModule webModule = (IWebModule) m.loadAdapter(IWebModule.class, monitor);
        final WebModule webModule2 = configuration.getWebModule(m);
        if (webModule != null && webModule2 != null) {
            String contextRoot = webModule.getContextRoot();
            if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0)
                contextRoot = "/" + contextRoot;
            if (!contextRoot.equals(webModule2.getPath()) && shouldPrompt(m, contextRoot)) {
                final String context = contextRoot;
                shell.getDisplay().syncExec(new Runnable() {

                    public void run() {
                        if (MessageDialog.openQuestion(shell, Messages.wizardTitle, NLS.bind(Messages.contextCleanup, m.getName()))) {
                            int index = configuration.getWebModules().indexOf(webModule2);
                            configuration.modifyWebModule(index, webModule2.getDocumentBase(), context, webModule2.isReloadable());
                            save[0] = true;
                        }
                    }
                });
                markProject(m, contextRoot);
            }
        }
    }
    if (save[0])
        tomcatServer.saveConfiguration(monitor);
    return Status.OK_STATUS;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) TomcatConfiguration(org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration) IWebModule(org.eclipse.jst.server.core.IWebModule) WebModule(org.eclipse.jst.server.tomcat.core.internal.WebModule) IWebModule(org.eclipse.jst.server.core.IWebModule) Shell(org.eclipse.swt.widgets.Shell) List(java.util.List) TomcatServer(org.eclipse.jst.server.tomcat.core.internal.TomcatServer)

Example 2 with TomcatServer

use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.

the class ConfigurationMimeEditorSection method init.

public void init(IEditorSite site, IEditorInput input) {
    super.init(site, input);
    TomcatServer ts = (TomcatServer) server.getAdapter(TomcatServer.class);
    try {
        tomcatConfiguration = ts.getTomcatConfiguration();
    } catch (Exception e) {
    // ignore
    }
    addChangeListener();
    initialize();
}
Also used : TomcatServer(org.eclipse.jst.server.tomcat.core.internal.TomcatServer)

Example 3 with TomcatServer

use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.

the class ConfigurationPortEditorSection method init.

/* (non-Javadoc)
	 * Initializes the editor part with a site and input.
	 */
public void init(IEditorSite site, IEditorInput input) {
    super.init(site, input);
    TomcatServer ts = (TomcatServer) server.getAdapter(TomcatServer.class);
    try {
        tomcatConfiguration = ts.getTomcatConfiguration();
    } catch (Exception e) {
    // ignore
    }
    addChangeListener();
    initialize();
}
Also used : TomcatServer(org.eclipse.jst.server.tomcat.core.internal.TomcatServer)

Example 4 with TomcatServer

use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.

the class AbstractTomcatServerTestCase method createServer.

public IServer createServer() throws Exception {
    IServerType st = ServerCore.findServerType(getServerTypeId());
    IRuntime runtime = createRuntime();
    IServerWorkingCopy wc = st.createServer(null, null, runtime, null);
    ServerPort[] ports = wc.getServerPorts(null);
    TomcatServer tomcatServer = (TomcatServer) wc.getAdapter(TomcatServer.class);
    ITomcatConfigurationWorkingCopy configuration = (ITomcatConfigurationWorkingCopy) tomcatServer.getServerConfiguration();
    // if no ports from the server, use the configuration
    if (ports == null || ports.length == 0) {
        List portsList = configuration.getServerPorts();
        if (portsList != null && portsList.size() > 0) {
            ports = (ServerPort[]) portsList.toArray(new ServerPort[portsList.size()]);
        }
    }
    if (ports != null) {
        int size = ports.length;
        for (int i = 0; i < size; i++) {
            configuration.modifyServerPort(ports[i].getId(), 22100 + i);
        }
    }
    return wc.save(true, null);
}
Also used : IServerType(org.eclipse.wst.server.core.IServerType) ITomcatConfigurationWorkingCopy(org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) List(java.util.List) TomcatServer(org.eclipse.jst.server.tomcat.core.internal.TomcatServer) ServerPort(org.eclipse.wst.server.core.ServerPort) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 5 with TomcatServer

use of org.eclipse.jst.server.tomcat.core.internal.TomcatServer in project webtools.servertools by eclipse.

the class AbstractTomcatServerTestCase method verifyDefaultDeployConfig.

/*
	 * Tests to verify modules are deployed correctly per configuration
	 */
/**
 * @throws Exception
 */
public void verifyDefaultDeployConfig() throws Exception {
    TomcatServer ts = getTomcatServer();
    assertNotNull(ts);
    TomcatServerBehaviour tsb = getTomcatServerBehaviour();
    assertNotNull(tsb);
    assertEquals(ITomcatServerWorkingCopy.DEFAULT_DEPLOYDIR, ts.getDeployDirectory());
    IPath tempDir = tsb.getTempDirectory();
    IPath baseDir = tsb.getRuntimeBaseDirectory();
    assertEquals(tempDir, baseDir);
    IPath deployDir = tsb.getServerDeployDirectory();
    assertEquals(baseDir.append(ITomcatServerWorkingCopy.DEFAULT_DEPLOYDIR), deployDir);
}
Also used : IPath(org.eclipse.core.runtime.IPath) TomcatServerBehaviour(org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour) TomcatServer(org.eclipse.jst.server.tomcat.core.internal.TomcatServer)

Aggregations

TomcatServer (org.eclipse.jst.server.tomcat.core.internal.TomcatServer)11 IPath (org.eclipse.core.runtime.IPath)4 TomcatServerBehaviour (org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour)4 List (java.util.List)3 IModule (org.eclipse.wst.server.core.IModule)3 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)3 ITomcatConfigurationWorkingCopy (org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy)2 IServer (org.eclipse.wst.server.core.IServer)2 IWebModule (org.eclipse.jst.server.core.IWebModule)1 ITomcatServer (org.eclipse.jst.server.tomcat.core.internal.ITomcatServer)1 ITomcatServerWorkingCopy (org.eclipse.jst.server.tomcat.core.internal.ITomcatServerWorkingCopy)1 TomcatConfiguration (org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration)1 WebModule (org.eclipse.jst.server.tomcat.core.internal.WebModule)1 Shell (org.eclipse.swt.widgets.Shell)1 IRuntime (org.eclipse.wst.server.core.IRuntime)1 IServerAttributes (org.eclipse.wst.server.core.IServerAttributes)1 IServerType (org.eclipse.wst.server.core.IServerType)1 ServerPort (org.eclipse.wst.server.core.ServerPort)1 Server (org.eclipse.wst.server.core.internal.Server)1