Search in sources :

Example 6 with IRuntimeType

use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.

the class ServerRuntimeUtils method getGenericServerRuntime.

public static GenericServerRuntime getGenericServerRuntime(String runtimeTypeId) throws CoreException {
    GenericServerRuntime runtimeDelegate = null;
    IRuntimeType[] runtimesTypes = ServerCore.getRuntimeTypes();
    for (int i = 0; i < runtimesTypes.length; i++) {
        IRuntimeType runtimeType = runtimesTypes[i];
        if (runtimeType.getId().equals(runtimeTypeId)) {
            IRuntime runtimeWorkingCopy = runtimeType.createRuntime(runtimeTypeId, null);
            runtimeDelegate = (GenericServerRuntime) runtimeWorkingCopy.loadAdapter(GenericServerRuntime.class, new NullProgressMonitor());
            break;
        }
    }
    return runtimeDelegate;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GenericServerRuntime(org.eclipse.jst.server.generic.core.internal.GenericServerRuntime) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 7 with IRuntimeType

use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.

the class HttpRuntimeLocator method getRuntimeFromDir.

protected static IRuntimeWorkingCopy getRuntimeFromDir(File dir, IProgressMonitor monitor) {
    for (String rt : runtimeTypes) {
        try {
            IRuntimeType runtimeType = ServerCore.findRuntimeType(rt);
            String absolutePath = dir.getAbsolutePath();
            String id = absolutePath.replace(File.separatorChar, '_').replace(':', '-');
            IRuntimeWorkingCopy runtime = runtimeType.createRuntime(id, monitor);
            runtime.setName(dir.getName());
            runtime.setLocation(new Path(absolutePath).append("htdocs"));
            IStatus status = runtime.validate(monitor);
            if (status == null || status.getSeverity() != IStatus.ERROR)
                return runtime;
            Trace.trace(Trace.FINER, "False runtime found at " + dir.getAbsolutePath() + ": " + status.getMessage());
        } catch (Exception e) {
            Trace.trace(Trace.SEVERE, "Could not find runtime", e);
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IStatus(org.eclipse.core.runtime.IStatus) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 8 with IRuntimeType

use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.

the class PreviewServer method createPreviewServer.

public static IServer createPreviewServer(String serverName) {
    try {
        NullProgressMonitor monitor = new NullProgressMonitor();
        IRuntimeType runtimeType = ServerCore.findRuntimeType(PreviewRuntime.ID);
        IRuntimeWorkingCopy runtimeCopy = runtimeType.createRuntime(PreviewRuntime.ID, monitor);
        IRuntime runtime = runtimeCopy.save(true, monitor);
        IServerType serverType = ServerCore.findServerType(ID);
        IServerWorkingCopy workingCopy = serverType.createServer(ID, null, runtime, monitor);
        workingCopy.setName(serverName);
        workingCopy.setHost("localhost");
        return workingCopy.save(true, monitor);
    } catch (Exception e) {
        Trace.trace(Trace.SEVERE, "Error creating server", e);
    }
    return null;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServerType(org.eclipse.wst.server.core.IServerType) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) CoreException(org.eclipse.core.runtime.CoreException) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 9 with IRuntimeType

use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.

the class PreviewStartup method startup.

public void startup() {
    // create runtime
    IRuntime[] runtimes = ServerCore.getRuntimes();
    IRuntime runtime = null;
    for (IRuntime r : runtimes) {
        if (r.getRuntimeType() != null && PreviewRuntime.ID.equals(r.getRuntimeType().getId())) {
            if (ID.equals(r.getId()))
                runtime = r;
        }
    }
    if (runtime == null) {
        try {
            IRuntimeType runtimeType = ServerCore.findRuntimeType(PreviewRuntime.ID);
            IRuntimeWorkingCopy wc = runtimeType.createRuntime(ID, null);
            wc.setName("My Preview");
            wc.setReadOnly(true);
            runtime = wc.save(true, null);
        } catch (CoreException ce) {
            Trace.trace(Trace.WARNING, "Could not create default preview runtime");
        }
    }
    // create server
    IServer[] servers = ServerCore.getServers();
    boolean found = false;
    for (IServer s : servers) {
        if (s.getServerType() != null && PreviewServer.ID.equals(s.getServerType().getId())) {
            if (ID.equals(s.getId()))
                found = true;
        }
    }
    if (!found) {
        try {
            IServerType serverType = ServerCore.findServerType(PreviewServer.ID);
            IServerWorkingCopy wc = serverType.createServer(ID, null, runtime, null);
            wc.setName("My preview");
            wc.setHost("localhost");
            wc.setReadOnly(true);
            wc.save(true, null);
        } catch (CoreException ce) {
            Trace.trace(Trace.WARNING, "Could not create default preview server");
        }
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) CoreException(org.eclipse.core.runtime.CoreException) IServerType(org.eclipse.wst.server.core.IServerType) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 10 with IRuntimeType

use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.

the class HttpServer method createHttpServer.

public static IServer createHttpServer(String host, String serverName, IProgressMonitor monitor) {
    try {
        IRuntimeType runtimeType = ServerCore.findRuntimeType(HttpRuntime.ID);
        IRuntimeWorkingCopy runtimeCopy = runtimeType.createRuntime(HttpRuntime.ID, monitor);
        IRuntime runtime = runtimeCopy.save(true, monitor);
        IServerType serverType = ServerCore.findServerType(ID);
        IServerWorkingCopy workingCopy = serverType.createServer(ID, null, runtime, monitor);
        workingCopy.setName(serverName);
        workingCopy.setHost(host);
        return workingCopy.save(true, monitor);
    } catch (Exception e) {
        Trace.trace(Trace.SEVERE, "Error creating server", e);
    }
    return null;
}
Also used : IServerType(org.eclipse.wst.server.core.IServerType) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) CoreException(org.eclipse.core.runtime.CoreException) IRuntime(org.eclipse.wst.server.core.IRuntime)

Aggregations

IRuntimeType (org.eclipse.wst.server.core.IRuntimeType)35 IRuntime (org.eclipse.wst.server.core.IRuntime)17 IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)12 IServerType (org.eclipse.wst.server.core.IServerType)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)9 CoreException (org.eclipse.core.runtime.CoreException)8 IPath (org.eclipse.core.runtime.IPath)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Path (org.eclipse.core.runtime.Path)3 GenericServerRuntime (org.eclipse.jst.server.generic.core.internal.GenericServerRuntime)3 Image (org.eclipse.swt.graphics.Image)3 IServer (org.eclipse.wst.server.core.IServer)3 File (java.io.File)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2