Search in sources :

Example 11 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 : ITomcatConfigurationWorkingCopy(org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy) List(java.util.List) 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