cvs commit: cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity NameValueEvent.java Event.java EventValidity.java NamedEvent.java
ghoward 2003/06/30 20:54:13 Modified:src/scratchpad/src/org/apache/cocoon/caching/validity NameValueEvent.java Event.java EventValidity.java NamedEvent.java Log: oops Revision ChangesPath 1.3 +1 -1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/NameValueEvent.java Index: NameValueEvent.java === RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/NameValueEvent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- NameValueEvent.java 1 Jul 2003 03:44:16 - 1.2 +++ NameValueEvent.java 1 Jul 2003 03:54:13 - 1.3 @@ -54,7 +54,7 @@ * An example might be "table_name", "primary_key" * * @author Geoff Howard ([EMAIL PROTECTED]) - * @version $CVS$ + * @version $Id$ */ public class NameValueEvent extends Event { 1.3 +1 -2 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/Event.java Index: Event.java === RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/Event.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Event.java1 Jul 2003 03:44:16 - 1.2 +++ Event.java1 Jul 2003 03:54:13 - 1.3 @@ -54,8 +54,7 @@ * uncache event. * * @author Geoff Howard ([EMAIL PROTECTED]) - * - * @version $CVS$ + * @version $Id$ */ public abstract class Event { 1.3 +1 -1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/EventValidity.java Index: EventValidity.java === RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/EventValidity.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- EventValidity.java1 Jul 2003 03:44:16 - 1.2 +++ EventValidity.java1 Jul 2003 03:54:13 - 1.3 @@ -56,7 +56,7 @@ * external events. * * @author Geoff Howard ([EMAIL PROTECTED]) - * @version $CVS$ + * @version $Id$ */ public class EventValidity implements SourceValidity { 1.3 +1 -1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/NamedEvent.java Index: NamedEvent.java === RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/NamedEvent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- NamedEvent.java 1 Jul 2003 03:44:16 - 1.2 +++ NamedEvent.java 1 Jul 2003 03:54:13 - 1.3 @@ -54,7 +54,7 @@ * (not necessarily useful) could include "Easter" or "Shutdown" * * @author Geoff Howard ([EMAIL PROTECTED]) - * @version $CVS$ + * @version $Id$ */ public class NamedEvent extends Event {
cvs commit: cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity NameValueEvent.java Event.java EventValidity.java NamedEvent.java
ghoward 2003/06/30 20:44:17 Modified:src/scratchpad/src/org/apache/cocoon/caching/validity NameValueEvent.java Event.java EventValidity.java NamedEvent.java Log: Add hashCode for lookup in EventAwareCacheImpl Revision ChangesPath 1.2 +19 -11 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/NameValueEvent.java Index: NameValueEvent.java === RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/NameValueEvent.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- NameValueEvent.java 21 Jun 2003 03:36:14 - 1.1 +++ NameValueEvent.java 1 Jul 2003 03:44:16 - 1.2 @@ -60,27 +60,35 @@ private String m_name; private String m_value; +private int m_hashcode; +/** + * Constructor requires two Strings - the name/value + * pair which defines this Event. + * + * @param name + * @param value + */ public NameValueEvent(String name, String value) { m_name = name; m_value = value; +m_hashcode = (name + value).hashCode(); } -private String getName() { -return m_name; -} - -private String getValue() { -return m_value; -} - +/** + * Must return true when both name and value are + * equivalent Strings. + */ public boolean equals(Event e) { if (e instanceof NameValueEvent) { NameValueEvent nve = (NameValueEvent)e; -return ( m_name.equals(nve.getName()) && -m_value.equals(nve.getValue()) ); +return ( m_name.equals(nve.m_name) && +m_value.equals(nve.m_value) ); } return false; } - + +public int hashCode() { +return m_hashcode; +} } 1.2 +14 -0 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/Event.java Index: Event.java === RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/Event.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Event.java21 Jun 2003 03:36:14 - 1.1 +++ Event.java1 Jul 2003 03:44:16 - 1.2 @@ -59,7 +59,21 @@ */ public abstract class Event { +/** + * Used by EventValidity for equals(Object o) which + * is important for determining whether a received event + * should uncache a held Pipeline key. + * + * @param event Another Event to compare. + * @return true if + */ public abstract boolean equals(Event e); + +/** + * This hash code is the only way the system can locate + * matching Events when a new event notification is received. + */ +public abstract int hashCode(); public boolean equals(Object o) { if (o instanceof Event) { 1.2 +30 -4 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/EventValidity.java Index: EventValidity.java === RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/EventValidity.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- EventValidity.java21 Jun 2003 03:36:14 - 1.1 +++ EventValidity.java1 Jul 2003 03:44:16 - 1.2 @@ -55,32 +55,58 @@ * The SourceValidity object for cache invalidation based on * external events. * - * @author Geoff Howard([EMAIL PROTECTED]) - * @version $CVS$ + * @author Geoff Howard ([EMAIL PROTECTED]) + * @version $CVS$ */ public class EventValidity implements SourceValidity { private Event m_event; +/** + * Constructor requires any subclass of Event. + * @param ev + */ public EventValidity(Event ev) { m_event = ev; } +/** + * Returns the specific Event this validity is based on. + * + * @return Event + */ public Event getEvent() { return m_event; } - /** Basic implementation is always valid until event signals - * otherwise. May never need other behavior. + /** + * Basic implementation is always valid until event signals + * otherwise. May never need other behavior. */ public int isValid() { return VALID; } +/** + * Older style of isValid + */ public int isValid(SourceValidity sv) {
cvs commit: cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity NameValueEvent.java Event.java EventValidity.java NamedEvent.java
ghoward 2003/06/20 20:36:15 Added: src/scratchpad/src/org/apache/cocoon/caching/validity NameValueEvent.java Event.java EventValidity.java NamedEvent.java Log: Experiment with external cache invalidation. An EventAwareCacheImpl can't be committed yet because it relies on the latest sourceresolve cvs. Revision ChangesPath 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/NameValueEvent.java Index: NameValueEvent.java === /* The Apache Software License, Version 1.1 Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, 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 acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. 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 THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, 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. */ package org.apache.cocoon.caching.validity; /** * Very experimental start at external cache invalidation. * Warning - API very unstable. Do not use! In fact, if this * becomes useful, it would probably move to Excalibur SourceResolve. * * An external uncache event that consists of a name/value pair. * An example might be "table_name", "primary_key" * * @author Geoff Howard ([EMAIL PROTECTED]) * @version $CVS$ */ public class NameValueEvent extends Event { private String m_name; private String m_value; public NameValueEvent(String name, String value) { m_name = name; m_value = value; } private String getName() { return m_name; } private String getValue() { return m_value; } public boolean equals(Event e) { if (e instanceof NameValueEvent) { NameValueEvent nve = (NameValueEvent)e; return ( m_name.equals(nve.getName()) && m_value.equals(nve.getValue()) ); } return false; } } 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/caching/validity/Event.java Index: Event.java === /* The Apache Software License, Version 1.1 Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above