cziegeler 2004/05/17 00:53:42
Modified: lib jars.xml
src/webapp/WEB-INF cocoon.xconf
Added: lib/core jcs-1.0-dev-20040303.jar
src/java/org/apache/cocoon/components/store
JCSPersistentStore.java transient.ccf default.ccf
AbstractJCSStore.java persistent.ccf
JCSDefaultStore.java JCSTransientStore.java
Removed: src/blocks/scratchpad/conf jcs-store.xconf
src/blocks/scratchpad/java/org/apache/cocoon/components/store
transient.ccf JCSDefaultStore.java
JCSTransientStore.java AbstractJCSStore.java
default.ccf
src/blocks/scratchpad/lib jcs-1.0-dev-20040303.jar
Log:
JCS is now the default cache (jcs is currently compield against 1.4)
Revision Changes Path
1.1 cocoon-2.1/lib/core/jcs-1.0-dev-20040303.jar
<<Binary file>>
1.1
cocoon-2.1/src/java/org/apache/cocoon/components/store/JCSPersistentStore.java
Index: JCSPersistentStore.java
===================================================================
/*
* Copyright 2004,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cocoon.components.store;
import org.apache.avalon.framework.context.Contextualizable;
/**
* This is the persistent store implementation based on JCS
* http://jakarta.apache.org/turbine/jcs/BasicJCSConfiguration.html
*
* @version CVS $Id: JCSPersistentStore.java,v 1.1 2004/05/17 07:53:41
cziegeler Exp $
*/
public class JCSPersistentStore
extends JCSDefaultStore
implements Contextualizable {
/** The location of the JCS default properties file */
private static final String DEFAULT_PROPERTIES =
"org/apache/cocoon/components/store/persistent.ccf";
protected String getDefaultPropertiesFile() {
return DEFAULT_PROPERTIES;
}
}
1.1
cocoon-2.1/src/java/org/apache/cocoon/components/store/transient.ccf
Index: transient.ccf
===================================================================
# Cache configuration defaults.
# Copyright 1999-2004 The Apache Software Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=100
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
# SYSTEM GROUP ID CACHE
jcs.system.groupIdCache=
jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=1000
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.main=
jcs.region.main.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.main.cacheattributes.MaxObjects=100
jcs.region.main.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.main.cacheattributes.UseMemoryShrinker=true
jcs.region.main.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.main.cacheattributes.ShrinkerIntervalSeconds=60
1.1
cocoon-2.1/src/java/org/apache/cocoon/components/store/default.ccf
Index: default.ccf
===================================================================
# Cache configuration defaults.
# Copyright 1999-2004 The Apache Software Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
jcs.default=DC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=100
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
# SYSTEM GROUP ID CACHE
jcs.system.groupIdCache=DC
jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=1000
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
##### AUXILIARY CACHES
# Indexed Disk Cache
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
#jcs.auxiliary.DC.attributes.DiskPath=
# PRE-DEFINED CACHE REGIONS
jcs.region.main=DC
jcs.region.main.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.main.cacheattributes.MaxObjects=100
jcs.region.main.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.main.cacheattributes.UseMemoryShrinker=true
jcs.region.main.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.main.cacheattributes.ShrinkerIntervalSeconds=60
1.1
cocoon-2.1/src/java/org/apache/cocoon/components/store/AbstractJCSStore.java
Index: AbstractJCSStore.java
===================================================================
/*
* Copyright 2004,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cocoon.components.store;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.commons.collections.iterators.IteratorEnumeration;
import org.apache.excalibur.store.Store;
import org.apache.jcs.access.GroupCacheAccess;
import org.apache.jcs.access.exception.CacheException;
import org.apache.jcs.engine.control.CompositeCache;
import org.apache.jcs.engine.control.CompositeCacheManager;
/**
* This is the base class for a store implementation based on JCS.
* For JCS Configuration details see:
* http://jakarta.apache.org/turbine/jcs/BasicJCSConfiguration.html
*
* @version CVS $Id: AbstractJCSStore.java,v 1.1 2004/05/17 07:53:41
cziegeler Exp $
*/
public abstract class AbstractJCSStore
extends AbstractLogEnabled
implements Store,
Parameterizable,
Initializable,
Disposable,
ThreadSafe {
/** The JCS configuration properties */
protected Properties properties;
/** The JCS region name */
protected String region;
/** JCS Cache manager */
private CompositeCacheManager cacheManager;
/** The Java Cache System object */
private JCSCacheAccess jcs;
/**
* Override in sub classes
*/
protected abstract String getDefaultPropertiesFile();
/* (non-Javadoc)
* @see
org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
*/
public void parameterize(Parameters parameters)
throws ParameterException {
this.region = parameters.getParameter("region-name","main");
Properties defaults = new Properties();
try {
String defaultsFile = this.getDefaultPropertiesFile();
if (defaultsFile != null) {
defaults.load(Thread.currentThread().getContextClassLoader().
getResourceAsStream(defaultsFile));
}
} catch (IOException e) {
throw new ParameterException("Failure loading cache defaults",e);
}
this.properties = new Properties(defaults);
String[] names = parameters.getNames();
for (int i = 0; i < names.length; i++) {
if (names[i].startsWith("jcs.")) {
this.properties.put(names[i],
parameters.getParameter(names[i]));
}
}
}
/* (non-Javadoc)
* @see org.apache.avalon.framework.activity.Initializable#initialize()
*/
public void initialize() throws Exception {
this.cacheManager = CompositeCacheManager.getUnconfiguredInstance();
this.cacheManager.configure(this.properties);
this.jcs = new JCSCacheAccess(cacheManager.getCache(region));
}
/* (non-Javadoc)
* @see org.apache.avalon.framework.activity.Disposable#dispose()
*/
public void dispose() {
if ( this.jcs != null ) {
this.jcs.dispose();
this.jcs = null;
}
if ( this.cacheManager != null ) {
this.cacheManager.release();
this.cacheManager = null;
}
this.properties = null;
}
// ---------------------------------------------------- Store
implementation
/* (non-Javadoc)
* @see org.apache.excalibur.store.Store#get(java.lang.Object)
*/
public Object get(Object key) {
Object value = this.jcs.get(key);
if (getLogger().isDebugEnabled()) {
if (value != null) {
getLogger().debug("Found key: " + key);
} else {
getLogger().debug("NOT Found key: " + key);
}
}
return value;
}
/* (non-Javadoc)
* @see org.apache.excalibur.store.Store#store(java.lang.Object,
java.lang.Object)
*/
public void store(Object key, Object value)
throws IOException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Store object " + value + " with key "+ key);
}
try {
this.jcs.put(key, value);
} catch (CacheException ce) {
getLogger().error("Failure storing object ", ce);
}
}
/* (non-Javadoc)
* @see org.apache.excalibur.store.Store#free()
*/
public void free() {
// TODO
}
/* (non-Javadoc)
* @see org.apache.excalibur.store.Store#clear()
*/
public void clear() {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Clearing the store");
}
try {
this.jcs.remove();
} catch (CacheException ce) {
getLogger().error("Failure clearing store", ce);
}
}
/* (non-Javadoc)
* @see org.apache.excalibur.store.Store#remove(java.lang.Object)
*/
public void remove(Object key) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Removing item " + key);
}
try {
this.jcs.remove(key);
} catch (CacheException ce) {
getLogger().error("Failure removing object", ce);
}
}
/* (non-Javadoc)
* @see org.apache.excalibur.store.Store#containsKey(java.lang.Object)
*/
public boolean containsKey(Object key) {
return this.jcs.get(key) != null;
}
/* (non-Javadoc)
* @see org.apache.excalibur.store.Store#keys()
*/
public Enumeration keys() {
return new IteratorEnumeration(this.jcs.getGroupKeys("").iterator());
}
/* (non-Javadoc)
* @see org.apache.excalibur.store.Store#size()
*/
public int size() {
return this.jcs.getSize();
}
private static class JCSCacheAccess extends GroupCacheAccess {
private JCSCacheAccess(CompositeCache cacheControl) {
super(cacheControl);
}
private int getSize() {
return super.cacheControl.getSize();
}
protected void dispose() {
super.dispose();
}
}
}
1.1
cocoon-2.1/src/java/org/apache/cocoon/components/store/persistent.ccf
Index: persistent.ccf
===================================================================
# Cache configuration defaults.
# Copyright 1999-2004 The Apache Software Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
jcs.default=DC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=100
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
# SYSTEM GROUP ID CACHE
jcs.system.groupIdCache=DC
jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=1000
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
##### AUXILIARY CACHES
# Indexed Disk Cache
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
#jcs.auxiliary.DC.attributes.DiskPath=
# PRE-DEFINED CACHE REGIONS
jcs.region.main=DC
jcs.region.main.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.main.cacheattributes.MaxObjects=100
jcs.region.main.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.main.cacheattributes.UseMemoryShrinker=true
jcs.region.main.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.region.main.cacheattributes.ShrinkerIntervalSeconds=60
1.1
cocoon-2.1/src/java/org/apache/cocoon/components/store/JCSDefaultStore.java
Index: JCSDefaultStore.java
===================================================================
/*
* Copyright 2004,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cocoon.components.store;
import java.io.File;
import java.io.IOException;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.Constants;
import org.apache.cocoon.util.IOUtils;
/**
* This is the default store implementation based on JCS
* http://jakarta.apache.org/turbine/jcs/BasicJCSConfiguration.html
*
* @version CVS $Id: JCSDefaultStore.java,v 1.1 2004/05/17 07:53:41 cziegeler
Exp $
*/
public class JCSDefaultStore
extends JCSTransientStore
implements Contextualizable {
/** The location of the JCS default properties file */
private static final String DEFAULT_PROPERTIES =
"org/apache/cocoon/components/store/default.ccf";
/** The context containing the work and the cache directory */
private Context context;
/* (non-Javadoc)
* @see
org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
*/
public void contextualize(Context aContext) throws ContextException {
this.context = aContext;
}
/* (non-Javadoc)
* @see
org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
*/
public void parameterize(Parameters parameters)
throws ParameterException {
// TODO describe options
super.parameterize(parameters);
// get the directory to use
try {
final File workDir = (File)
context.get(Constants.CONTEXT_WORK_DIR);
if (parameters.getParameterAsBoolean("use-cache-directory",
false)) {
final File cacheDir = (File)
context.get(Constants.CONTEXT_CACHE_DIR);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Using cache directory: " + cacheDir);
}
setDirectory(cacheDir);
} else if (parameters.getParameterAsBoolean("use-work-directory",
false)) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Using work directory: " + workDir);
}
setDirectory(workDir);
} else if (parameters.getParameter("directory", null) != null) {
String dir = parameters.getParameter("directory");
dir = IOUtils.getContextFilePath(workDir.getPath(), dir);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Using directory: " + dir);
}
setDirectory(new File(dir));
} else {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Using default directory: " + workDir);
}
setDirectory(workDir);
}
} catch (ContextException ce) {
throw new ParameterException("Unable to get directory information
from context.", ce);
} catch (IOException e) {
throw new ParameterException("Unable to set directory", e);
}
}
protected String getDefaultPropertiesFile() {
return DEFAULT_PROPERTIES;
}
/**
* Sets the disk cache location.
*/
private void setDirectory(final File directory)
throws IOException {
/* Does directory exist? */
if (!directory.exists()) {
/* Create it anew */
if (!directory.mkdirs()) {
throw new IOException(
"Error creating store directory '" +
directory.getAbsolutePath() + "'. ");
}
}
/* Is given file actually a directory? */
if (!directory.isDirectory()) {
throw new IOException("'" + directory.getAbsolutePath() + "' is
not a directory");
}
/* Is directory readable and writable? */
if (!(directory.canRead() && directory.canWrite())) {
throw new IOException(
"Directory '" + directory.getAbsolutePath() + "' is not
readable/writable"
);
}
this.properties.setProperty("jcs.auxiliary.DC.attributes.DiskPath",
directory.getAbsolutePath());
}
}
1.1
cocoon-2.1/src/java/org/apache/cocoon/components/store/JCSTransientStore.java
Index: JCSTransientStore.java
===================================================================
/*
* Copyright 2004,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cocoon.components.store;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
/**
* This is the transient store implementation based on JCS
* http://jakarta.apache.org/turbine/jcs/BasicJCSConfiguration.html
*
* @version CVS $Id: JCSTransientStore.java,v 1.1 2004/05/17 07:53:41
cziegeler Exp $
*/
public class JCSTransientStore
extends AbstractJCSStore {
/** The location of the JCS default properties file */
private static final String DEFAULT_PROPERTIES =
"org/apache/cocoon/components/store/transient.ccf";
/* (non-Javadoc)
* @see
org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
*/
public void parameterize(Parameters parameters) throws ParameterException
{
super.parameterize(parameters);
int maxobjects = parameters.getParameterAsInteger("maxobjects", -1);
if (maxobjects != -1) {
String key = "jcs.region." + region +
".cacheattributes.MaxObjects";
this.properties.setProperty(key, String.valueOf(maxobjects));
}
}
protected String getDefaultPropertiesFile() {
return DEFAULT_PROPERTIES;
}
}
1.214 +2 -2 cocoon-2.1/lib/jars.xml
Index: jars.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/lib/jars.xml,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -r1.213 -r1.214
--- jars.xml 8 May 2004 12:39:21 -0000 1.213
+++ jars.xml 17 May 2004 07:53:41 -0000 1.214
@@ -548,7 +548,7 @@
<title>JCS</title>
<description>Java Caching System</description>
<used-by>JCS Store</used-by>
- <lib>scratchpad/lib/jcs-1.0-dev-20040303.jar</lib>
+ <lib>core/jcs-1.0-dev-20040303.jar</lib>
<homepage>http://jakarta.apache.org/turbine/jcs</homepage>
</file>
1.43 +12 -12 cocoon-2.1/src/webapp/WEB-INF/cocoon.xconf
Index: cocoon.xconf
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/webapp/WEB-INF/cocoon.xconf,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- cocoon.xconf 6 May 2004 15:30:50 -0000 1.42
+++ cocoon.xconf 17 May 2004 07:53:42 -0000 1.43
@@ -422,8 +422,9 @@
| When the number of maxobjects has been reached. The last object
| in the cache will be thrown out.
+-->
- <transient-store logger="core.store.transient">
- <parameter name="maxobjects" value="100"/>
+ <transient-store
class="org.apache.cocoon.components.store.JCSTransientStore"
+ logger="core.store.transient">
+ <parameter name="maxobjects" value="1000"/>
</transient-store>
<!--+
@@ -437,14 +438,16 @@
| When the number of maxobjects has been reached. The last object
| in the cache will be thrown out.
+-->
- <store logger="core.store">
- <parameter name="maxobjects" value="100"/>
+ <store class="org.apache.cocoon.components.store.JCSDefaultStore"
+ logger="core.store">
+ <parameter name="maxobjects" value="1000"/>
+ <parameter name="use-cache-directory" value="true"/>
</store>
<!--+
| Persistent Store: holds objects that have to survive shutdown.
- | WARNING: FilesystemStore is broken. Cocoon uses
DefaultPersistentStore based
- | on the Avalon Excalibur JispStore instead.
+ | WARNING: FilesystemStore and JispStore are broken. Cocoon uses
+ | JCSPersistentStore based on Jakarta JCS instead.
|
| Common configuration parameters:
| use-cache-directory: Indicates that cache directory specified in
@@ -454,14 +457,11 @@
| directory: Specifies directory to use. Absolute or relative to the
| work directory.
|
- | DefaultStore configuration parameters:
- | datafile: Name of the store file to use. Defaults to cocoon.dat
- | indexfile: Name of the index file to use. Defaults to cocoon.idx
- | order: The page size of the B-Tree index, as an integer
(default=301).
+-->
- <persistent-store logger="core.store.persistent">
+ <persistent-store
class="org.apache.cocoon.components.store.JCSPersistentStore"
+ logger="core.store.persistent">
<parameter name="use-cache-directory" value="true"/>
- <parameter name="order" value="2701"/>
+ <parameter name="maxobjects" value="1000"/>
</persistent-store>
<!--+