You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by un...@apache.org on 2004/03/04 23:56:22 UTC

cvs commit: cocoon-2.1/src/blocks/scratchpad/WEB-INF/classes TestDiskCache.ccf

unico       2004/03/04 14:56:22

  Modified:    src/blocks/scratchpad/java/org/apache/cocoon/components/store
                        AbstractJCSStore.java JCSPersistentStore.java
  Added:       src/blocks/scratchpad/WEB-INF/classes TestDiskCache.ccf
  Removed:     src/blocks/scratchpad/WEB-INF TestDiskCache.ccf
  Log:
  at least make it run
  - config file needs to be on the classpath 
  - cannot nullify cache in dispose
  
  Revision  Changes    Path
  1.4       +7 -22     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractJCSStore.java	4 Mar 2004 08:01:56 -0000	1.3
  +++ AbstractJCSStore.java	4 Mar 2004 22:56:22 -0000	1.4
  @@ -50,17 +50,15 @@
   */
   package org.apache.cocoon.components.store;
   
  -import java.io.File;
   import java.io.IOException;
   import java.io.Serializable;
   import java.util.Enumeration;
   
  -import org.apache.jcs.JCS;
  -import org.apache.jcs.access.exception.CacheException;
  -
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.excalibur.store.Store;
   import org.apache.excalibur.store.impl.AbstractReadWriteStore;
  +import org.apache.jcs.JCS;
  +import org.apache.jcs.access.exception.CacheException;
   
   /**
    * TODO - This store implementation should be moved to excalibur store
  @@ -84,9 +82,8 @@
       /**The group name as used by JCS getGroupKeys*/
       private String m_group;
       
  -
        
  -    public void setup(final File configFile, 
  +    public void setup(final String configFile, 
                         final String regionName, 
                         final String groupName) 
       throws IOException, CacheException {
  @@ -95,28 +92,18 @@
           this.m_group = groupName;
           
           if ( this.getLogger().isDebugEnabled() ) {
  -            if ( configFile != null ) {
  -                getLogger().debug("CEM Loading config: '" + configFile.getAbsolutePath() + "'");
  -            }
  +            getLogger().debug("CEM Loading config: '" + configFile + "'");
               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." );
  -           // }
  -        }
  +        JCS.setConfigFilename( configFile );
   
           try {
              m_JCS = JCS.getInstance( m_region );
  +           System.out.println("m_JCS" + m_JCS);
           } catch (CacheException ce) { 
  +            ce.printStackTrace();
               throw new CacheException( "Error initialising JCS with region: " + this.m_region );
           }
            
  @@ -296,7 +283,5 @@
           //so, I'll be bad
           return 0;
       }
  -    
  -    
       
   }
  
  
  
  1.4       +11 -41    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JCSPersistentStore.java	4 Mar 2004 08:01:56 -0000	1.3
  +++ JCSPersistentStore.java	4 Mar 2004 22:56:22 -0000	1.4
  @@ -51,7 +51,9 @@
   package org.apache.cocoon.components.store;
   
   import java.io.File;
  +import java.io.FileInputStream;
   import java.io.IOException;
  +import java.util.Properties;
   
   import org.apache.jcs.access.exception.CacheException;
   
  @@ -88,9 +90,6 @@
       protected ServiceManager manager;
       
       
  -    /* (non-Javadoc)
  -     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
  -     */
       public void service(ServiceManager manager) throws ServiceException {
           this.manager = manager;
       }
  @@ -111,45 +110,16 @@
        */
       public void parameterize(Parameters params) throws ParameterException {
           // TODO - These are only values for testing:
  -        final String configFileName = params.getParameter("config-file", "context://WEB-INF/TestDiskCache.ccf");     
  -        final String regionName = params.getParameter("region-name", "indexedRegion1");        
  -        final String groupName = params.getParameter("group-name", "indexedDiskCache");        
  -        
  -        SourceResolver resolver = null;
  -        Source source = null;
  -        try {
  -            File configFile = null;
  +        final String configFile = params.getParameter("config-file", "/TestDiskCache.ccf");
  +        final String regionName = params.getParameter("region-name", "indexedRegion1");
  +        final String groupName = params.getParameter("group-name", "indexedDiskCache");
   
  -            if ( configFileName != null ) {
  -                resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
  -                source = resolver.resolveURI(configFileName);
  -            
  -                // get the config file to use
  -                configFile = SourceUtil.getFile(source);
  -            
  -                //if(!configFile.exists()){
  -                //   throw new ParameterException(
  -                //      "JCS Config file does not exist: " + configFileName
  -                //   );
  -                //}
  -            }
  -            
  -            try {
  -               this.setup(configFile, regionName, groupName);
  -            } catch (CacheException ce) {
  -               throw new ParameterException(
  -                  "JCS unable to run setup with region: " + regionName
  -               );
  -            }
  -        } catch (ServiceException se) {
  -            throw new ParameterException("Unable to get source resolver.", se);
  +        try {
  +            this.setup(configFile, regionName, groupName);
  +        } catch (CacheException ce) {
  +           throw new ParameterException("JCS unable to run setup with region: " + regionName);
           } catch (IOException ioe) {
  -            throw new ParameterException("Unable to get handle on JCS Config file: " + configFileName , ioe);
  -        } finally {
  -            if ( resolver != null ) {
  -                resolver.release(source);
  -                this.manager.release(resolver);
  -            }
  +            throw new ParameterException("Unable to get handle on JCS Config file: " + configFile , ioe);
           }
   
       }
  @@ -161,7 +131,7 @@
   
               if (super.m_JCS != null) {
                   
  -                super.m_JCS = null;
  +                //super.m_JCS = null;
                   //protected - what is the best way to do this?
                   //super.m_JCS.dispose();
               }
  
  
  
  1.1                  cocoon-2.1/src/blocks/scratchpad/WEB-INF/classes/TestDiskCache.ccf
  
  Index: TestDiskCache.ccf
  ===================================================================
  # Cache configuration for the 'TestDiskCache' test. The memory cache has a
  # a maximum of 100 objects, so objects should get pushed into the disk cache
  
  jcs.default=indexedDiskCache
  jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  jcs.default.cacheattributes.MaxObjects=10
  jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
  
  # SYSTEM GROUP ID CACHE
  jcs.system.groupIdCache=indexedDiskCache
  jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  jcs.system.groupIdCache.cacheattributes.MaxObjects=10
  jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
  
  
  ##### CACHE REGIONS FOR TEST
  
  jcs.region.indexedRegion1=indexedDiskCache
  jcs.region.indexedRegion1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  jcs.region.indexedRegion1.cacheattributes.MaxObjects=1000
  jcs.region.indexedRegion1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
  
  jcs.region.indexedRegion2=indexedDiskCache
  jcs.region.indexedRegion2.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  jcs.region.indexedRegion2.cacheattributes.MaxObjects=100
  jcs.region.indexedRegion2.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
  
  jcs.region.indexedRegion3=indexedDiskCache
  jcs.region.indexedRegion3.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  jcs.region.indexedRegion3.cacheattributes.MaxObjects=100
  jcs.region.indexedRegion3.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
  
  jcs.region.indexedRegion4=indexedDiskCache2
  jcs.region.indexedRegion4.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
  jcs.region.indexedRegion4.cacheattributes.MaxObjects=100
  jcs.region.indexedRegion4.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
  
  
  ##### AUXILIARY CACHES
  
  # Indexed Disk Cache
  jcs.auxiliary.indexedDiskCache=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
  jcs.auxiliary.indexedDiskCache.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
  jcs.auxiliary.indexedDiskCache.attributes.DiskPath=/www/cocoon/webapps/cocoon/indexed-disk-cache
  
  # Indexed Disk Cache
  jcs.auxiliary.indexedDiskCache2=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
  jcs.auxiliary.indexedDiskCache2.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
  jcs.auxiliary.indexedDiskCache2.attributes.DiskPath=target/test-sandbox/indexed-disk-cache2