Search in sources :

Example 21 with IRuntimeType

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

the class MatchesTestCase method testMatches.

public void testMatches() {
    IRuntimeType rt = ServerCore.getRuntimeTypes()[0];
    System.out.println("Runtime: " + rt.getName());
    IModuleType[] mt = rt.getModuleTypes();
    for (int i = 0; i < NUM; i++) {
        ServerUtil.isSupportedModule(mt, "jst.web", "2.4");
    }
    long time = System.currentTimeMillis();
    for (int i = 0; i < NUM; i++) {
        ServerUtil.isSupportedModule(mt, "jst.web", "2.4");
    }
    System.out.println("Time: " + (System.currentTimeMillis() - time));
    time = System.currentTimeMillis();
    for (int i = 0; i < NUM; i++) {
        ServerUtil.isSupportedModule(mt, "jst.*", "2.*");
    }
    System.out.println("Time2: " + (System.currentTimeMillis() - time));
    time = System.currentTimeMillis();
    for (int i = 0; i < NUM; i++) {
        ServerUtil.isSupportedModule(mt, "*", "2.4");
    }
    System.out.println("Time3: " + (System.currentTimeMillis() - time));
}
Also used : IModuleType(org.eclipse.wst.server.core.IModuleType) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType)

Example 22 with IRuntimeType

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

the class RuntimeTypesTestCase method testRuntimeTypesExtension.

public void testRuntimeTypesExtension() throws Exception {
    IRuntimeType[] runtimeTypes = ServerCore.getRuntimeTypes();
    if (runtimeTypes != null) {
        for (IRuntimeType runtimeType : runtimeTypes) {
            runtimeType.getId();
            runtimeType.getName();
            runtimeType.canCreate();
            runtimeType.getDescription();
            runtimeType.getVendor();
            runtimeType.getVersion();
            runtimeType.getModuleTypes();
        }
    }
}
Also used : IRuntimeType(org.eclipse.wst.server.core.IRuntimeType)

Example 23 with IRuntimeType

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

the class TomcatRuntime method setDefaults.

/**
 * @see RuntimeDelegate#setDefaults(IProgressMonitor)
 */
public void setDefaults(IProgressMonitor monitor) {
    IRuntimeType type = getRuntimeWorkingCopy().getRuntimeType();
    Path p = new Path(TomcatPlugin.getPreference("location" + type.getId()));
    if (p != null && p.toFile().exists() && verifyLocation(p).isOK())
        getRuntimeWorkingCopy().setLocation(p);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType)

Example 24 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 25 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)

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