Search in sources :

Example 16 with Service

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service in project webtools.servertools by eclipse.

the class Tomcat41Configuration method modifyServerPort.

/**
 * Modify the port with the given id.
 *
 * @param id java.lang.String
 * @param port int
 */
public void modifyServerPort(String id, int port) {
    try {
        if ("server".equals(id)) {
            server.setPort(port + "");
            isServerDirty = true;
            firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
            return;
        }
        int i = id.indexOf("/");
        // If a connector in the instance Service
        if (i < 0) {
            int connNum = Integer.parseInt(id);
            Connector connector = serverInstance.getConnector(connNum);
            if (connector != null) {
                connector.setPort(port + "");
                isServerDirty = true;
                firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
            }
        } else // Else a connector in another Service
        {
            int servNum = Integer.parseInt(id.substring(0, i));
            int connNum = Integer.parseInt(id.substring(i + 1));
            Service service = server.getService(servNum);
            Connector connector = service.getConnector(connNum);
            connector.setPort(port + "");
            isServerDirty = true;
            firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
        }
    } catch (Exception e) {
        Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
    }
}
Also used : Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) Service(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service) CoreException(org.eclipse.core.runtime.CoreException)

Example 17 with Service

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service in project webtools.servertools by eclipse.

the class XmlTestCase method testServerInstance2.

/**
 * Test behavior of ServerInstance
 */
public void testServerInstance2() {
    Server server = getXml40Server("serverxml.test2");
    assertNotNull(server);
    ServerInstance si = new ServerInstance(server, "Service", "nonexistent_host");
    assertNotNull(si.getService());
    assertNotNull(si.getEngine());
    assertEquals("Engine", si.getEngine().getName());
    assertNull(si.getHost());
    assertEquals("Host \"nonexistent_host\" was not found under Engine \"Engine\" and Service \"Service\".", si.getStatus().getMessage());
    si = new ServerInstance(server, "Service", null);
    assertNotNull(si.getService());
    assertNotNull(si.getEngine());
    assertEquals("Engine", si.getEngine().getName());
    assertNotNull(si.getHost());
    assertEquals("localhost", si.getHost().getName());
    assertEquals((new Path("/Base")).append("Engine").append("localhost"), si.getContextXmlDirectory(new Path("/Base")));
    Context context = si.getContext(0);
    assertNotNull(context);
    assertEquals("/WebApp1", context.getPath());
    context = si.getContext(1);
    assertNotNull(context);
    assertEquals("/WebApp2", context.getPath());
    context = si.getContext(2);
    assertNotNull(context);
    assertEquals("/WebApp3", context.getPath());
    // create new context
    context = si.getContext(3);
    context.setPath("/WebApp4");
    Context[] contexts = si.getContexts();
    assertEquals(4, contexts.length);
    assertEquals("/WebApp1", contexts[0].getPath());
    assertEquals("/WebApp2", contexts[1].getPath());
    assertEquals("/WebApp3", contexts[2].getPath());
    assertEquals("/WebApp4", contexts[3].getPath());
    context = si.createContext(2);
    context.setPath("/WebApp2b");
    contexts = si.getContexts();
    assertEquals(5, contexts.length);
    assertEquals("/WebApp1", contexts[0].getPath());
    assertEquals("/WebApp2", contexts[1].getPath());
    assertEquals("/WebApp2b", contexts[2].getPath());
    assertEquals("/WebApp3", contexts[3].getPath());
    assertEquals("/WebApp4", contexts[4].getPath());
    assertTrue(si.removeContext("WebApp2b"));
    contexts = si.getContexts();
    assertEquals(4, contexts.length);
    assertEquals("/WebApp1", contexts[0].getPath());
    assertEquals("/WebApp2", contexts[1].getPath());
    assertEquals("/WebApp3", contexts[2].getPath());
    assertEquals("/WebApp4", contexts[3].getPath());
    assertTrue(si.removeContext(3));
    contexts = si.getContexts();
    assertEquals(3, contexts.length);
    assertEquals("/WebApp1", contexts[0].getPath());
    assertEquals("/WebApp2", contexts[1].getPath());
    assertEquals("/WebApp3", contexts[2].getPath());
    context = si.getContext("/WebApp1");
    assertNotNull(context);
    assertEquals("/WebApp1", context.getPath());
    assertEquals(new Path("/Base/work/Engine/localhost/WebApp1"), si.getContextWorkDirectory(new Path("/Base"), context));
    context = si.getContext("WebApp2");
    assertNotNull(context);
    assertEquals("/WebApp2", context.getPath());
    assertEquals(new Path("/Base/relative/workdir"), si.getContextWorkDirectory(new Path("/Base"), context));
    context = si.getContext("WebApp3");
    assertNotNull(context);
    assertEquals("/WebApp3", context.getPath());
    assertEquals(new Path("/absolute/workdir"), si.getContextWorkDirectory(new Path("/Base"), context));
    context = si.createContext(3);
    context.setPath("");
    context = si.getContext("");
    assertNotNull(context);
    assertEquals("", context.getPath());
    assertEquals(new Path("/Base/work/Engine/localhost/_"), si.getContextWorkDirectory(new Path("/Base"), context));
    assertEquals(new Path("/Base/work/Engine/localhost"), si.getHostWorkDirectory(new Path("/Base")));
    assertNull(si.getContext("nonexistent"));
    assertEquals("Context with path \"/nonexistent\" was not found under Service \"Service\", Engine \"Engine\", and Host \"localhost\".", si.getStatus().getMessage());
}
Also used : Path(org.eclipse.core.runtime.Path) Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)

