Search in sources :

Example 1 with ITomcatConfigurationWorkingCopy

use of org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy 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 2 with ITomcatConfigurationWorkingCopy

use of org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy 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

List (java.util.List)2 ITomcatConfigurationWorkingCopy (org.eclipse.jst.server.tomcat.core.internal.ITomcatConfigurationWorkingCopy)2 TomcatServer (org.eclipse.jst.server.tomcat.core.internal.TomcatServer)2 IRuntime (org.eclipse.wst.server.core.IRuntime)1 IServerType (org.eclipse.wst.server.core.IServerType)1 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)1 ServerPort (org.eclipse.wst.server.core.ServerPort)1