Search in sources :

Example 31 with Manager

use of org.apache.catalina.Manager in project geode by apache.

the class JvmRouteBinderValve method invoke.

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
    // Get the Manager
    Manager manager = request.getContext().getManager();
    // If it is an AbstractManager, handle possible failover
    if (manager instanceof DeltaSessionManager) {
        DeltaSessionManager absMgr = (DeltaSessionManager) manager;
        String localJvmRoute = absMgr.getJvmRoute();
        if (localJvmRoute != null) {
            handlePossibleFailover(request, absMgr, localJvmRoute);
        }
    }
    // Invoke the next Valve
    getNext().invoke(request, response);
}
Also used : Manager(org.apache.catalina.Manager)

Example 32 with Manager

use of org.apache.catalina.Manager in project geode by apache.

the class CommitSessionValve method invoke.

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
    // Get the Manager
    Manager manager = request.getContext().getManager();
    DeltaSessionFacade session = null;
    // Invoke the next Valve
    try {
        getNext().invoke(request, response);
    } finally {
        // Commit and if the correct Manager was found
        if (manager instanceof DeltaSessionManager) {
            session = (DeltaSessionFacade) request.getSession(false);
            DeltaSessionManager dsm = ((DeltaSessionManager) manager);
            if (session != null) {
                if (session.isValid()) {
                    dsm.removeTouchedSession(session.getId());
                    session.commit();
                    if (dsm.getTheContext().getLogger().isDebugEnabled()) {
                        dsm.getTheContext().getLogger().debug(session + ": Committed.");
                    }
                } else {
                    if (dsm.getTheContext().getLogger().isDebugEnabled()) {
                        dsm.getTheContext().getLogger().debug(session + ": Not valid so not committing.");
                    }
                }
            }
        }
    }
}
Also used : Manager(org.apache.catalina.Manager)

Example 33 with Manager

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

the class ContainerBase method setManager.

/**
 * Set the Manager with which this Container is associated.
 *
 * @param manager The newly associated Manager
 */
@Override
public void setManager(Manager manager) {
    Lock writeLock = managerLock.writeLock();
    writeLock.lock();
    Manager oldManager = null;
    try {
        // Change components if necessary
        oldManager = this.manager;
        if (oldManager == manager)
            return;
        this.manager = manager;
        // Stop the old component if necessary
        if (oldManager instanceof Lifecycle) {
            try {
                ((Lifecycle) oldManager).stop();
                ((Lifecycle) oldManager).destroy();
            } catch (LifecycleException e) {
                log.error("ContainerBase.setManager: stop-destroy: ", e);
            }
        }
        // Start the new component if necessary
        if (manager != null)
            manager.setContainer(this);
        if (getState().isAvailable() && manager instanceof Lifecycle) {
            try {
                ((Lifecycle) manager).start();
            } catch (LifecycleException e) {
                log.error("ContainerBase.setManager: start: ", e);
            }
        }
    } finally {
        writeLock.unlock();
    }
    // Report this property change to interested listeners
    support.firePropertyChange("manager", oldManager, manager);
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) Lifecycle(org.apache.catalina.Lifecycle) StringManager(org.apache.tomcat.util.res.StringManager) Manager(org.apache.catalina.Manager) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) Lock(java.util.concurrent.locks.Lock)

Example 34 with Manager

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

the class ContainerBase method destroyInternal.

@Override
protected void destroyInternal() throws LifecycleException {
    Manager manager = getManagerInternal();
    if ((manager != null) && (manager instanceof Lifecycle)) {
        ((Lifecycle) manager).destroy();
    }
    Realm realm = getRealmInternal();
    if ((realm != null) && (realm instanceof Lifecycle)) {
        ((Lifecycle) realm).destroy();
    }
    Cluster cluster = getClusterInternal();
    if ((cluster != null) && (cluster instanceof Lifecycle)) {
        ((Lifecycle) cluster).destroy();
    }
    Loader loader = getLoaderInternal();
    if ((loader != null) && (loader instanceof Lifecycle)) {
        ((Lifecycle) loader).destroy();
    }
    // Stop the Valves in our pipeline (including the basic), if any
    if (pipeline instanceof Lifecycle) {
        ((Lifecycle) pipeline).destroy();
    }
    // Remove children now this container is being destroyed
    for (Container child : findChildren()) {
        removeChild(child);
    }
    // Required if the child is destroyed directly.
    if (parent != null) {
        parent.removeChild(this);
    }
    // If init fails, this may be null
    if (startStopExecutor != null) {
        startStopExecutor.shutdownNow();
    }
    super.destroyInternal();
}
Also used : Container(org.apache.catalina.Container) Lifecycle(org.apache.catalina.Lifecycle) Cluster(org.apache.catalina.Cluster) Loader(org.apache.catalina.Loader) StringManager(org.apache.tomcat.util.res.StringManager) Manager(org.apache.catalina.Manager) Realm(org.apache.catalina.Realm)

