Search in sources :

Example 1 with StandardEngine

use of org.apache.catalina.core.StandardEngine in project tomcat by apache.

the class MBeanFactory method createStandardServiceEngine.

/**
     * Creates a new StandardService and StandardEngine.
     *
     * @param domain       Domain name for the container instance
     * @param defaultHost  Name of the default host to be used in the Engine
     * @param baseDir      Base directory value for Engine
     * @return the object name of the created service
     *
     * @exception Exception if an MBean cannot be created or registered
     */
public String createStandardServiceEngine(String domain, String defaultHost, String baseDir) throws Exception {
    if (!(container instanceof Server)) {
        throw new Exception("Container not Server");
    }
    StandardEngine engine = new StandardEngine();
    engine.setDomain(domain);
    engine.setName(domain);
    engine.setDefaultHost(defaultHost);
    Service service = new StandardService();
    service.setContainer(engine);
    service.setName(domain);
    ((Server) container).addService(service);
    return engine.getObjectName().toString();
}
Also used : StandardEngine(org.apache.catalina.core.StandardEngine) MBeanServer(javax.management.MBeanServer) Server(org.apache.catalina.Server) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardService(org.apache.catalina.core.StandardService)

Example 2 with StandardEngine

use of org.apache.catalina.core.StandardEngine in project tomcat by apache.

the class MBeanFactory method getParentContainerFromParent.

/**
     * Get Parent Container to add its child component
     * from parent's ObjectName
     */
private Container getParentContainerFromParent(ObjectName pname) throws Exception {
    String type = pname.getKeyProperty("type");
    String j2eeType = pname.getKeyProperty("j2eeType");
    Service service = getService(pname);
    StandardEngine engine = (StandardEngine) service.getContainer();
    if ((j2eeType != null) && (j2eeType.equals("WebModule"))) {
        String name = pname.getKeyProperty("name");
        name = name.substring(2);
        int i = name.indexOf('/');
        String hostName = name.substring(0, i);
        String path = name.substring(i);
        Container host = engine.findChild(hostName);
        String pathStr = getPathStr(path);
        Container context = host.findChild(pathStr);
        return context;
    } else if (type != null) {
        if (type.equals("Engine")) {
            return engine;
        } else if (type.equals("Host")) {
            String hostName = pname.getKeyProperty("host");
            Container host = engine.findChild(hostName);
            return host;
        }
    }
    return null;
}
Also used : Container(org.apache.catalina.Container) StandardEngine(org.apache.catalina.core.StandardEngine) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service)

Example 3 with StandardEngine

use of org.apache.catalina.core.StandardEngine in project tomcat by apache.

the class Tomcat method getEngine.

/**
     * Access to the engine, for further customization.
     * @return The engine
     */
public Engine getEngine() {
    Service service = getServer().findServices()[0];
    if (service.getContainer() != null) {
        return service.getContainer();
    }
    Engine engine = new StandardEngine();
    engine.setName("Tomcat");
    engine.setDefaultHost(hostname);
    engine.setRealm(createDefaultRealm());
    service.setContainer(engine);
    return engine;
}
Also used : StandardEngine(org.apache.catalina.core.StandardEngine) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine)

Example 4 with StandardEngine

use of org.apache.catalina.core.StandardEngine in project tomee by apache.

the class GlobalListenerSupport method serviceRemoved.

/**
     * Service removed.
     *
     * @param service tomcat service
     */
private void serviceRemoved(final Service service) {
    final Container container = service.getContainer();
    if (container instanceof StandardEngine) {
        final StandardEngine engine = (StandardEngine) container;
        engineRemoved(engine);
    }
}
Also used : Container(org.apache.catalina.Container) StandardEngine(org.apache.catalina.core.StandardEngine)

Example 5 with StandardEngine

use of org.apache.catalina.core.StandardEngine in project tomcat by apache.

the class StandardEngineSF method storeChildren.

/**
     * Store the specified Engine properties.
     *
     * @param aWriter
     *            PrintWriter to which we are storing
     * @param indent
     *            Number of spaces to indent this element
     * @param aEngine
     *            Object whose properties are being stored
     *
     * @exception Exception
     *                if an exception occurs while storing
     */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aEngine, StoreDescription parentDesc) throws Exception {
    if (aEngine instanceof StandardEngine) {
        StandardEngine engine = (StandardEngine) aEngine;
        // Store nested <Listener> elements
        LifecycleListener[] listeners = ((Lifecycle) engine).findLifecycleListeners();
        storeElementArray(aWriter, indent, listeners);
        // Store nested <Realm> element
        Realm realm = engine.getRealm();
        Realm parentRealm = null;
        // TODO is this case possible? (see it a old Server 5.0 impl)
        if (engine.getParent() != null) {
            parentRealm = engine.getParent().getRealm();
        }
        if (realm != parentRealm) {
            storeElement(aWriter, indent, realm);
        }
        // Store nested <Valve> elements
        Valve[] valves = engine.getPipeline().getValves();
        if (valves != null && valves.length > 0) {
            List<Valve> engineValves = new ArrayList<>();
            for (int i = 0; i < valves.length; i++) {
                if (!(valves[i] instanceof ClusterValve))
                    engineValves.add(valves[i]);
            }
            storeElementArray(aWriter, indent, engineValves.toArray());
        }
        // store all <Cluster> elements
        Cluster cluster = engine.getCluster();
        if (cluster != null) {
            storeElement(aWriter, indent, cluster);
        }
        // store all <Host> elements
        Container[] children = engine.findChildren();
        storeElementArray(aWriter, indent, children);
    }
}
Also used : Lifecycle(org.apache.catalina.Lifecycle) ArrayList(java.util.ArrayList) Cluster(org.apache.catalina.Cluster) LifecycleListener(org.apache.catalina.LifecycleListener) ClusterValve(org.apache.catalina.ha.ClusterValve) Container(org.apache.catalina.Container) StandardEngine(org.apache.catalina.core.StandardEngine) ClusterValve(org.apache.catalina.ha.ClusterValve) Valve(org.apache.catalina.Valve) Realm(org.apache.catalina.Realm)

Aggregations

StandardEngine (org.apache.catalina.core.StandardEngine)9 Container (org.apache.catalina.Container)6 Service (org.apache.catalina.Service)6 StandardService (org.apache.catalina.core.StandardService)4 StandardHost (org.apache.catalina.core.StandardHost)3 File (java.io.File)2 JarFile (java.util.jar.JarFile)2 Engine (org.apache.catalina.Engine)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 MBeanServer (javax.management.MBeanServer)1 Cluster (org.apache.catalina.Cluster)1 Context (org.apache.catalina.Context)1 Host (org.apache.catalina.Host)1 Lifecycle (org.apache.catalina.Lifecycle)1 LifecycleListener (org.apache.catalina.LifecycleListener)1 Realm (org.apache.catalina.Realm)1 Server (org.apache.catalina.Server)1 Valve (org.apache.catalina.Valve)1 StandardContext (org.apache.catalina.core.StandardContext)1