Example 18 with Service

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service in project webtools.servertools by eclipse.

the class XmlTestCase method testDefaultServerXml50.

/**
 * Test reading of the default server.xml provided by the
 * current Tomcat 5.0 release (28).
 */
public void testDefaultServerXml50() {
    Server server = getXml40Server("default.serverxml.50");
    assertNotNull(server);
    // Check contents of XML
    String port = server.getPort();
    assertEquals("8005", port);
    assertEquals(server.getListenerCount(), 2);
    Listener listener = server.getListener(0);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listener.getClassName());
    listener = server.getListener(1);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listener.getClassName());
    assertEquals(1, server.getServiceCount());
    Service service = server.getService(0);
    assertNotNull(service);
    assertEquals("Catalina", service.getName());
    assertEquals(2, service.getConnectorCount());
    Connector connector = service.getConnector(0);
    assertNotNull(connector);
    assertEquals("8080", connector.getPort());
    assertNull(connector.getProtocol());
    connector = service.getConnector(1);
    assertNotNull(connector);
    assertEquals("8009", connector.getPort());
    assertEquals("AJP/1.3", connector.getProtocol());
    Engine engine = service.getEngine();
    assertNotNull(engine);
    assertEquals("Catalina", engine.getName());
    assertEquals("localhost", engine.getDefaultHost());
    assertEquals(engine.getHostCount(), 1);
    Host host = engine.getHost(0);
    assertNotNull(host);
    assertEquals("localhost", host.getName());
    assertEquals("webapps", host.getAppBase());
    assertEquals("true", host.getAttributeValue("unpackWARs"));
    assertEquals("true", host.getAttributeValue("autoDeploy"));
    assertEquals(0, host.getContextCount());
}
Also used : Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) Listener(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener) Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) Service(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service) Host(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Host) Engine(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)

Example 19 with Service

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service in project webtools.servertools by eclipse.

the class XmlTestCase method testDefaultServerXml55.

/**
 * Test reading of the default server.xml provided by the
 * current Tomcat 5.5 release (20).
 */