Example 35 with Manager

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

the class StandardContext method stopInternal.

/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {
    // Send j2ee.state.stopping notification
    if (this.getObjectName() != null) {
        Notification notification = new Notification("j2ee.state.stopping", this.getObjectName(), sequenceNumber.getAndIncrement());
        broadcaster.sendNotification(notification);
    }
    setState(LifecycleState.STOPPING);
    // Binding thread
    ClassLoader oldCCL = bindThread();
    try {
        // Stop our child containers, if any
        final Container[] children = findChildren();
        ClassLoader old = bindThread();
        try {
            // Stop ContainerBackgroundProcessor thread
            threadStop();
            for (int i = 0; i < children.length; i++) {
                children[i].stop();
            }
            // Stop our filters
            filterStop();
            Manager manager = getManagerInternal();
            if (manager != null && manager instanceof Lifecycle && ((Lifecycle) manager).getState().isAvailable()) {
                ((Lifecycle) manager).stop();
            }
            // Stop our application listeners
            listenerStop();
        } finally {
            unbindThread(old);
        }
        // Finalize our character set mapper
        setCharsetMapper(null);
        // Normal container shutdown processing
        if (log.isDebugEnabled())
            log.debug("Processing standard container shutdown");
        // after the application has finished with the resource
        if (namingResources != null) {
            namingResources.stop();
        }
        fireLifecycleEvent(Lifecycle.CONFIGURE_STOP_EVENT, null);
        // Stop the Valves in our pipeline (including the basic), if any
        if (pipeline instanceof Lifecycle && ((Lifecycle) pipeline).getState().isAvailable()) {
            ((Lifecycle) pipeline).stop();
        }
        // Clear all application-originated servlet context attributes
        if (context != null)
            context.clearAttributes();
        // Stop resources
        resourcesStop();
        Realm realm = getRealmInternal();
        if ((realm != null) && (realm instanceof Lifecycle)) {
            ((Lifecycle) realm).stop();
        }
        Cluster cluster = getClusterInternal();
        if ((cluster != null) && (cluster instanceof Lifecycle)) {
            ((Lifecycle) cluster).stop();
        }
        Loader loader = getLoaderInternal();
        if ((loader != null) && (loader instanceof Lifecycle)) {
            ((Lifecycle) loader).stop();
        }
    } finally {
        // Unbinding thread
        unbindThread(oldCCL);
    }
    // Send j2ee.state.stopped notification
    if (this.getObjectName() != null) {
        Notification notification = new Notification("j2ee.state.stopped", this.getObjectName(), sequenceNumber.getAndIncrement());
        broadcaster.sendNotification(notification);
    }
    // Reset application context
    context = null;
    // This object will no longer be visible or used.
    try {
        resetContext();
    } catch (Exception ex) {
        log.error("Error resetting context " + this + " " + ex, ex);
    }
    // reset the instance manager
    setInstanceManager(null);
    if (log.isDebugEnabled())
        log.debug("Stopping complete");
}
Also used : Container(org.apache.catalina.Container) Lifecycle(org.apache.catalina.Lifecycle) Cluster(org.apache.catalina.Cluster) WebappLoader(org.apache.catalina.loader.WebappLoader) Loader(org.apache.catalina.Loader) Manager(org.apache.catalina.Manager) InstanceManager(org.apache.tomcat.InstanceManager) StandardManager(org.apache.catalina.session.StandardManager) Realm(org.apache.catalina.Realm) Notification(javax.management.Notification) SecurityConstraint(org.apache.catalina.deploy.SecurityConstraint) LifecycleException(org.apache.catalina.LifecycleException) ListenerNotFoundException(javax.management.ListenerNotFoundException) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) NamingException(javax.naming.NamingException) MalformedURLException(java.net.MalformedURLException)

Aggregations

Manager (org.apache.catalina.Manager)54 StringManager (org.apache.tomcat.util.res.StringManager)26 IOException (java.io.IOException)22 Session (org.apache.catalina.Session)22 Context (org.apache.catalina.Context)19 Container (org.apache.catalina.Container)13 LifecycleException (org.apache.catalina.LifecycleException)12 Lifecycle (org.apache.catalina.Lifecycle)11 Loader (org.apache.catalina.Loader)11 InstanceManager (org.apache.tomcat.InstanceManager)11 StandardManager (org.apache.catalina.session.StandardManager)10 Realm (org.apache.catalina.Realm)9 ServletException (javax.servlet.ServletException)7 ArrayList (java.util.ArrayList)6 NamingException (javax.naming.NamingException)6 Cluster (org.apache.catalina.Cluster)6 DistributedManager (org.apache.catalina.DistributedManager)6 StandardContext (org.apache.catalina.core.StandardContext)6 WebappLoader (org.apache.catalina.loader.WebappLoader)6 ServletException (jakarta.servlet.ServletException)5