org.apache.catalina.session.PersistentManager Java Examples

The following examples show how to use org.apache.catalina.session.PersistentManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JvmRouteBinderValve.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Detect possible the JVMRoute change at cluster backup node..
 *
 * @param request
 *            tomcat request being processed
 * @param response
 *            tomcat response being processed
 * @exception IOException
 *                if an input/output error has occurred
 * @exception ServletException
 *                if a servlet error has occurred
 */
@Override
public void invoke(Request request, Response response) throws IOException,
        ServletException {

     if (getEnabled() &&
             request.getContext() != null &&
             request.getContext().getDistributable() &&
             !request.isAsyncDispatching()) {
         // valve cluster can access manager - other cluster handle turnover
         // at host level - hopefully!
         Manager manager = request.getContext().getManager();

         if (manager != null && (
                 (manager instanceof ClusterManager
                   && getCluster() != null
                   && getCluster().getManager(((ClusterManager)manager).getName()) != null)
                 ||
                 (manager instanceof PersistentManager))) {
            handlePossibleTurnover(request);
        }
    }
    // Pass this request on to the next valve in our pipeline
    getNext().invoke(request, response);
}
 
Example #2
Source File: PersistentManagerSF.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Store the specified PersistentManager properties.
 *
 * @param aWriter
 *            PrintWriter to which we are storing
 * @param indent
 *            Number of spaces to indent this element
 * @param aManager
 *            PersistentManager whose properties are being stored
 *
 * @exception Exception
 *                if an exception occurs while storing
 */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aManager,
        StoreDescription parentDesc) throws Exception {
    if (aManager instanceof PersistentManager) {
        PersistentManager manager = (PersistentManager) aManager;

        // Store nested <Store> element
        Store store = manager.getStore();
        storeElement(aWriter, indent, store);

        // Store nested <SessionIdGenerator> element
        SessionIdGenerator sessionIdGenerator = manager.getSessionIdGenerator();
        if (sessionIdGenerator != null) {
            storeElement(aWriter, indent, sessionIdGenerator);
        }

    }
}
 
Example #3
Source File: JvmRouteBinderValve.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Detect possible the JVMRoute change at cluster backup node..
 * 
 * @param request
 *            tomcat request being processed
 * @param response
 *            tomcat response being processed
 * @exception IOException
 *                if an input/output error has occurred
 * @exception ServletException
 *                if a servlet error has occurred
 */
@Override
public void invoke(Request request, Response response) throws IOException,
        ServletException {

     if (getEnabled() &&
             request.getContext() != null &&
             request.getContext().getDistributable() &&
             !request.isAsyncDispatching()) {
         // valve cluster can access manager - other cluster handle turnover 
         // at host level - hopefully!
         Manager manager = request.getContext().getManager();

         if (manager != null && (
                 (manager instanceof ClusterManager
                   && getCluster() != null
                   && getCluster().getManager(((ClusterManager)manager).getName()) != null)
                 ||
                 (manager instanceof PersistentManager)))
             handlePossibleTurnover(request);
    }
    // Pass this request on to the next valve in our pipeline
    getNext().invoke(request, response);
}
 
Example #4
Source File: JvmRouteBinderValve.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Detect possible the JVMRoute change at cluster backup node..
 * 
 * @param request
 *            tomcat request being processed
 * @param response
 *            tomcat response being processed
 * @exception IOException
 *                if an input/output error has occurred
 * @exception ServletException
 *                if a servlet error has occurred
 */
@Override
public void invoke(Request request, Response response) throws IOException,
        ServletException {

     if (getEnabled() &&
             request.getContext() != null &&
             request.getContext().getDistributable() &&
             !request.isAsyncDispatching()) {
         // valve cluster can access manager - other cluster handle turnover 
         // at host level - hopefully!
         Manager manager = request.getContext().getManager();

         if (manager != null && (
                 (manager instanceof ClusterManager
                   && getCluster() != null
                   && getCluster().getManager(((ClusterManager)manager).getName()) != null)
                 ||
                 (manager instanceof PersistentManager)))
             handlePossibleTurnover(request);
    }
    // Pass this request on to the next valve in our pipeline
    getNext().invoke(request, response);
}
 
Example #5
Source File: Application.java    From spring-boot-spring-loaded-java8-example with Apache License 2.0 6 votes vote down vote up
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
    return factory -> {
        TomcatEmbeddedServletContainerFactory containerFactory = (TomcatEmbeddedServletContainerFactory) factory;
        containerFactory.setTomcatContextCustomizers(Arrays.asList(context -> {
            final PersistentManager persistentManager = new PersistentManager();
            final FileStore store = new FileStore();

            final String sessionDirectory = makeSessionDirectory();
            log.info("Writing sessions to " + sessionDirectory);
            store.setDirectory(sessionDirectory);

            persistentManager.setStore(store);
            context.setManager(persistentManager);
        }));
    };
}