Search in sources :

Example 21 with Service

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

the class XmlTestCase method testServerInstance3.

/**
 * Test behavior of ServerInstance
 */
public void testServerInstance3() {
    Server server = getXml40Server("serverxml.test3");
    assertNotNull(server);
    ServerInstance si = new ServerInstance(server, "Service", null);
    Context context = si.getContext("/WebApp1");
    assertNotNull(context);
    assertEquals(new Path("/Base/relative/host/WebApp1"), si.getContextWorkDirectory(new Path("/Base"), context));
    context = si.getContext("WebApp2");
    assertNotNull(context);
    assertEquals(new Path("/Base/relative/workdir"), si.getContextWorkDirectory(new Path("/Base"), context));
    context = si.getContext("WebApp3");
    assertNotNull(context);
    assertEquals(new Path("/absolute/workdir"), si.getContextWorkDirectory(new Path("/Base"), context));
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) Path(org.eclipse.core.runtime.Path) Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)

Example 22 with Service

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

the class XmlTestCase method testServerInstance50.

/**
 * Test reading of the default server.xml provided by the
 * current Tomcat 5.0 release using ServerInstance.
 */
public void testServerInstance50() {
    Server server = getXml40Server("default.serverxml.50");
    assertNotNull(server);
    ServerInstance si = new ServerInstance(server, null, null);
    assertEquals(2, server.getListenerCount());
    Listener[] listeners = si.getListeners();
    assertEquals("org.apache.catalina.mbeans.ServerLifecycleListener", listeners[0].getClassName());
    assertEquals("org.apache.catalina.mbeans.GlobalResourcesLifecycleListener", listeners[1].getClassName());
    Service service = si.getService();
    assertNotNull(service);
    assertEquals("Catalina", service.getName());
    assertEquals("8080", si.getConnector(0).getPort());
    assertNull(si.getConnector(0).getProtocol());
    assertEquals("8009", si.getConnector(1).getPort());
    assertEquals("AJP/1.3", si.getConnector(1).getProtocol());
    Connector[] connectors = si.getConnectors();
    assertEquals(2, connectors.length);
    assertEquals("8080", connectors[0].getPort());
    assertNull(connectors[0].getProtocol());
    assertEquals("8009", connectors[1].getPort());
    assertEquals("AJP/1.3", connectors[1].getProtocol());
    Engine engine = si.getEngine();
    assertNotNull(engine);
    assertEquals("Catalina", engine.getName());
    assertEquals("localhost", engine.getDefaultHost());
    Host host = si.getHost();
    assertNotNull(host);
    assertEquals("localhost", host.getName());
    assertEquals("webapps", host.getAppBase());
    assertEquals("true", host.getAttributeValue("unpackWARs"));
    assertEquals("true", host.getAttributeValue("autoDeploy"));
    Context[] contexts = si.getContexts();
    assertEquals(0, contexts.length);
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) 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) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance) Engine(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)

Example 23 with Service

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service in project ovirt-engine-sdk-java by oVirt.

the class HttpConnection method followLink.

@Override
public <TYPE> TYPE followLink(TYPE object) {
    if (!isLink(object)) {
        throw new Error("Can't follow link because object don't have any");
    }
    String href = getHref(object);
    if (href == null) {
        throw new Error("Can't follow link because the 'href' attribute does't have a value");
    }
    try {
        URL url = new URL(getUrl());
        String prefix = url.getPath();
        if (!prefix.endsWith("/")) {
            prefix += "/";
        }
        if (!href.startsWith(prefix)) {
            throw new Error("The URL '" + href + "' isn't compatible with the base URL of the connection");
        }
        // Get service based on path
        String path = href.substring(prefix.length());
        Service service = systemService().service(path);
        // Obtain method which provides result object and invoke it:
        Method get;
        if (object instanceof ListWithHref) {
            get = service.getClass().getMethod("list");
        } else {
            get = service.getClass().getMethod("get");
        }
        Object getRequest = get.invoke(service);
        Method send = getRequest.getClass().getMethod("send");
        send.setAccessible(true);
        Object getResponse = send.invoke(getRequest);
        Method obtainObject = getResponse.getClass().getDeclaredMethods()[0];
        obtainObject.setAccessible(true);
        return (TYPE) obtainObject.invoke(getResponse);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
        throw new Error(String.format("Unexpected error while following link \"%1$s\"", href), ex);
    } catch (MalformedURLException ex) {
        throw new Error(String.format("Error while creating URL \"%1$s\"", getUrl()), ex);
    }
}
Also used : ListWithHref(org.ovirt.api.metamodel.runtime.util.ListWithHref) MalformedURLException(java.net.MalformedURLException) Error(org.ovirt.engine.sdk4.Error) SystemService(org.ovirt.engine.sdk4.services.SystemService) Service(org.ovirt.engine.sdk4.Service) Method(java.lang.reflect.Method) URL(java.net.URL) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 24 with Service

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

the class KeystoneToken method getAggregatedCatalog.

/**
     * {@inheritDoc}
     */
@Override
@JsonIgnore
public SortedSetMultimap<String, Service> getAggregatedCatalog() {
    if (aggregatedCatalog == null) {
        synchronized (this) {
            if (aggregatedCatalog == null) {
                aggregatedCatalog = TreeMultimap.create();
                for (Service sc : catalog) {
                    String nameKey = TYPE_WITHOUT_VERSION.apply(sc.getName());
                    String typeKey = TYPE_WITHOUT_VERSION.apply(sc.getType());
                    aggregatedCatalog.put(nameKey, sc);
                    aggregatedCatalog.put(typeKey, sc);
                }
            }
        }
    }
    return aggregatedCatalog;
}
Also used : Service(org.openstack4j.model.identity.v3.Service) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 25 with Service

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

the class Tomcat40Configuration 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)

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