Search in sources :

Example 46 with Service

use of org.apache.catalina.Service in project tomcat70 by apache.

the class ServiceMBean method findConnectors.

/**
 * Find and return the set of Connectors associated with this Service.
 * @throws MBeanException
 */
public String[] findConnectors() throws MBeanException {
    Service service;
    try {
        service = (Service) getManagedResource();
    } catch (InstanceNotFoundException e) {
        throw new MBeanException(e);
    } catch (RuntimeOperationsException e) {
        throw new MBeanException(e);
    } catch (InvalidTargetObjectTypeException e) {
        throw new MBeanException(e);
    }
    Connector[] connectors = service.findConnectors();
    String[] str = new String[connectors.length];
    for (int i = 0; i < connectors.length; i++) {
        str[i] = connectors[i].toString();
    }
    return str;
}
Also used : Connector(org.apache.catalina.connector.Connector) InstanceNotFoundException(javax.management.InstanceNotFoundException) Service(org.apache.catalina.Service) MBeanException(javax.management.MBeanException) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 47 with Service

use of org.apache.catalina.Service in project tomcat70 by apache.

the class ConnectorCreateRule method begin.

// --------------------------------------------------------- Public Methods
/**
 * Process the beginning of this element.
 *
 * @param namespace the namespace URI of the matching element, or an
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param name the local name if the parser is namespace aware, or just
 *   the element name otherwise
 * @param attributes The attribute list for this element
 */
@Override
public void begin(String namespace, String name, Attributes attributes) throws Exception {
    Service svc = (Service) digester.peek();
    Executor ex = null;
    if (attributes.getValue("executor") != null) {
        ex = svc.getExecutor(attributes.getValue("executor"));
    }
    Connector con = new Connector(attributes.getValue("protocol"));
    if (ex != null)
        _setExecutor(con, ex);
    digester.push(con);
}
Also used : Connector(org.apache.catalina.connector.Connector) Executor(org.apache.catalina.Executor) Service(org.apache.catalina.Service)

Example 48 with Service

use of org.apache.catalina.Service in project tomcat70 by apache.

the class ContextConfig method getServer.

private Server getServer() {
    Container c = context;
    while (c != null && !(c instanceof Engine)) {
        c = c.getParent();
    }
    if (c == null) {
        return null;
    }
    Service s = ((Engine) c).getService();
    if (s == null) {
        return null;
    }
    return s.getServer();
}
Also used : Container(org.apache.catalina.Container) Service(org.apache.catalina.Service) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine)

Example 49 with Service

use of org.apache.catalina.Service in project tomee by apache.

the class GlobalListenerSupport method start.

/**
 * Starts operation.
 */
public void start() {
    // hook the hosts so we get notified before contexts are started
    standardServer.addPropertyChangeListener(this);
    standardServer.addLifecycleListener(this);
    for (final Service service : standardServer.findServices()) {
        serviceAdded(service);
    }
}
Also used : Service(org.apache.catalina.Service)

Example 50 with Service

use of org.apache.catalina.Service in project tomee by apache.

the class OpenEJBListener method findOpenEjbWar.

private static File findOpenEjbWar() {
    // in Tomcat 5.5 the OpenEjb war is in the server/webapps director
    final String catalinaBase = System.getProperty("catalina.base");
    final File serverWebapps = new File(catalinaBase, "server/webapps");
    File openEjbWar = findOpenEjbWar(serverWebapps);
    if (openEjbWar != null) {
        return openEjbWar;
    }
    try {
        // scan all hosts directories
        for (final Service service : TomcatHelper.getServer().findServices()) {
            final Container container = service.getContainer();
            if (container instanceof StandardEngine) {
                final StandardEngine engine = (StandardEngine) container;
                for (final Container child : engine.findChildren()) {
                    if (child instanceof StandardHost) {
                        final StandardHost host = (StandardHost) child;
                        final File hostDir = hostDir(catalinaBase, host.getAppBase());
                        openEjbWar = findOpenEjbWar(hostDir);
                        if (openEjbWar != null) {
                            return openEjbWar;
                        } else {
                            return findOpenEjbWar(host);
                        }
                    }
                }
            }
        }
    } catch (final Exception e) {
        LOGGER.log(Level.WARNING, "OpenEJBListener.findOpenEjbWar: {0}", e.getMessage());
    }
    return null;
}
Also used : Container(org.apache.catalina.Container) StandardEngine(org.apache.catalina.core.StandardEngine) StandardHost(org.apache.catalina.core.StandardHost) Service(org.apache.catalina.Service) JarFile(java.util.jar.JarFile) File(java.io.File) IOException(java.io.IOException)

Aggregations

Service (org.apache.catalina.Service)64 StandardService (org.apache.catalina.core.StandardService)25 Connector (org.apache.catalina.connector.Connector)22 Engine (org.apache.catalina.Engine)20 StandardEngine (org.apache.catalina.core.StandardEngine)16 ObjectName (javax.management.ObjectName)13 StandardHost (org.apache.catalina.core.StandardHost)12 Container (org.apache.catalina.Container)8 Executor (org.apache.catalina.Executor)8 Server (org.apache.catalina.Server)8 MBeanServer (javax.management.MBeanServer)7 InstanceNotFoundException (javax.management.InstanceNotFoundException)6 MBeanException (javax.management.MBeanException)6 Host (org.apache.catalina.Host)6 File (java.io.File)5 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)5 RuntimeOperationsException (javax.management.RuntimeOperationsException)5 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)5 StandardContext (org.apache.catalina.core.StandardContext)5 JarFile (java.util.jar.JarFile)3