Search in sources :

Example 21 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy 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 22 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy 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 23 with IRuntimeWorkingCopy

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

the class GenericServerClasspathRuntimeHandlerTest method setUp.

/*
     * @see TestCase#setUp()
     */
protected void setUp() throws Exception {
    super.setUp();
    IRuntimeType type = ServerCore.findRuntimeType("org.eclipse.jst.server.generic.runtime.jonas4");
    IRuntimeWorkingCopy wc = type.createRuntime("testRuntime", null);
    GenericServerRuntime delegate = (GenericServerRuntime) wc.loadAdapter(GenericServerRuntime.class, new NullProgressMonitor());
    HashMap props = new HashMap();
    props.put("mappernames", "");
    props.put("classPathVariableName", "JONAS");
    props.put("serverAddress", "127.0.0.1");
    props.put("jonasBase", SERVER_ROOT);
    props.put("jonasRoot", SERVER_ROOT);
    props.put("protocols", "jrmp");
    props.put("port", "9000");
    delegate.setServerInstanceProperties(props);
    delegate.setServerDefinitionId(SERVER_DEF_NAME);
    wc.save(false, null);
    fRuntime = wc.getOriginal();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GenericServerRuntime(org.eclipse.jst.server.generic.core.internal.GenericServerRuntime) HashMap(java.util.HashMap) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 24 with IRuntimeWorkingCopy

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

the class ServerCreationTest method testCreateServer.

public void testCreateServer() throws Exception {
    // Finds the generic server type
    IServerType[] sTypes = ServerCore.getServerTypes();
    IServerType serverType = null;
    for (int i = 0; i < sTypes.length; i++) {
        IServerType sType = sTypes[i];
        if (ID.equals(sType.getId()))
            serverType = sType;
    }
    assertNotNull("Could not find org.eclipse.jst.server.generic.jonas4 server type", serverType);
    // Finds the generic server runtime type
    IRuntimeType runtimeType = serverType.getRuntimeType();
    assertNotNull("Could not find runtime type for the generic server type", runtimeType);
    // Create a new runtime instance from the type
    IRuntime runtime = runtimeType.createRuntime(ID + ".Jonas.Runtime", null);
    assertNotNull("Could not create runtime", runtime);
    // Create a new server instance from the type
    IServerWorkingCopy server = serverType.createServer(ID + ".Jonas.Server", null, runtime, null);
    assertNotNull("Could not create server", server);
    // Save the server
    server.save(false, null);
    // Set properties for the runtime
    IRuntimeWorkingCopy runtimeWorkingCopy = runtime.createWorkingCopy();
    assertNotNull("Could not create runtime working copy", runtimeWorkingCopy);
    // Set the JONAS runtime as the default runtime
    ServerUtil.setRuntimeDefaultName(runtimeWorkingCopy);
    assertNotNull("Runtime working copy has no name", runtimeWorkingCopy.getName());
    // Set properties for the JONAS runtime
    GenericServerRuntime runtimeDelegate = (GenericServerRuntime) runtimeWorkingCopy.loadAdapter(GenericServerRuntime.class, new NullProgressMonitor());
    assertNotNull("Could not obtain runtime delegate", runtimeDelegate);
    HashMap props = new HashMap();
    props.put("mappernames", "");
    props.put("classPathVariableName", "JONAS");
    props.put("serverAddress", "127.0.0.1");
    props.put("jonasBase", "C:\\nmd\\dev\\java\\appservers\\JOnAS-4.1.4");
    props.put("jonasRoot", "C:\\nmd\\dev\\java\\appservers\\JOnAS-4.1.4");
    props.put("classPath", "C:\\nmd\\dev\\java\\appservers\\JOnAS-4.1.4");
    props.put("protocols", "C:\\nmd\\dev\\java\\appservers\\JOnAS-4.1.4");
    props.put("port", "9000");
    runtimeDelegate.setServerInstanceProperties(props);
    // Save the runtime working copy
    runtimeWorkingCopy.save(false, null);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GenericServerRuntime(org.eclipse.jst.server.generic.core.internal.GenericServerRuntime) IServerType(org.eclipse.wst.server.core.IServerType) HashMap(java.util.HashMap) 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 IRuntimeWorkingCopy

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

the class AbstractTomcatServerTestCase method createRuntime.

protected IRuntime createRuntime() throws Exception {
    IServerType st = ServerCore.findServerType(getServerTypeId());
    IRuntimeWorkingCopy wc = st.getRuntimeType().createRuntime(null, null);
    wc.setLocation(new Path(RuntimeLocation.runtimeLocation));
    return wc.save(true, null);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IServerType(org.eclipse.wst.server.core.IServerType) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Aggregations

IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)41 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)16 IRuntime (org.eclipse.wst.server.core.IRuntime)13 IRuntimeType (org.eclipse.wst.server.core.IRuntimeType)12 CoreException (org.eclipse.core.runtime.CoreException)9 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)9 IServerType (org.eclipse.wst.server.core.IServerType)8 IPath (org.eclipse.core.runtime.IPath)6 IStatus (org.eclipse.core.runtime.IStatus)6 Path (org.eclipse.core.runtime.Path)6 Test (org.junit.Test)6 PortalRuntime (com.liferay.ide.server.core.portal.PortalRuntime)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 NewModuleFragmentOp (com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)2 OverrideFilePath (com.liferay.ide.project.core.modules.fragment.OverrideFilePath)2 HashMap (java.util.HashMap)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 GenericServerRuntime (org.eclipse.jst.server.generic.core.internal.GenericServerRuntime)2 ITomcatRuntimeWorkingCopy (org.eclipse.jst.server.tomcat.core.internal.ITomcatRuntimeWorkingCopy)2