You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/03/04 09:01:56 UTC
cvs commit: cocoon-2.1/src/blocks/scratchpad/java jcs-store.txt
cziegeler 2004/03/04 00:01:56
Modified: src/blocks/scratchpad/java/org/apache/cocoon/components/store
AbstractJCSStore.java JCSPersistentStore.java
Added: src/blocks/scratchpad/java jcs-store.txt
Log:
Adding readme for JCS and make config file optional
Revision Changes Path
1.3 +28 -23 cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/store/AbstractJCSStore.java
Index: AbstractJCSStore.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/store/AbstractJCSStore.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractJCSStore.java 3 Mar 2004 22:31:01 -0000 1.2
+++ AbstractJCSStore.java 4 Mar 2004 08:01:56 -0000 1.3
@@ -65,49 +65,54 @@
/**
* TODO - This store implementation should be moved to excalibur store
*
+ * The JCS Configuration file - for details see:
+ * http://jakarta.apache.org/turbine/jcs/BasicJCSConfiguration.html
+ *
* @author <a href="mailto:cmoss@tvnz.co.nz">Corin Moss</a>
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
*/
public abstract class AbstractJCSStore
extends AbstractReadWriteStore
implements Store, ThreadSafe {
- /**The JCS Configuration file - for details see:
- *http://jakarta.apache.org/turbine/jcs/BasicJCSConfiguration.html
- */
- protected File m_JCSConfigFile;
-
/** The Java Cache System object */
protected JCS m_JCS;
/**The Region as used by JCS*/
- protected String m_region;
+ private String m_region;
/**The group name as used by JCS getGroupKeys*/
- protected String m_group;
+ private String m_group;
- public void setup(final File configFile, final String regionName, final String groupName)
- throws IOException, CacheException {
+ public void setup(final File configFile,
+ final String regionName,
+ final String groupName)
+ throws IOException, CacheException {
- this.m_JCSConfigFile = configFile;
this.m_region = regionName;
this.m_group = groupName;
- getLogger().debug("CEM Loading config: '" + this.m_JCSConfigFile.getAbsolutePath() + "'");
- getLogger().debug("CEM Loading region: '" + this.m_region + "'");
- getLogger().debug("CEM Loading group: '" + this.m_group + "'");
-
- /* Does config exist? */
- // if (this.m_JCSConfigFile.exists())
- // {
- getLogger().debug("CEM Setting full path: " + this.m_JCSConfigFile.getAbsolutePath());
-
- JCS.setConfigFilename( this.m_JCSConfigFile.getAbsolutePath() );
- // } else {
- // throw new IOException( "Error reading JCS Config '" + this.m_JCSConfigFile.getAbsolutePath() + "'. File not found." );
- // }
+ if ( this.getLogger().isDebugEnabled() ) {
+ if ( configFile != null ) {
+ getLogger().debug("CEM Loading config: '" + configFile.getAbsolutePath() + "'");
+ }
+ getLogger().debug("CEM Loading region: '" + this.m_region + "'");
+ getLogger().debug("CEM Loading group: '" + this.m_group + "'");
+ }
+ if ( configFile != null ) {
+ /* Does config exist? */
+ // if (this.m_JCSConfigFile.exists())
+ // {
+ getLogger().debug("CEM Setting full path: " + configFile.getAbsolutePath());
+
+ JCS.setConfigFilename( configFile.getAbsolutePath() );
+ // } else {
+ // throw new IOException( "Error reading JCS Config '" + this.m_JCSConfigFile.getAbsolutePath() + "'. File not found." );
+ // }
+ }
try {
m_JCS = JCS.getInstance( m_region );
1.3 +14 -9 cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/store/JCSPersistentStore.java
Index: JCSPersistentStore.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/store/JCSPersistentStore.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JCSPersistentStore.java 3 Mar 2004 22:31:01 -0000 1.2
+++ JCSPersistentStore.java 4 Mar 2004 08:01:56 -0000 1.3
@@ -118,17 +118,22 @@
SourceResolver resolver = null;
Source source = null;
try {
- resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
- source = resolver.resolveURI(configFileName);
+ File configFile = null;
+
+ if ( configFileName != null ) {
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+ source = resolver.resolveURI(configFileName);
- // get the config file to use
- final File configFile = SourceUtil.getFile(source);
+ // get the config file to use
+ configFile = SourceUtil.getFile(source);
+
+ //if(!configFile.exists()){
+ // throw new ParameterException(
+ // "JCS Config file does not exist: " + configFileName
+ // );
+ //}
+ }
- //if(!configFile.exists()){
- // throw new ParameterException(
- // "JCS Config file does not exist: " + configFileName
- // );
- //}
try {
this.setup(configFile, regionName, groupName);
} catch (CacheException ce) {
1.1 cocoon-2.1/src/blocks/scratchpad/java/jcs-store.txt
Index: jcs-store.txt
===================================================================
README: Created by Corin Moss, <cm...@tvnz.co.nz>
--------------
The files contained within are an initial implementation of the JCS store as
an internal persistent store for Apache Cocoon. More documentation on this
can be found here: http://jakarta.apache.org/turbine/jcs/
The AbstractJCSStore class belongs with the Avalon-excalibur-store implementations,
to compile, A-E-Store needs to have the following in the dependency file:
<dependency>
<id>JCS</id>
<version>1.0</version>
</dependency>
<dependency>
<id>commons-lang</id>
<version>1.0.1</version>
</dependency>
<dependency>
<id>commons-collections</id>
<version>3.0</version>
</dependency>
You may need to compile, and make JCS available within the Maven repositories.
The JCSPersistentStore class implements Parameterizable, and has the following
xconf config:
<persistent-store logger="core.store.persistent">
<parameter name="region-name" value="indexedRegion1"/>
<parameter name="group-name" value="indexedDiskCache"/>
<parameter name="config-file" value="context://WEB-INF/TestDiskCache.ccf"/>
</persistent-store>
Where indexedRegion1 and indexedDiskCache are defined with the ccf file.
The TestDiskCache.ccf file must be in your classpath, play with
this as much as you like - you can use pretty much and of the stores
defined by JCS in this way.
You will need to alter your cocoon.roles file to use this store:
<role name="org.apache.excalibur.store.Store/PersistentStore"
shorthand="persistent-store"
default-class="org.apache.cocoon.components.store.impl.JCSPersistentStore"/>
Obviously the various JARS referenced above need to be available to cocoon both at
run and compile time :)
Good Luck!!