Author: tv
Date: Tue Jun  7 12:30:36 2016
New Revision: 1747206

URL: http://svn.apache.org/viewvc?rev=1747206&view=rev
Log:
Update to commons-jcs-2.0-beta1

Modified:
    turbine/fulcrum/trunk/cache/pom.xml
    
turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/impl/JCSCacheService.java
    turbine/fulcrum/trunk/cache/src/test/cache.ccf

Modified: turbine/fulcrum/trunk/cache/pom.xml
URL: 
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/cache/pom.xml?rev=1747206&r1=1747205&r2=1747206&view=diff
==============================================================================
--- turbine/fulcrum/trunk/cache/pom.xml (original)
+++ turbine/fulcrum/trunk/cache/pom.xml Tue Jun  7 12:30:36 2016
@@ -17,9 +17,9 @@
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
   <parent>
-    <groupId>org.apache.fulcrum</groupId>
-    <artifactId>fulcrum-parent</artifactId>
-    <version>2-SNAPSHOT</version>
+    <groupId>org.apache.turbine</groupId>
+    <artifactId>turbine-parent</artifactId>
+    <version>3</version>
   </parent>
 
   <modelVersion>4.0.0</modelVersion>
@@ -36,14 +36,6 @@
     <url>http://svn.apache.org/viewvc/turbine/fulcrum/trunk/cache/</url>
   </scm>
 
-  <distributionManagement>
-    <site>
-      <id>apache.website</id>
-      <name>Fulcrum Website</name>
-      
<url>${fulcrum.deployment.protocol}://people.apache.org/www/turbine.apache.org/fulcrum/fulcrum-cache/</url>
-    </site>    
-  </distributionManagement>
-       
   <developers>
     <developer>
       <name>Siegfried Goeschl</name>
@@ -78,15 +70,9 @@
       <optional>true</optional>
     </dependency>
     <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging</artifactId>
-      <version>1.1.1</version>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.jcs</groupId>
-      <artifactId>jcs</artifactId>
-      <version>1.3</version>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-jcs-core</artifactId>
+      <version>2.0-beta-1</version>
       <optional>true</optional>
     </dependency>
     <!-- testing dependencies -->
@@ -128,23 +114,39 @@
 
   <profiles>
     <profile>
-      <id>rc</id>
-      <distributionManagement>
-        <!-- Cannot define in parent ATM, see COMMONSSITE-26 -->
-        <site>
-          <id>apache.website</id>
-          <name>Apache Fulcrum Release Candidate Staging Site</name>
-          
<url>${fulcrum.deployment.protocol}://people.apache.org/www/turbine.apache.org/builds/fulcrum/${fulcrum.componentid}/${fulcrum.release.version}/${fulcrum.rc.version}/site</url>
-        </site>
-      </distributionManagement>
+      <id>apache-release</id>
+      <build>
+        <plugins>
+          <plugin>
+            <!-- build the source and binary distribution packages -->
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-assembly-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>fulcrum-source-release-assembly</id>
+                <phase>package</phase>
+                <goals>
+                  <goal>single</goal>
+                </goals>
+                <configuration>
+                  <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
+                  <descriptorRefs>
+                    <descriptorRef>bin</descriptorRef>
+                    <descriptorRef>project</descriptorRef>
+                    <descriptorRef>src</descriptorRef>
+                  </descriptorRefs>
+                  <tarLongFileFormat>gnu</tarLongFileFormat>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
     </profile>
   </profiles>
-  
+
   <properties>
-    <!-- This bits are used for the staging directory -->
-    <fulcrum.release.version>1.1.0</fulcrum.release.version>
-    <fulcrum.rc.version>RC1</fulcrum.rc.version>  
-    <fulcrum.deployment.protocol>scpexe</fulcrum.deployment.protocol>
-  </properties>    
+    <turbine.site.path>fulcrum/fulcrum-cache</turbine.site.path>
+  </properties>  
        
 </project>
\ No newline at end of file

Modified: 
turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/impl/JCSCacheService.java
URL: 
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/impl/JCSCacheService.java?rev=1747206&r1=1747205&r2=1747206&view=diff
==============================================================================
--- 
turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/impl/JCSCacheService.java
 (original)
+++ 
turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/impl/JCSCacheService.java
 Tue Jun  7 12:30:36 2016
@@ -24,7 +24,6 @@ import java.io.IOException;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -35,17 +34,19 @@ import org.apache.avalon.framework.confi
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.commons.jcs.JCS;
+import org.apache.commons.jcs.access.GroupCacheAccess;
+import org.apache.commons.jcs.access.exception.CacheException;
+import org.apache.commons.jcs.engine.ElementAttributes;
+import org.apache.commons.jcs.engine.control.CompositeCacheManager;
 import org.apache.fulcrum.cache.CachedObject;
 import org.apache.fulcrum.cache.GlobalCacheService;
 import org.apache.fulcrum.cache.ObjectExpiredException;
 import org.apache.fulcrum.cache.RefreshableCachedObject;