public void testDefaultServerXml55() {
    Server server = getXml40Server("default.serverxml.55");
    assertNotNull(server);
    // Check contents of XML
    String port = server.getPort();
    assertEquals("8005", port);
    assertEquals(server.getListenerCount(), 4);
    Listener listener = server.getListener(0);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.core.AprLifecycleListener", listener.getClassName());
    listener = server.getListener(1);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listener.getClassName());
    listener = server.getListener(2);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listener.getClassName());
    listener = server.getListener(3);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.storeconfig.StoreConfigLifecycleListener", listener.getClassName());
    assertEquals(server.getServiceCount(), 1);
    Service service = server.getService(0);
    assertNotNull(service);
    assertEquals("Catalina", service.getName());
    assertEquals(2, service.getConnectorCount());
    Connector connector = service.getConnector(0);
    assertNotNull(connector);
    assertEquals("8080", connector.getPort());
    assertNull(connector.getProtocol());
    connector = service.getConnector(1);
    assertNotNull(connector);
    assertEquals("8009", connector.getPort());
    assertEquals("AJP/1.3", connector.getProtocol());
    Engine engine = service.getEngine();
    assertNotNull(engine);
    assertEquals("Catalina", engine.getName());
    assertEquals("localhost", engine.getDefaultHost());
    assertEquals(1, engine.getHostCount());
    Host host = engine.getHost(0);
    assertNotNull(host);
    assertEquals("localhost", host.getName());
    assertEquals("webapps", host.getAppBase());
    assertEquals("true", host.getAttributeValue("unpackWARs"));
    assertEquals("true", host.getAttributeValue("autoDeploy"));
    assertEquals(0, host.getContextCount());
}
Also used : Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) Listener(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener) Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) Service(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service) Host(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Host) Engine(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)

Example 20 with Service

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service in project webtools.servertools by eclipse.

the class XmlTestCase method testDefaultServerXml60.

/**
 * Test reading of the default server.xml provided by the
 * current Tomcat 6.0 release.
 */
public void testDefaultServerXml60() {
    Server server = getXml40Server("default.serverxml.60");
    assertNotNull(server);
    // Check contents of XML
    String port = server.getPort();
    assertEquals("8005", port);
    assertEquals(4, server.getListenerCount());
    Listener listener = server.getListener(0);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.core.AprLifecycleListener", listener.getClassName());
    listener = server.getListener(1);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.core.JasperListener", listener.getClassName());
    listener = server.getListener(2);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listener.getClassName());
    listener = server.getListener(3);
    assertNotNull(listener);
    assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listener.getClassName());
    assertEquals(1, server.getServiceCount());
    Service service = server.getService(0);
    assertNotNull(service);
    assertEquals("Catalina", service.getName());
    assertEquals(2, service.getConnectorCount());
    Connector connector = service.getConnector(0);
    assertNotNull(connector);
    assertEquals("8080", connector.getPort());
    assertEquals("HTTP/1.1", connector.getProtocol());
    connector = service.getConnector(1);
    assertNotNull(connector);
    assertEquals("8009", connector.getPort());
    assertEquals("AJP/1.3", connector.getProtocol());
    Engine engine = service.getEngine();
    assertNotNull(engine);
    assertEquals("Catalina", engine.getName());
    assertEquals("localhost", engine.getDefaultHost());
    assertEquals(1, engine.getHostCount());
    Host host = engine.getHost(0);
    assertNotNull(host);
    assertEquals("localhost", host.getName());
    assertEquals("webapps", host.getAppBase());
    assertEquals("true", host.getAttributeValue("unpackWARs"));
    assertEquals("true", host.getAttributeValue("autoDeploy"));
    assertEquals(0, host.getContextCount());
}
Also used : Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) Listener(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener) Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) Service(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service) Host(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Host) Engine(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)

Aggregations

Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 CoreException (org.eclipse.core.runtime.CoreException)18 ArrayList (java.util.ArrayList)10 ServerPort (org.eclipse.wst.server.core.ServerPort)9 Server (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server)8 Host (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Host)5 ServerInstance (org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)5 Context (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context)4 Engine (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)4 Listener (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener)4 Service (org.openstack4j.model.identity.v3.Service)3 HashMap (java.util.HashMap)2 Path (org.eclipse.core.runtime.Path)2 Access (org.openstack4j.model.identity.v2.Access)2 Element (org.w3c.dom.Element)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1 V1OwnerReference (io.kubernetes.client.models.V1OwnerReference)1 IntOrString (io.kubernetes.client.proto.IntStr.IntOrString)1