head	1.6;
access;
symbols;
locks; strict;
comment	@# @;


1.6
date	2001.08.11.09.08.02;	author dlr;	state Exp;
branches;
next	1.5;

1.5
date	2001.07.18.10.05.13;	author dlr;	state Exp;
branches;
next	1.4;

1.4
date	2001.07.17.20.26.16;	author leonardr;	state Exp;
branches;
next	1.3;

1.3
date	2001.05.30.20.15.24;	author leonardr;	state Exp;
branches;
next	1.2;

1.2
date	2001.05.23.02.03.41;	author leonardr;	state Exp;
branches;
next	1.1;

1.1
date	2001.05.23.01.21.03;	author leonardr;	state Exp;
branches;
next	;


desc
@@


1.6
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@/* ================================================================
 * Copyright (c) 2001 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.collab.net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */

package org.tigris.helm.host;
import java.sql.Connection;

import org.apache.velocity.context.Context;
import org.apache.commons.util.exception.NestableException;
import org.tigris.helm.security.RedirectException;

import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.tool.cache.CacheRegistryService;
import org.tigris.helm.tool.ContextAPI;

/**
 * Dumps a description of all the currently registered caches.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Id: CacheDump.java,v 1.5 2001/07/18 10:05:13 dlr Exp $
 */
public class CacheDump extends HelmServlet 
{
    /**
     * Whether or not to log debugging information.
     */
    private static final boolean DEBUG = true;

    /** 
     * The action describing the sending of a cache invalidation event.
     */
    private final static String SEND_CACHE_INVALIDATION_EVENT_ACTION
        = "Invalidate Interested Caches";

    /** 
     * The field containing the invalidation event to set.
     */
    private final static String CACHE_INVALIDATION_EVENT_FIELD 
        = "invalidationEvent";

    /**
     *  Get a cache description, possibly one obtained after a cache
     *  invalidation. 
     */
    protected String processRequest (Context context)
        throws NestableException, RedirectException
    {
        String templateName = super.processRequest(context);

        if (SEND_CACHE_INVALIDATION_EVENT_ACTION.equals(getAction(context)))
        {
            String descriptor = ContextAPI.processField
                (context, CACHE_INVALIDATION_EVENT_FIELD);
            try
            {
                CacheRegistryService.getService().invalidate(descriptor);
                ContextAPI.addMessage
                    (context, "All caches interested in \"" + descriptor
                     + "\" invalidated.");
            }
            catch (Exception e)
            {
                ContextAPI.addError
                    (context, "Error sending cache invalidation for " 
                     + descriptor + ": " + e.getMessage());
            }
        }

        context.put("invalidationEvents", 
                    CacheRegistryService.getService().getCurrentDescriptors());
        context.put("cacheDump", CacheRegistryService.getService()
                    .describeCaches());

        return templateName;  
    }
}
@


1.5
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d51 1
a51 1
import org.apache.turbine.util.TurbineException;
d62 1
a62 1
 * @@version $Id: CacheDump.java,v 1.4 2001/07/17 20:26:16 leonardr Exp $
d88 1
a88 1
        throws TurbineException, RedirectException
@


1.4
log
@Ported servlet to new error-handling mechanism.
@
text
@d52 1
a52 1
import org.joist.security.RedirectException;
d62 1
a62 1
 * @@version $Id: CacheDump.java,v 1.3 2001/05/30 20:15:24 leonardr Exp $
@


1.3
log
@Big cleanup of cache self-descriptions. Also added an admin tool to do manual selective cache invalidation.
@
text
@d56 1
d62 1
a62 1
 * @@version $Id: CacheDump.java,v 1.2 2001/05/23 02:03:41 leonardr Exp $
d94 2
a95 2
            String descriptor = processField(context, 
                                             CACHE_INVALIDATION_EVENT_FIELD);
d99 3
a101 3
                appendToMessage(context,
                                "All caches interested in \"" + descriptor
                                + "\" invalidated.");
d105 3
a107 3
                throw new TurbineException
                    ("Error sending cache invalidation for " + descriptor 
                     + ": " + e.getMessage());
@


1.2
log
@Converted to Velocity.
@
text
@d61 1
a61 1
 * @@version $Id: CacheDump.java,v 1.1 2001/05/23 01:21:03 leonardr Exp $
d70 12
d83 2
a84 1
     *  Rebuild data structures and start/stop threads.
d90 22
d114 1
@


1.1
log
@New servlet to dump JVM cache information: CacheDump.
@
text
@d50 2
a51 2
import org.webmacro.servlet.*;

d61 1
a61 1
 * @@version $Id: AdminUtils.java,v 1.17 2001/05/21 21:06:00 leonardr Exp $
d73 2
a74 2
    protected String processRequest (Connection conn, WebContext context)
        throws HandlerException, RedirectException
d76 1
a76 1
        String templateName = super.processRequest(conn, context);
@