-import org.apache.jcs.JCS;
-import org.apache.jcs.access.exception.CacheException;
-import org.apache.jcs.engine.ElementAttributes;
 
 /**
  * Default implementation of JCSCacheService
- * 
+ *
  * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
  * @version $Id:$
  */
@@ -67,7 +68,7 @@ public class JCSCacheService extends Abs
     /**
      * Instance of the JCS cache
      */
-    private JCS cacheManager;
+    private GroupCacheAccess<String, CachedObject> cacheManager;
 
     /**
      * JCS region to use
@@ -95,7 +96,8 @@ public class JCSCacheService extends Abs
     /**
      * @see 
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
      */
-    public void configure(Configuration config) throws ConfigurationException
+    @Override
+       public void configure(Configuration config) throws 
ConfigurationException
     {
         this.cacheCheckFrequency = config.getChild("cacheCheckFrequency")
                 .getValueAsLong(DEFAULT_CACHE_CHECK_FREQUENCY);
@@ -107,10 +109,11 @@ public class JCSCacheService extends Abs
     /**
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
-    public void initialize() throws Exception
+    @Override
+       public void initialize() throws Exception
     {
         JCS.setConfigFilename(this.configFile);
-        this.cacheManager = JCS.getInstance(this.region);
+        this.cacheManager = JCS.getGroupCacheInstance(this.region);
 
         // Start housekeeping thread.
         this.continueThread = true;
@@ -130,13 +133,15 @@ public class JCSCacheService extends Abs
     /**
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
-    public void dispose()
+    @Override
+       public void dispose()
     {
         this.continueThread = false;
         this.refreshing.interrupt();
 
         this.cacheManager.dispose();
         this.cacheManager = null;
+        CompositeCacheManager.getInstance().shutDown();
 
         getLogger().debug("JCSCacheService stopped.");
     }
@@ -144,10 +149,10 @@ public class JCSCacheService extends Abs
     /**
      * @see 
org.apache.fulcrum.cache.GlobalCacheService#getObject(java.lang.String)
      */
-    public CachedObject getObject(String id) throws ObjectExpiredException
+    @Override
+       public CachedObject getObject(String id) throws ObjectExpiredException
     {
-        CachedObject obj = (CachedObject) this.cacheManager.getFromGroup(id,
-                group);
+        CachedObject obj = this.cacheManager.getFromGroup(id, group);
 
         if (obj == null)
         {
@@ -198,7 +203,8 @@ public class JCSCacheService extends Abs
      * @see 
org.apache.fulcrum.cache.GlobalCacheService#addObject(java.lang.String,
      *      org.apache.fulcrum.cache.CachedObject)
      */
-    public void addObject(String id, CachedObject o)
+    @Override
+       public void addObject(String id, CachedObject o)
     {
         try
         {
@@ -211,8 +217,7 @@ public class JCSCacheService extends Abs
                                         + "] is not serializable. Expect 
problems with auxiliary caches.");
             }
 
-            ElementAttributes attrib = (ElementAttributes) this.cacheManager
-                    .getDefaultElementAttributes();
+            ElementAttributes attrib = (ElementAttributes) 
this.cacheManager.getDefaultElementAttributes();
 
             if (o instanceof RefreshableCachedObject)
             {
@@ -221,7 +226,7 @@ public class JCSCacheService extends Abs
             else
             {
                 attrib.setIsEternal(false);
-                attrib.setMaxLifeSeconds((o.getExpires() + 500) / 1000);
+                attrib.setMaxLife(o.getExpires() + 500);
             }
 
             attrib.setLastAccessTimeNow();
@@ -238,17 +243,19 @@ public class JCSCacheService extends Abs
     /**
      * @see 
org.apache.fulcrum.cache.GlobalCacheService#removeObject(java.lang.String)
      */
-    public void removeObject(String id)
+    @Override
+       public void removeObject(String id)
     {
-        this.cacheManager.remove(id, group);
+        this.cacheManager.removeFromGroup(id, group);
     }
 
     /**
      * @see org.apache.fulcrum.cache.GlobalCacheService#getKeys()
      */
-    public List getKeys()
+    @Override
+       public List<String> getKeys()
     {
-        ArrayList keys = new ArrayList();
+        ArrayList<String> keys = new ArrayList<String>();
 
         keys.addAll(this.cacheManager.getGroupKeys(group));
         return keys;
@@ -257,14 +264,14 @@ public class JCSCacheService extends Abs
     /**
      * @see org.apache.fulcrum.cache.GlobalCacheService#getCachedObjects()
      */
-    public List getCachedObjects()
+    @Override
+       public List<CachedObject> getCachedObjects()
     {
-        ArrayList values = new ArrayList();
+        ArrayList<CachedObject> values = new ArrayList<CachedObject>();
 
-        for (Iterator i = this.cacheManager.getGroupKeys(group).iterator(); i
-                .hasNext();)
+        for (String key : this.cacheManager.getGroupKeys(group))
         {
-            Object o = this.cacheManager.getFromGroup(i.next(), group);
+            CachedObject o = this.cacheManager.getFromGroup(key, group);
             if (o != null)
             {
                 values.add(o);
@@ -278,7 +285,8 @@ public class JCSCacheService extends Abs
      * Circle through the cache and refresh stale objects. Frequency is
      * determined by the cacheCheckFrequency property.
      */
-    public void run()
+    @Override
+       public void run()
     {
         while (this.continueThread)
         {
@@ -296,11 +304,9 @@ public class JCSCacheService extends Abs
                 }
             }
 
-            for (Iterator i = 
this.cacheManager.getGroupKeys(group).iterator(); i
-                    .hasNext();)
+            for (String key : this.cacheManager.getGroupKeys(group))
             {
-                String key = (String) i.next();
-                Object o = this.cacheManager.getFromGroup(key, group);
+                CachedObject o = this.cacheManager.getFromGroup(key, group);
                 if (o == null)
                 {
                     removeObject(key);
@@ -312,7 +318,7 @@ public class JCSCacheService extends Abs
                         RefreshableCachedObject rco = 
(RefreshableCachedObject) o;
                         if (rco.isUntouched())
                         {
-                            this.cacheManager.remove(key, group);
+                            this.cacheManager.removeFromGroup(key, group);
                         }
                         else if (rco.isStale())
                         {
@@ -327,16 +333,17 @@ public class JCSCacheService extends Abs
     /**
      * @see org.apache.fulcrum.cache.GlobalCacheService#getCacheSize()
      */
-    public int getCacheSize() throws IOException
+    @Override
+       public int getCacheSize() throws IOException
     {
         // This is evil!
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream(baos);
-        Set keys = this.cacheManager.getGroupKeys(group);
+        Set<String> keys = this.cacheManager.getGroupKeys(group);
 
-        for (Iterator i = keys.iterator(); i.hasNext();)
+        for (String key : keys)
         {
-            out.writeObject(this.cacheManager.getFromGroup(i.next(), group));
+            out.writeObject(this.cacheManager.getFromGroup(key, group));
         }
 
         out.flush();
@@ -353,14 +360,14 @@ public class JCSCacheService extends Abs
     /**
      * @see org.apache.fulcrum.cache.GlobalCacheService#getNumberOfObjects()
      */
-    public int getNumberOfObjects()
+    @Override
+       public int getNumberOfObjects()
     {
         int count = 0;
 
-        for (Iterator i = this.cacheManager.getGroupKeys(group).iterator(); i
-                .hasNext();)
+        for (String key : this.cacheManager.getGroupKeys(group))
         {
-            if (this.cacheManager.getFromGroup(i.next(), group) != null)
+            if (this.cacheManager.getFromGroup(key, group) != null)
             {
                 count++;
             }
@@ -372,7 +379,8 @@ public class JCSCacheService extends Abs
     /**
      * @see org.apache.fulcrum.cache.GlobalCacheService#flushCache()
      */
-    public void flushCache()
+    @Override
+       public void flushCache()
     {
         this.cacheManager.invalidateGroup(group);
     }

Modified: turbine/fulcrum/trunk/cache/src/test/cache.ccf
URL: 
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/cache/src/test/cache.ccf?rev=1747206&r1=1747205&r2=1747206&view=diff
==============================================================================
--- turbine/fulcrum/trunk/cache/src/test/cache.ccf (original)
+++ turbine/fulcrum/trunk/cache/src/test/cache.ccf Tue Jun  7 12:30:36 2016
@@ -17,13 +17,13 @@
 # Java Caching System configuration
 
 jcs.default=
-jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
 jcs.default.cacheattributes.MaxObjects=100
-jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
-jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
+jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.commons.engine.memory.lru.LRUMemoryCache
+jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
 
 jcs.region.Cache_Test=
-jcs.region.Cache_Test.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.region.Cache_Test.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
 jcs.region.Cache_Test.cacheattributes.MaxObjects=100
-jcs.region.Cache_Test.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
-jcs.region.Cache_Test.elementattributes=org.apache.jcs.engine.ElementAttributes
+jcs.region.Cache_Test.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.region.Cache_Test.elementattributes=org.apache.commons.jcs.engine.ElementAttributes


Reply via email to