ghoward 2003/09/04 21:02:52
Modified: src/blocks/eventcache/java/org/apache/cocoon/caching/impl
DefaultEventRegistryImpl.java
EventAwareCacheImpl.java
EventRegistryDataWrapper.java
src/blocks/eventcache/java/org/apache/cocoon/caching/validity
EventValidity.java NameValueEvent.java Event.java
NamedEvent.java
Added: src/blocks/eventcache/java/org/apache/cocoon/caching/impl
StoreEventRegistryImpl.java
Log:
- Remove dire warnings
- add registry impl which uses Store instead of raw serialization.
- slight internal refactoring of Default registry to facilitate Store version
Revision Changes Path
1.5 +15 -7
cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/DefaultEventRegistryImpl.java
Index: DefaultEventRegistryImpl.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/DefaultEventRegistryImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultEventRegistryImpl.java 4 Aug 2003 03:09:42 -0000 1.4
+++ DefaultEventRegistryImpl.java 5 Sep 2003 04:02:51 -0000 1.5
@@ -233,8 +233,7 @@
try {
oos = new ObjectOutputStream(
new
FileOutputStream(this.m_persistentFile));
- EventRegistryDataWrapper ecdw = new EventRegistryDataWrapper();
- ecdw.setupMaps(this.m_keyMMap, this.m_eventMMap);
+ EventRegistryDataWrapper ecdw = wrapRegistry();
oos.writeObject(ecdw);
oos.flush();
} catch (FileNotFoundException e) {
@@ -252,12 +251,18 @@
m_eventMMap = null;
}
+ protected EventRegistryDataWrapper wrapRegistry() {
+ EventRegistryDataWrapper ecdw = new EventRegistryDataWrapper();
+ ecdw.setupMaps(this.m_keyMMap, this.m_eventMMap);
+ return ecdw;
+ }
+
/*
* I don't think this needs to get synchronized because it should
* only be called during initialize, which should only be called
* once by the container.
*/
- private boolean recover() {
+ protected boolean recover() {
if (this.m_persistentFile.exists()) {
ObjectInputStream ois = null;
EventRegistryDataWrapper ecdw = null;
@@ -284,9 +289,7 @@
// ignore
}
}
-
- this.m_eventMMap = ecdw.get_eventMap();
- this.m_keyMMap = ecdw.get_keyMap();
+ unwrapRegistry(ecdw);
} else {
getLogger().warn(this.m_persistentFile + " does not exist -
Unable to " +
"retrieve EventRegistry.");
@@ -295,6 +298,11 @@
}
return true;
}
+
+ protected void unwrapRegistry(EventRegistryDataWrapper ecdw) {
+ this.m_eventMMap = ecdw.get_eventMap();
+ this.m_keyMMap = ecdw.get_keyMap();
+ }
// TODO: don't hardcode initial size
private void createBlankCache() {
1.5 +1 -8
cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/EventAwareCacheImpl.java
Index: EventAwareCacheImpl.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/EventAwareCacheImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EventAwareCacheImpl.java 7 Aug 2003 08:52:15 -0000 1.4
+++ EventAwareCacheImpl.java 5 Sep 2003 04:02:51 -0000 1.5
@@ -61,15 +61,8 @@
import org.apache.excalibur.source.impl.validity.AggregatedValidity;
/**
- * Very experimental start at external cache invalidation.
- * Warning - API very unstable. Do not use!
- * (But it's getting closer!)
- *
* This implementation holds all mappings between Events and
PipelineCacheKeys
* in two MultiHashMap to facilitate efficient lookup by either as Key.
- *
- * TODO: Test performance.
- * TODO: Handle MultiThreading
*
* @author Geoff Howard ([EMAIL PROTECTED])
* @version $Id$
1.2 +2 -2
cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/EventRegistryDataWrapper.java
Index: EventRegistryDataWrapper.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/EventRegistryDataWrapper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EventRegistryDataWrapper.java 14 Jul 2003 02:50:45 -0000 1.1
+++ EventRegistryDataWrapper.java 5 Sep 2003 04:02:51 -0000 1.2
@@ -58,7 +58,7 @@
* A light object for persisting the state of an EventRegistry
implementation
* based on two MultiHashMaps.
*
- * @author [EMAIL PROTECTED]
+ * @author <a href="mailto:[EMAIL PROTECTED]">Geoff Howard</a>
* @version CVS $Id$
*/
public class EventRegistryDataWrapper implements Serializable {
1.1
cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/StoreEventRegistryImpl.java
Index: StoreEventRegistryImpl.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.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.caching.impl;
import java.io.IOException;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.excalibur.store.Store;
/**
* This implementation of <code>EventRegistry</code> extends <code>
* DefaultEventRegistry</code> to handle persistence by storing its
* <code>EventRegistryDataWrapper</code> in the <code>PersistentStore</code>
* defined in cocoon.xconf.
*
* @since 2.1
* @author <a href="mailto:[EMAIL PROTECTED]">Geoff Howard</a>
* @version CVS $Id: StoreEventRegistryImpl.java,v 1.1 2003/09/05 04:02:51
ghoward Exp $
*/
public class StoreEventRegistryImpl
extends DefaultEventRegistryImpl implements Composable {
private static final String EVENTREGISTRYKEY = "EVENTREGWRAPPER";
private boolean m_init_success = false;
private ComponentManager m_manager;
private Store m_persistentStore;
/**
* Completely override dispose from superclass to persist the
* data wrapper in the Store instead of a serialized file on disk.
*/
public void dispose() {
EventRegistryDataWrapper ecdw = wrapRegistry();
try {
m_persistentStore.store(EVENTREGISTRYKEY,ecdw);
} catch (IOException e) {
getLogger().warn("Unable to persist Event Registry");
}
this.m_manager.release(this.m_persistentStore);
m_manager = null;
m_persistentStore = null;
}
/**
* Obtain a reference to the Store
*/
public void compose(ComponentManager manager) throws ComponentException
{
this.m_manager = manager;
this.m_persistentStore =
(Store)manager.lookup(Store.PERSISTENT_STORE);
}
/**
* Recover the datawrapper from the Store.
*/
protected boolean recover() {
Object o = m_persistentStore.get(EVENTREGISTRYKEY);
m_persistentStore.remove(EVENTREGISTRYKEY);
if (o != null && o instanceof EventRegistryDataWrapper) {
if (getLogger().isInfoEnabled()) {
getLogger().info("Retrieving EventRegistry from
PersistentStore.");
}
unwrapRegistry((EventRegistryDataWrapper)o);
return true;
} else {
getLogger().warn("Unable to recover Event Registry.");
return false;
}
}
}
1.2 +1 -5
cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/validity/EventValidity.java
Index: EventValidity.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/validity/EventValidity.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EventValidity.java 14 Jul 2003 02:50:45 -0000 1.1
+++ EventValidity.java 5 Sep 2003 04:02:51 -0000 1.2
@@ -48,10 +48,6 @@
import org.apache.excalibur.source.SourceValidity;
/**
- * 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.
- *
* The SourceValidity object for cache invalidation based on
* external events.
*
1.2 +1 -5
cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/validity/NameValueEvent.java
Index: NameValueEvent.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/validity/NameValueEvent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NameValueEvent.java 14 Jul 2003 02:50:45 -0000 1.1
+++ NameValueEvent.java 5 Sep 2003 04:02:51 -0000 1.2
@@ -46,10 +46,6 @@
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"
*
1.2 +1 -5
cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/validity/Event.java
Index: Event.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/validity/Event.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Event.java 14 Jul 2003 02:50:45 -0000 1.1
+++ Event.java 5 Sep 2003 04:02:51 -0000 1.2
@@ -48,10 +48,6 @@
import java.io.Serializable;
/**
- * 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.
- *
* Base class encapsulating the information about an external
* uncache event.
*
1.2 +1 -5
cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/validity/NamedEvent.java
Index: NamedEvent.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/validity/NamedEvent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NamedEvent.java 14 Jul 2003 02:50:45 -0000 1.1
+++ NamedEvent.java 5 Sep 2003 04:02:51 -0000 1.2
@@ -46,10 +46,6 @@
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 cache event that consists of just a name. Examples
* (not necessarily useful) could include "Easter" or "Shutdown"
*