You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2011/07/27 20:08:57 UTC
svn commit: r1151575 [1/6] - in /commons/proper/jcs/trunk: ./
src/experimental/org/apache/jcs/engine/memory/arc/
src/java/org/apache/jcs/access/ src/java/org/apache/jcs/access/behavior/
src/java/org/apache/jcs/admin/ src/java/org/apache/jcs/auxiliary/ ...
Author: tv
Date: Wed Jul 27 18:08:23 2011
New Revision: 1151575
URL: http://svn.apache.org/viewvc?rev=1151575&view=rev
Log:
This is a large commit.
- Switched to Maven2 as the main build system
- Switched to JDK 5 generics and
- Replaced Doug Leas concurrent package with JDK5-concurrent
For me, 4 tests still fail. Still under investigation.
Removed:
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPool.java
Modified:
commons/proper/jcs/trunk/pom.xml
commons/proper/jcs/trunk/src/experimental/org/apache/jcs/engine/memory/arc/ARCMemoryCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/access/CacheAccess.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/access/GroupCacheAccess.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/access/PartitionedCacheAccess.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/IGroupCacheAccess.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/admin/JCSAdminBean.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskCacheManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/block/BlockDiskKeyStore.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/file/FileDiskCacheManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskElementDescriptor.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManagerAbstractTemplate.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/ShrinkerThread.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheAbstractManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWait.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/behavior/ILateralCacheManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/AbsractRemoteCacheListener.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheFactory.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheMonitor.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheClient.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteHttpCacheService.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheRequest.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheResponse.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueue.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/CacheListeners.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/CacheWatchRepairable.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/ElementAttributes.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/PooledCacheEventQueue.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheService.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/ZombieCacheServiceNonLocal.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheElement.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheService.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheServiceNonLocal.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/behavior/IElementAttributes.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/control/event/ElementEventQueue.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/KeyMatcherPatternImpl.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/match/behavior/IKeyMatcher.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractDoulbeLinkedListMemoryCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/AbstractMemoryCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/behavior/IMemoryCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/lru/LHMLRUMemoryCache.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/shrinking/ShrinkerThread.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/engine/memory/util/MemoryElementDescriptor.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/access/JCSWorker.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/config/IUtilConstants.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/config/OptionConverter.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/config/PropertySetter.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/discovery/DiscoveredService.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPCleanupRunner.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoveryManager.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoveryMessage.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoveryReceiver.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoverySender.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoverySenderThread.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/discovery/UDPDiscoveryService.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/net/HostNameUtil.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/struct/BoundedQueue.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/struct/DoubleLinkedList.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/struct/DoubleLinkedListNode.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUElementDescriptor.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMapEntry.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/struct/SingleLinkedList.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/struct/SortedPreferentialArray.java
commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/access/TestCacheAccess.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/file/FileDiskCacheUnitTest.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCacheConcurrentNoDeadLockUnitTest.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheClient.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/memory/MockMemoryCache.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/threadpool/ThreadPoolManagerUnitTest.java
commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/threadpool/ThreadPoolUnitTest.java
Modified: commons/proper/jcs/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/pom.xml?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/pom.xml (original)
+++ commons/proper/jcs/trunk/pom.xml Wed Jul 27 18:08:23 2011
@@ -16,14 +16,6 @@
limitations under the License.
-->
-
-<!--
-Note: While this pom includes many of the elements required in order to build
-the project, maven 1 is the only supported build system for jcs.
-
-This pom is provided to make it easier for projects built with maven 2 to use
-jcs.
--->
<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">
@@ -31,12 +23,12 @@ jcs.
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
- <version>3</version>
+ <version>9</version>
</parent>
<groupId>org.apache.jcs</groupId>
<artifactId>jcs</artifactId>
- <packaging>pom</packaging>
- <version>1.3.3.5-RC</version>
+ <packaging>jar</packaging>
+ <version>1.4-SNAPSHOT</version>
<name>Jakarta JCS</name>
<url>http://jakarta.apache.org/jcs/</url>
<inceptionYear>2002</inceptionYear>
@@ -64,7 +56,7 @@ jcs.
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <version>1.1</version>
+ <version>1.1.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
@@ -73,7 +65,7 @@ jcs.
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
- <version>2.1</version>
+ <version>2.3</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
@@ -93,26 +85,18 @@ jcs.
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
- <version>1.3</version>
+ <version>1.4</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- REQUIRED FOR JCS CORE -->
- <dependency>
- <groupId>concurrent</groupId>
- <artifactId>concurrent</artifactId>
- <!-- Using old release for now while JDK 1.3 is supported. -->
- <version>1.0</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
- <version>3.0.10</version>
+ <version>5.0.4</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
@@ -137,14 +121,6 @@ jcs.
<optional>true</optional>
</dependency>
- <dependency>
- <groupId>servletapi</groupId>
- <artifactId>servletapi</artifactId>
- <version>2.3</version>
- <type>jar</type>
- <scope>compile</scope>
- <optional>true</optional>
- </dependency>
<!-- LGPL! -->
<!--
@@ -220,6 +196,23 @@ jcs.
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.3</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
</dependencies>
<!-- We don't use Continuum yet -->
@@ -331,23 +324,21 @@ jcs.
</contributors>
<build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
- <version>1.0-alpha-1</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.1</version>
- </plugin>
- </plugins>
- </pluginManagement>
+ <sourceDirectory>src/java</sourceDirectory>
+ <testSourceDirectory>src/test</testSourceDirectory>
+ <testResources>
+ <testResource>
+ <directory>src/test-conf</directory>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.ccf</include>
+ </includes>
+ </testResource>
+ </testResources>
<plugins>
<!-- TODO: later use toolchain support to do compilation on an external JDK 1.3+ compiler -->
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compile.source}</source>
@@ -355,6 +346,34 @@ jcs.
</configuration>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Xmx256m</argLine>
+ <forkMode>pertest</forkMode>
+ <includes>
+ <include>**/*UnitTest.java</include>
+ </includes>
+ <excludes>
+ <!--
+ Several of the test cases rely on background tasks that are timing
+ sensitive.
+ -->
+ <!-- You need to manually run these test cases. -->
+ <exclude>**/BlockDiskElementDescriptorUnitTest.java</exclude>
+ <exclude>**/HSQLDiskCacheConcurrentUnitTest.java</exclude>
+ <exclude>**/HSQLDiskCacheUnitTest.java</exclude>
+ <exclude>**/IndexedDiskCacheOptimizationUnitTest.java</exclude>
+ <exclude>**/TestTCPLateralUnitTest.java</exclude>
+ <exclude>**/UDPDiscoveryUnitTest.java</exclude>
+ <!-- The ones that fail may be different for you. -->
+ <!-- <exclude>**/JDBCDiskCacheRemovalUnitTest.java</exclude> -->
+ <!-- <exclude>**/JDBCDiskCacheUnitTest.java</exclude> -->
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
@@ -372,6 +391,26 @@ jcs.
</archive>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rmic-maven-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>rmic-process-classes</id>
+ <goals>
+ <goal>rmic</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+ <includes>
+ <include>org.apache.jcs.auxiliary.remote.RemoteCacheListener</include>
+ <include>org.apache.jcs.auxiliary.remote.server.RemoteCacheServer</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
@@ -433,6 +472,7 @@ jcs.
<plugins>
<!-- We want to sign the artifact, the POM, and all attached artifacts -->
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<configuration>
<passphrase>${gpg.passphrase}</passphrase>
@@ -448,6 +488,7 @@ jcs.
</executions>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
@@ -459,6 +500,7 @@ jcs.
</executions>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
@@ -540,10 +582,10 @@ jcs.
<properties>
<!-- Default configuration for compiler source and target JVM -->
- <maven.compile.source>1.4</maven.compile.source>
- <maven.compile.target>1.4</maven.compile.target>
+ <maven.compile.source>1.5</maven.compile.source>
+ <maven.compile.target>1.5</maven.compile.target>
- <!--
+ <!--
Make the deployment protocol pluggable. This allows to switch to
other protocols like scpexe, which some users prefer over scp.
-->
Modified: commons/proper/jcs/trunk/src/experimental/org/apache/jcs/engine/memory/arc/ARCMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/experimental/org/apache/jcs/engine/memory/arc/ARCMemoryCache.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/experimental/org/apache/jcs/engine/memory/arc/ARCMemoryCache.java (original)
+++ commons/proper/jcs/trunk/src/experimental/org/apache/jcs/engine/memory/arc/ARCMemoryCache.java Wed Jul 27 18:08:23 2011
@@ -36,8 +36,6 @@ import org.apache.jcs.engine.stats.behav
import org.apache.jcs.engine.stats.behavior.IStats;
import org.apache.jcs.utils.struct.DoubleLinkedList;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-
/**
* This is a rough implmentation of an adaptive replacement cache. ARC is a
* hybrid LFU / LRU that adapts to user behavior.
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/access/CacheAccess.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/access/CacheAccess.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/access/CacheAccess.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/access/CacheAccess.java Wed Jul 27 18:08:23 2011
@@ -22,7 +22,6 @@ package org.apache.jcs.access;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -53,7 +52,7 @@ import org.apache.jcs.engine.stats.behav
* The JCS class is the preferred way to access these methods.
*/
public class CacheAccess
- implements ICacheAccess
+ implements ICacheAccess<Serializable, Serializable>
{
/** The logger. */
private static final Log log = LogFactory.getLog( CacheAccess.class );
@@ -187,41 +186,38 @@ public class CacheAccess
* @param name Key the object is stored as
* @return The object if found or null
*/
- public Object get( Object name )
+ public Serializable get( Serializable name )
{
- ICacheElement element = this.cacheControl.get( (Serializable) name );
+ ICacheElement element = this.cacheControl.get( name );
return ( element != null ) ? element.getVal() : null;
}
-
+
/**
* Retrieve matching objects from the cache region this instance provides access to.
* <p>
* @param pattern - a key pattern for the objects stored
* @return A map of key to values. These are stripped from the wrapper.
*/
- public Map getMatching( String pattern )
+ public Map<Serializable, Serializable> getMatching( String pattern )
{
- HashMap unwrappedResults = new HashMap();
-
- Map wrappedResults = this.cacheControl.getMatching( pattern );
+ HashMap<Serializable, Serializable> unwrappedResults = new HashMap<Serializable, Serializable>();
+
+ Map<Serializable, ICacheElement> wrappedResults = this.cacheControl.getMatching( pattern );
if ( wrappedResults != null )
{
- Set keySet = wrappedResults.keySet();
- Iterator it = keySet.iterator();
- while ( it.hasNext() )
+ for (Map.Entry<Serializable, ICacheElement> entry : wrappedResults.entrySet())
{
- Object key = it.next();
- ICacheElement element = (ICacheElement)wrappedResults.get( key );
+ ICacheElement element = wrappedResults.get( entry.getKey() );
if ( element != null )
{
- unwrappedResults.put( key, element.getVal() );
+ unwrappedResults.put( entry.getKey(), element.getVal() );
}
- }
+ }
}
return unwrappedResults;
}
-
+
/**
* This method returns the ICacheElement wrapper which provides access to element info and other
* attributes.
@@ -234,12 +230,12 @@ public class CacheAccess
* <p>
* The last access time in the ElementAttributes should be current.
* <p>
- * @param name Key the object is stored as
+ * @param name Key the Serializable is stored as
* @return The ICacheElement if the object is found or null
*/
- public ICacheElement getCacheElement( Object name )
+ public ICacheElement getCacheElement( Serializable name )
{
- return this.cacheControl.get( (Serializable) name );
+ return this.cacheControl.get( name );
}
/**
@@ -256,10 +252,10 @@ public class CacheAccess
* <p>
* The last access time in the ElementAttributes should be current.
* <p>
- * @param names set of Object cache keys
- * @return a map of Object key to ICacheElement element, or empty map if none of the keys are present
+ * @param names set of Serializable cache keys
+ * @return a map of Serializable key to ICacheElement element, or empty map if none of the keys are present
*/
- public Map getCacheElements( Set names )
+ public Map<Serializable, ICacheElement> getCacheElements( Set<Serializable> names )
{
return this.cacheControl.getMultiple( names );
}
@@ -279,13 +275,13 @@ public class CacheAccess
* The last access time in the ElementAttributes should be current.
* <p>
* @param pattern key search pattern
- * @return a map of Object key to ICacheElement element, or empty map if no keys match the pattern
+ * @return a map of Serializable key to ICacheElement element, or empty map if no keys match the pattern
*/
- public Map getMatchingCacheElements( String pattern )
+ public Map<Serializable, ICacheElement> getMatchingCacheElements( String pattern )
{
return this.cacheControl.getMatching( pattern );
}
-
+
/**
* Place a new object in the cache, associated with key name. If there is currently an object
* associated with name in the region an ObjectExistsException is thrown. Names are scoped to a
@@ -296,10 +292,10 @@ public class CacheAccess
* @exception CacheException and ObjectExistsException is thrown if the item is already in the
* cache.
*/
- public void putSafe( Object key, Object value )
+ public void putSafe( Serializable key, Serializable value )
throws CacheException
{
- if ( this.cacheControl.get( (Serializable) key ) != null )
+ if ( this.cacheControl.get( key ) != null )
{
throw new ObjectExistsException( "putSafe failed. Object exists in the cache for key [" + key
+ "]. Remove first or use a non-safe put to override the value." );
@@ -315,7 +311,7 @@ public class CacheAccess
* @param obj Object to store
* @exception CacheException
*/
- public void put( Object name, Object obj )
+ public void put( Serializable name, Serializable obj )
throws CacheException
{
// Call put with a copy of the contained caches default attributes.
@@ -331,7 +327,7 @@ public class CacheAccess
* @see org.apache.jcs.access.behavior.ICacheAccess#put(java.lang.Object, java.lang.Object,
* org.apache.jcs.engine.behavior.IElementAttributes)
*/
- public void put( Object key, Object val, IElementAttributes attr )
+ public void put( Serializable key, Serializable val, IElementAttributes attr )
throws CacheException
{
if ( key == null )
@@ -347,8 +343,8 @@ public class CacheAccess
// should be wrapped by cache access.
try
{
- CacheElement ce = new CacheElement( this.cacheControl.getCacheName(), (Serializable) key,
- (Serializable) val );
+ CacheElement ce = new CacheElement( this.cacheControl.getCacheName(), key,
+ val );
ce.setElementAttributes( attr );
@@ -367,6 +363,7 @@ public class CacheAccess
* @exception CacheException
* @deprecated
*/
+ @Deprecated
public void destroy()
throws CacheException
{
@@ -386,6 +383,7 @@ public class CacheAccess
* @deprecated use clear()
* @throws CacheException
*/
+ @Deprecated
public void remove()
throws CacheException
{
@@ -418,10 +416,11 @@ public class CacheAccess
* @exception CacheException
* @deprecated use remove
*/
- public void destroy( Object name )
+ @Deprecated
+ public void destroy( Serializable name )
throws CacheException
{
- this.cacheControl.remove( (Serializable) name );
+ this.cacheControl.remove( name );
}
/**
@@ -430,10 +429,10 @@ public class CacheAccess
* @param name the name of the item to remove.
* @throws CacheException
*/
- public void remove( Object name )
+ public void remove( Serializable name )
throws CacheException
{
- this.cacheControl.remove( (Serializable) name );
+ this.cacheControl.remove( name );
}
/**
@@ -456,6 +455,7 @@ public class CacheAccess
* @exception CacheException
* @exception InvalidHandleException
*/
+ @Deprecated
public void resetElementAttributes( IElementAttributes attr )
throws CacheException, InvalidHandleException
{
@@ -487,10 +487,10 @@ public class CacheAccess
* @exception CacheException
* @exception InvalidHandleException if the item does not exist.
*/
- public void resetElementAttributes( Object name, IElementAttributes attr )
+ public void resetElementAttributes( Serializable name, IElementAttributes attr )
throws CacheException, InvalidHandleException
{
- ICacheElement element = this.cacheControl.get( (Serializable) name );
+ ICacheElement element = this.cacheControl.get( name );
if ( element == null )
{
@@ -516,6 +516,7 @@ public class CacheAccess
* @return Attributes for this region
* @exception CacheException
*/
+ @Deprecated
public IElementAttributes getElementAttributes()
throws CacheException
{
@@ -547,14 +548,14 @@ public class CacheAccess
* @return Attributes for the object, null if object not in cache
* @exception CacheException
*/
- public IElementAttributes getElementAttributes( Object name )
+ public IElementAttributes getElementAttributes( Serializable name )
throws CacheException
{
IElementAttributes attr = null;
try
{
- attr = this.cacheControl.getElementAttributes( (Serializable) name );
+ attr = this.cacheControl.getElementAttributes( name );
}
catch ( IOException ioe )
{
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/access/GroupCacheAccess.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/access/GroupCacheAccess.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/access/GroupCacheAccess.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/access/GroupCacheAccess.java Wed Jul 27 18:08:23 2011
@@ -19,6 +19,7 @@ package org.apache.jcs.access;
* under the License.
*/
+import java.io.Serializable;
import java.util.Set;
import org.apache.jcs.access.behavior.IGroupCacheAccess;
@@ -36,7 +37,7 @@ import org.apache.jcs.engine.control.gro
*/
public class GroupCacheAccess
extends CacheAccess
- implements IGroupCacheAccess
+ implements IGroupCacheAccess<Serializable, Serializable>
{
/** The underlying cache manager. */
private static CompositeCacheManager cacheMgr;
@@ -102,7 +103,7 @@ public class GroupCacheAccess
* The group name.
* @return The cached value, null if not found.
*/
- public Object getFromGroup( Object name, String group )
+ public Serializable getFromGroup( Serializable name, String group )
{
ICacheElement element = this.cacheControl.get( getGroupAttrName( group, name ) );
return ( element != null ) ? element.getVal() : null;
@@ -115,7 +116,7 @@ public class GroupCacheAccess
* @param name
* @return GroupAttrName
*/
- private GroupAttrName getGroupAttrName( String group, Object name )
+ private GroupAttrName getGroupAttrName( String group, Serializable name )
{
GroupId gid = new GroupId( this.cacheControl.getCacheName(), group );
return new GroupAttrName( gid, name );
@@ -134,7 +135,7 @@ public class GroupCacheAccess
* The object to cache
* @throws CacheException
*/
- public void putInGroup( Object name, String groupName, Object value )
+ public void putInGroup( Serializable name, String groupName, Serializable value )
throws CacheException
{
putInGroup( name, groupName, value, null );
@@ -155,7 +156,7 @@ public class GroupCacheAccess
* The objects attributes.
* @throws CacheException
*/
- public void putInGroup( Object name, String groupName, Object value, IElementAttributes attr )
+ public void putInGroup( Serializable name, String groupName, Serializable value, IElementAttributes attr )
throws CacheException
{
// unbind object first if any.
@@ -175,7 +176,7 @@ public class GroupCacheAccess
* @param name
* @param group
*/
- public void remove( Object name, String group )
+ public void remove( Serializable name, String group )
{
GroupAttrName key = getGroupAttrName( group, name );
this.cacheControl.remove( key );
@@ -187,7 +188,7 @@ public class GroupCacheAccess
* @param group
* @return A Set of keys.
*/
- public Set getGroupKeys( String group )
+ public Set<Serializable> getGroupKeys( String group )
{
return this.cacheControl.getGroupKeys( group );
}
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/access/PartitionedCacheAccess.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/access/PartitionedCacheAccess.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/access/PartitionedCacheAccess.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/access/PartitionedCacheAccess.java Wed Jul 27 18:08:23 2011
@@ -22,13 +22,11 @@ package org.apache.jcs.access;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.jcs.JCS;
import org.apache.jcs.access.behavior.ICacheAccess;
import org.apache.jcs.access.exception.CacheException;
import org.apache.jcs.access.exception.ConfigurationException;
@@ -55,9 +53,9 @@ import org.apache.jcs.utils.props.Abstra
* <p>
* @author Aaron Smuts
*/
-public class PartitionedCacheAccess
+public class PartitionedCacheAccess<K, V>
extends AbstractPropertyContainer
- implements ICacheAccess
+ implements ICacheAccess<K, V>
{
/** the logger. */
private static final Log log = LogFactory.getLog( PartitionedCacheAccess.class );
@@ -72,7 +70,7 @@ public class PartitionedCacheAccess
private String partitionRegionNamePrefix;
/** An array of partitions built during initialization. */
- private ICacheAccess[] partitions;
+ private ICacheAccess<K, V>[] partitions;
/** Is the class initialized. */
private boolean initialized = false;
@@ -91,7 +89,7 @@ public class PartitionedCacheAccess
* @param object object
* @throws CacheException on configuration problem
*/
- public void put( Object key, Object object )
+ public void put( K key, V object )
throws CacheException
{
if ( key == null || object == null )
@@ -120,7 +118,7 @@ public class PartitionedCacheAccess
* @param object
* @throws CacheException
*/
- public void putSafe( Object key, Object object )
+ public void putSafe( K key, V object )
throws CacheException
{
if ( key == null || object == null )
@@ -141,7 +139,7 @@ public class PartitionedCacheAccess
* @param attr
* @throws CacheException on configuration problem
*/
- public void put( Object key, Object object, IElementAttributes attr )
+ public void put( K key, V object, IElementAttributes attr )
throws CacheException
{
if ( key == null || object == null )
@@ -169,7 +167,7 @@ public class PartitionedCacheAccess
* @param key key
* @return result, null if not found.
*/
- public Object get( Object key )
+ public V get( K key )
{
if ( key == null )
{
@@ -198,7 +196,7 @@ public class PartitionedCacheAccess
* @param key key
* @return result, null if not found.
*/
- public ICacheElement getCacheElement( Object key )
+ public ICacheElement getCacheElement( K key )
{
if ( key == null )
{
@@ -227,29 +225,27 @@ public class PartitionedCacheAccess
* @param names
* @return Map of keys to ICacheElement
*/
- public Map getCacheElements( Set names )
+ public Map<K, ICacheElement> getCacheElements( Set<K> names )
{
if ( names == null )
{
log.warn( "Bad input names cannot be null." );
- return Collections.EMPTY_MAP;
+ return Collections.emptyMap();
}
- Set[] dividedNames = new Set[this.getNumberOfPartitions()];
+ Set<K>[] dividedNames = new Set[this.getNumberOfPartitions()];
- Iterator it = names.iterator();
- while ( it.hasNext() )
+ for (K key : names)
{
- Object key = it.next();
int partition = getPartitionNumberForKey( key );
if ( dividedNames[partition] == null )
{
- dividedNames[partition] = new HashSet();
+ dividedNames[partition] = new HashSet<K>();
}
dividedNames[partition].add( key );
}
- Map result = new HashMap();
+ Map<K, ICacheElement> result = new HashMap<K, ICacheElement>();
for ( int i = 0; i < partitions.length; i++ )
{
if ( dividedNames[i] != null && !dividedNames[i].isEmpty() )
@@ -264,12 +260,12 @@ public class PartitionedCacheAccess
* This is tricky. Do we need to get from all the partitions?
* <p>
* If this interface took an object, we could use the hashcode to determine the partition. Then
- * we could user the toString for the pattern.
+ * we could use the toString for the pattern.
* <p>
* @param pattern
* @return HashMap key to value
*/
- public Map getMatching( String pattern )
+ public Map<K, V> getMatching( String pattern )
{
if ( pattern == null )
{
@@ -287,21 +283,21 @@ public class PartitionedCacheAccess
return null;
}
- Map result = new HashMap();
+ Map<K, V> result = new HashMap<K,V>();
for ( int i = 0; i < partitions.length; i++ )
{
result.putAll( partitions[i].getMatching( pattern ) );
}
return result;
}
-
+
/**
* This is tricky. Do we need to get from all the partitions?
* <p>
* @param pattern
* @return HashMap key to ICacheElement
*/
- public Map getMatchingCacheElements( String pattern )
+ public Map<K, ICacheElement> getMatchingCacheElements( String pattern )
{
if ( pattern == null )
{
@@ -319,7 +315,7 @@ public class PartitionedCacheAccess
return null;
}
- Map result = new HashMap();
+ Map<K, ICacheElement> result = new HashMap<K, ICacheElement>();
for ( int i = 0; i < partitions.length; i++ )
{
result.putAll( partitions[i].getMatchingCacheElements( pattern ) );
@@ -349,7 +345,7 @@ public class PartitionedCacheAccess
* @param key
* @throws CacheException
*/
- public void remove( Object key )
+ public void remove( K key )
throws CacheException
{
if ( key == null )
@@ -439,7 +435,7 @@ public class PartitionedCacheAccess
* @return IElementAttributes
* @throws CacheException
*/
- public IElementAttributes getElementAttributes( Object key )
+ public IElementAttributes getElementAttributes( K key )
throws CacheException
{
if ( key == null )
@@ -480,7 +476,7 @@ public class PartitionedCacheAccess
* @param attributes
* @throws CacheException
*/
- public void resetElementAttributes( Object key, IElementAttributes attributes )
+ public void resetElementAttributes( K key, IElementAttributes attributes )
throws CacheException
{
if ( key == null )
@@ -520,15 +516,15 @@ public class PartitionedCacheAccess
}
/**
- * This expects a numeric key. If the key cannot be converted into a number, we wil return 0.
+ * This expects a numeric key. If the key cannot be converted into a number, we will return 0.
* TODO we could md5 it or get the hashcode.
* <p>
- * We determine the partition by taking the mod of the number of partions.
+ * We determine the partition by taking the mod of the number of partitions.
* <p>
* @param key key
* @return the partition number.
*/
- protected int getPartitionNumberForKey( Object key )
+ protected int getPartitionNumberForKey( K key )
{
if ( key == null )
{
@@ -553,7 +549,7 @@ public class PartitionedCacheAccess
* @param key key
* @return long
*/
- public long getNumericValueForKey( Object key )
+ public long getNumericValueForKey( K key )
{
String keyString = key.toString();
long keyNum = -1;
@@ -565,7 +561,7 @@ public class PartitionedCacheAccess
{
// THIS IS UGLY, but I can't think of a better failsafe right now.
keyNum = key.hashCode();
- log.warn( "Counldn't convert [" + key + "] into a number. Will use hashcode [" + keyNum + "]" );
+ log.warn( "Couldn't convert [" + key + "] into a number. Will use hashcode [" + keyNum + "]" );
}
return keyNum;
}
@@ -585,7 +581,7 @@ public class PartitionedCacheAccess
}
/**
- * Use the partion prefix and the number of partions to get JCS regions.
+ * Use the partition prefix and the number of partitions to get JCS regions.
* <p>
* @throws ConfigurationException on configuration problem
*/
@@ -594,13 +590,13 @@ public class PartitionedCacheAccess
{
ensureProperties();
- ICacheAccess[] tempPartitions = new ICacheAccess[this.getNumberOfPartitions()];
+ ICacheAccess<K, V>[] tempPartitions = new ICacheAccess[this.getNumberOfPartitions()];
for ( int i = 0; i < this.getNumberOfPartitions(); i++ )
{
String regionName = this.getPartitionRegionNamePrefix() + "_" + i;
try
{
- tempPartitions[i] = CacheAccess.getAccess( regionName );
+ tempPartitions[i] = (ICacheAccess<K, V>) CacheAccess.getAccess( regionName );
}
catch ( CacheException e )
{
@@ -622,6 +618,7 @@ public class PartitionedCacheAccess
* </ul>
* @throws ConfigurationException on configuration problem
*/
+ @Override
protected void handleProperties()
throws ConfigurationException
{
@@ -722,7 +719,7 @@ public class PartitionedCacheAccess
/**
* @param partitions The partitions to set.
*/
- protected void setPartitions( JCS[] partitions )
+ protected void setPartitions( ICacheAccess<K, V>[] partitions )
{
this.partitions = partitions;
}
@@ -730,7 +727,7 @@ public class PartitionedCacheAccess
/**
* @return Returns the partitions.
*/
- protected ICacheAccess[] getPartitions()
+ protected ICacheAccess<K, V>[] getPartitions()
{
return partitions;
}
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/ICacheAccess.java Wed Jul 27 18:08:23 2011
@@ -30,7 +30,7 @@ import org.apache.jcs.engine.behavior.IE
/**
* ICacheAccess defines the behavior for client access.
*/
-public interface ICacheAccess
+public interface ICacheAccess<K, V>
{
/**
* Basic get method.
@@ -38,7 +38,7 @@ public interface ICacheAccess
* @param name
* @return Object or null if not found.
*/
- Object get( Object name );
+ V get( K name );
/**
* Retrieve matching objects from the cache region this instance provides access to.
@@ -46,7 +46,7 @@ public interface ICacheAccess
* @param pattern - a key pattern for the objects stored
* @return A map of key to values. These are stripped from the wrapper.
*/
- Map getMatching( String pattern );
+ Map<K, V> getMatching( String pattern );
/**
* Puts in cache if an item does not exist with the name in that region.
@@ -55,17 +55,17 @@ public interface ICacheAccess
* @param obj
* @throws CacheException
*/
- void putSafe( Object name, Object obj )
+ void putSafe( K name, V obj )
throws CacheException;
/**
- * Puts and/or overides an element with the name in that region.
+ * Puts and/or overrides an element with the name in that region.
* <p>
* @param name
* @param obj
* @throws CacheException
*/
- void put( Object name, Object obj )
+ void put( K name, V obj )
throws CacheException;
/**
@@ -76,7 +76,7 @@ public interface ICacheAccess
* @param attr
* @throws CacheException
*/
- void put( Object name, Object obj, IElementAttributes attr )
+ void put( K name, V obj, IElementAttributes attr )
throws CacheException;
/**
@@ -94,7 +94,7 @@ public interface ICacheAccess
* @param name Key the object is stored as
* @return The ICacheElement if the object is found or null
*/
- ICacheElement getCacheElement( Object name );
+ ICacheElement getCacheElement( K name );
/**
* Get multiple elements from the cache based on a set of cache keys.
@@ -114,7 +114,7 @@ public interface ICacheAccess
* @return a map of Object key to ICacheElement element, or empty map if none of the keys are
* present
*/
- Map getCacheElements( Set names );
+ Map<K, ICacheElement> getCacheElements( Set<K> names );
/**
* Get multiple elements from the cache based on a set of cache keys.
@@ -134,7 +134,7 @@ public interface ICacheAccess
* @return a map of Object key to ICacheElement element, or empty map if no keys match the
* pattern
*/
- Map getMatchingCacheElements( String pattern );
+ Map<K, ICacheElement> getMatchingCacheElements( String pattern );
/**
* Old remove all method.
@@ -149,12 +149,12 @@ public interface ICacheAccess
* @param name
* @throws CacheException
*/
- void remove( Object name )
+ void remove( K name )
throws CacheException;
/**
* ResetAttributes allows for some of the attributes of a region to be reset in particular
- * expiration time attriubtes, time to live, default time to live and idle time, and event
+ * expiration time attributes, time to live, default time to live and idle time, and event
* handlers. The cacheloader object and attributes set as flags can't be reset with
* resetAttributes, the object must be destroyed and redefined to cache those parameters.
* Changing default settings on groups and regions will not affect existing objects. Only object
@@ -174,7 +174,7 @@ public interface ICacheAccess
* @param attributes
* @throws CacheException
*/
- void resetElementAttributes( Object name, IElementAttributes attributes )
+ void resetElementAttributes( K name, IElementAttributes attributes )
throws CacheException;
/**
@@ -196,7 +196,7 @@ public interface ICacheAccess
* @return The elementAttributes value
* @throws CacheException
*/
- IElementAttributes getElementAttributes( Object name )
+ IElementAttributes getElementAttributes( K name )
throws CacheException;
/**
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/IGroupCacheAccess.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/IGroupCacheAccess.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/IGroupCacheAccess.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/access/behavior/IGroupCacheAccess.java Wed Jul 27 18:08:23 2011
@@ -28,8 +28,8 @@ import org.apache.jcs.engine.behavior.IE
* IGroupCacheAccess defines group specific behavior for the client access
* classes.
*/
-public interface IGroupCacheAccess
- extends ICacheAccess
+public interface IGroupCacheAccess<K, V>
+ extends ICacheAccess<K, V>
{
/**
* Gets the g attribute of the IGroupCacheAccess object
@@ -39,7 +39,7 @@ public interface IGroupCacheAccess
* the name of the group to associate this with.
* @return The teh object that is keyed by the name in the group
*/
- Object getFromGroup( Object name, String group );
+ V getFromGroup( K name, String group );
/**
* Puts an item int eh cache associated with this group.
@@ -49,7 +49,7 @@ public interface IGroupCacheAccess
* @param obj
* @throws CacheException
*/
- void putInGroup( Object key, String group, Object obj )
+ void putInGroup( K key, String group, V obj )
throws CacheException;
/**
@@ -61,7 +61,7 @@ public interface IGroupCacheAccess
* @param attr
* @throws CacheException
*/
- void putInGroup( Object key, String group, Object obj, IElementAttributes attr )
+ void putInGroup( K key, String group, V obj, IElementAttributes attr )
throws CacheException;
/**
@@ -70,7 +70,7 @@ public interface IGroupCacheAccess
* @param name
* @param group
*/
- public void remove( Object name, String group );
+ public void remove( K name, String group );
/**
* Gets the set of keys of objects currently in the group
@@ -78,7 +78,7 @@ public interface IGroupCacheAccess
* @param group
* @return the set of group keys.
*/
- public Set getGroupKeys( String group );
+ public Set<K> getGroupKeys( String group );
/**
* Invalidates a group
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/admin/JCSAdminBean.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/admin/JCSAdminBean.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/admin/JCSAdminBean.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/admin/JCSAdminBean.java Wed Jul 27 18:08:23 2011
@@ -36,6 +36,7 @@ import org.apache.jcs.engine.behavior.IE
import org.apache.jcs.engine.control.CompositeCache;
import org.apache.jcs.engine.control.CompositeCacheManager;
import org.apache.jcs.engine.memory.behavior.IMemoryCache;
+import org.apache.jcs.engine.memory.util.MemoryElementDescriptor;
/**
* A servlet which provides HTTP access to JCS. Allows a summary of regions to be viewed, and
@@ -48,8 +49,8 @@ public class JCSAdminBean
/** The logger. */
private static final Log log = LogFactory.getLog( JCSAdminBean.class );
- /** The cache maanger. */
- private CompositeCacheManager cacheHub = CompositeCacheManager.getInstance();
+ /** The cache manager. */
+ private final CompositeCacheManager cacheHub = CompositeCacheManager.getInstance();
/**
* Builds up info about each element in a region.
@@ -58,7 +59,7 @@ public class JCSAdminBean
* @return List of CacheElementInfo objects
* @throws Exception
*/
- public LinkedList buildElementInfo( String cacheName )
+ public LinkedList<CacheElementInfo> buildElementInfo( String cacheName )
throws Exception
{
CompositeCache cache = cacheHub.getCache( cacheName );
@@ -67,7 +68,6 @@ public class JCSAdminBean
// Attempt to sort keys according to their natural ordering. If that
// fails, get the key array again and continue unsorted.
-
try
{
Arrays.sort( keys );
@@ -77,7 +77,7 @@ public class JCSAdminBean
keys = cache.getMemoryCache().getKeyArray();
}
- LinkedList records = new LinkedList();
+ LinkedList<CacheElementInfo> records = new LinkedList<CacheElementInfo>();
ICacheElement element;
IElementAttributes attributes;
@@ -118,14 +118,14 @@ public class JCSAdminBean
* @return list of CacheRegionInfo objects
* @throws Exception
*/
- public LinkedList buildCacheInfo()
+ public LinkedList<CacheRegionInfo> buildCacheInfo()
throws Exception
{
String[] cacheNames = cacheHub.getCacheNames();
Arrays.sort( cacheNames );
- LinkedList cacheInfo = new LinkedList();
+ LinkedList<CacheRegionInfo> cacheInfo = new LinkedList<CacheRegionInfo>();
CacheRegionInfo regionInfo;
CompositeCache cache;
@@ -147,7 +147,7 @@ public class JCSAdminBean
/**
* Tries to estimate how much data is in a region. This is expensive. If there are any non
- * serializable objects in the region, the count will stop when it encouters the first one.
+ * serializable objects in the region, the count will stop when it encounters the first one.
* <p>
* @param cache
* @return int
@@ -158,7 +158,7 @@ public class JCSAdminBean
{
IMemoryCache memCache = cache.getMemoryCache();
- Iterator iter = memCache.getIterator();
+ Iterator<Map.Entry<Serializable, MemoryElementDescriptor>> iter = memCache.getIterator();
CountingOnlyOutputStream counter = new CountingOnlyOutputStream();
ObjectOutputStream out = new ObjectOutputStream( counter );
@@ -169,18 +169,16 @@ public class JCSAdminBean
{
while ( iter.hasNext() )
{
- ICacheElement ce = (ICacheElement) ( (Map.Entry) iter.next() ).getValue();
-
- out.writeObject( ce.getVal() );
+ MemoryElementDescriptor me = iter.next().getValue();
+ out.writeObject( me.ce.getVal() );
}
}
catch ( Exception e )
{
- log.info( "Problem getting byte count. Likley cause is a non serilizable object." + e.getMessage() );
+ log.info( "Problem getting byte count. Likely cause is a non serializable object." + e.getMessage() );
}
// 4 bytes lost for the serialization header
-
return counter.getCount() - 4;
}
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AbstractAuxiliaryCacheEventLogging.java Wed Jul 27 18:08:23 2011
@@ -114,7 +114,7 @@ public abstract class AbstractAuxiliaryC
* data in cache for any of these keys
* @throws IOException
*/
- public Map getMultiple( Set keys )
+ public Map<Serializable, ICacheElement> getMultiple(Set<Serializable> keys)
throws IOException
{
return getMultipleWithEventLogging( keys );
@@ -128,7 +128,7 @@ public abstract class AbstractAuxiliaryC
* data in cache for any of these keys
* @throws IOException
*/
- protected final Map getMultipleWithEventLogging( Set keys )
+ protected final Map<Serializable, ICacheElement> getMultipleWithEventLogging(Set<Serializable> keys )
throws IOException
{
ICacheEvent cacheEvent = createICacheEvent( getCacheName(), (Serializable) keys,
@@ -151,7 +151,7 @@ public abstract class AbstractAuxiliaryC
* data in cache for any of these keys
* @throws IOException
*/
- protected abstract Map processGetMultiple( Set keys )
+ protected abstract Map<Serializable, ICacheElement> processGetMultiple(Set<Serializable> keys)
throws IOException;
/**
@@ -168,7 +168,7 @@ public abstract class AbstractAuxiliaryC
* data matching the pattern.
* @throws IOException
*/
- public Map getMatching( String pattern )
+ public Map<Serializable, ICacheElement> getMatching( String pattern )
throws IOException
{
return getMatchingWithEventLogging( pattern );
@@ -182,7 +182,7 @@ public abstract class AbstractAuxiliaryC
* data matching the pattern.
* @throws IOException
*/
- protected final Map getMatchingWithEventLogging( String pattern )
+ protected final Map<Serializable, ICacheElement> getMatchingWithEventLogging( String pattern )
throws IOException
{
ICacheEvent cacheEvent = createICacheEvent( getCacheName(), pattern, ICacheEventLogger.GETMATCHING_EVENT );
@@ -204,7 +204,7 @@ public abstract class AbstractAuxiliaryC
* data matching the pattern.
* @throws IOException
*/
- protected abstract Map processGetMatching( String pattern )
+ protected abstract Map<Serializable, ICacheElement> processGetMatching( String pattern )
throws IOException;
/**
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java Wed Jul 27 18:08:23 2011
@@ -20,6 +20,7 @@ package org.apache.jcs.auxiliary;
*/
import java.io.IOException;
+import java.io.Serializable;
import java.util.Set;
import org.apache.jcs.engine.behavior.ICache;
@@ -42,7 +43,7 @@ public interface AuxiliaryCache
* @return a set of group keys
* @throws IOException
*/
- Set getGroupKeys( String group )
+ Set<Serializable> getGroupKeys( String group )
throws IOException;
/**
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java Wed Jul 27 18:08:23 2011
@@ -24,10 +24,10 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -46,8 +46,6 @@ import org.apache.jcs.engine.stats.Stats
import org.apache.jcs.engine.stats.behavior.IStatElement;
import org.apache.jcs.engine.stats.behavior.IStats;
-import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
-
/**
* Abstract class providing a base implementation of a disk cache, which can be easily extended to
* implement a disk cache for a specific persistence mechanism.
@@ -68,7 +66,7 @@ public abstract class AbstractDiskCache
private static final long serialVersionUID = 6541664080877628324L;
/** The logger */
- private static final Log log = LogFactory.getLog( AbstractDiskCache.class );
+ protected static final Log log = LogFactory.getLog( AbstractDiskCache.class );
/** Generic disk cache attributes */
private IDiskCacheAttributes diskCacheAttributes = null;
@@ -81,7 +79,7 @@ public abstract class AbstractDiskCache
* If the elements are pulled into the memory cache while the are still in purgatory, writing to
* disk can be canceled.
*/
- protected Map purgatory = new HashMap();
+ protected Map<Serializable, PurgatoryElement> purgatory = new HashMap<Serializable, PurgatoryElement>();
/**
* The CacheEventQueue where changes will be queued for asynchronous updating of the persistent
@@ -105,7 +103,7 @@ public abstract class AbstractDiskCache
* We lock here, so that we cannot get an update after a remove all. an individual removal locks
* the item.
*/
- private WriterPreferenceReadWriteLock removeAllLock = new WriterPreferenceReadWriteLock();
+ protected final ReentrantReadWriteLock removeAllLock = new ReentrantReadWriteLock();
// ----------------------------------------------------------- constructors
@@ -141,46 +139,37 @@ public abstract class AbstractDiskCache
*/
private void initPurgatory()
{
- try
- {
- // we need this so we can stop the updates from happening after a
- // removeall
- removeAllLock.writeLock().acquire();
+ // we need this so we can stop the updates from happening after a
+ // removeall
+ removeAllLock.writeLock().lock();
- if ( purgatory != null )
- {
- synchronized ( purgatory )
- {
- if ( diskCacheAttributes.getMaxPurgatorySize() >= 0 )
- {
- purgatory = new LRUMapJCS( diskCacheAttributes.getMaxPurgatorySize() );
- }
- else
- {
- purgatory = new HashMap();
- }
- }
- }
- else
+ if ( purgatory != null )
+ {
+ synchronized ( purgatory )
{
if ( diskCacheAttributes.getMaxPurgatorySize() >= 0 )
{
- purgatory = new LRUMapJCS( diskCacheAttributes.getMaxPurgatorySize() );
+ purgatory = new LRUMapJCS<Serializable, PurgatoryElement>( diskCacheAttributes.getMaxPurgatorySize() );
}
else
{
- purgatory = new HashMap();
+ purgatory = new HashMap<Serializable, PurgatoryElement>();
}
}
}
- catch ( InterruptedException e )
- {
- log.error( "problem encountered resseting purgatory.", e );
- }
- finally
+ else
{
- removeAllLock.writeLock().release();
+ if ( diskCacheAttributes.getMaxPurgatorySize() >= 0 )
+ {
+ purgatory = new LRUMapJCS<Serializable, PurgatoryElement>( diskCacheAttributes.getMaxPurgatorySize() );
+ }
+ else
+ {
+ purgatory = new HashMap<Serializable, PurgatoryElement>();
+ }
}
+
+ removeAllLock.writeLock().unlock();
}
// ------------------------------------------------------- interface ICache
@@ -196,6 +185,7 @@ public abstract class AbstractDiskCache
* @throws IOException
* @see org.apache.jcs.engine.behavior.ICache#update
*/
+ @Override
public final void update( ICacheElement cacheElement )
throws IOException
{
@@ -239,6 +229,7 @@ public abstract class AbstractDiskCache
* @return ICacheElement or null
* @see AuxiliaryCache#get
*/
+ @Override
public final ICacheElement get( Serializable key )
{
// If not alive, always return null.
@@ -255,7 +246,7 @@ public abstract class AbstractDiskCache
PurgatoryElement pe = null;
synchronized ( purgatory )
{
- pe = (PurgatoryElement) purgatory.get( key );
+ pe = purgatory.get( key );
}
// If the element was found in purgatory
@@ -322,7 +313,8 @@ public abstract class AbstractDiskCache
* data matching the pattern.
* @throws IOException
*/
- public Map getMatching( String pattern )
+ @Override
+ public Map<Serializable, ICacheElement> getMatching( String pattern )
throws IOException
{
// Get the keys from purgatory
@@ -334,13 +326,13 @@ public abstract class AbstractDiskCache
keyArray = purgatory.keySet().toArray();
}
- Set matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
+ Set<Serializable> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
// call getMultiple with the set
- Map result = processGetMultiple( matchingKeys );
+ Map<Serializable, ICacheElement> result = processGetMultiple( matchingKeys );
// Get the keys from disk
- Map diskMatches = doGetMatching( pattern );
+ Map<Serializable, ICacheElement> diskMatches = doGetMatching( pattern );
result.putAll( diskMatches );
@@ -354,18 +346,15 @@ public abstract class AbstractDiskCache
* @return a map of Serializable key to ICacheElement element, or an empty map if there is no
* data in cache for any of these keys
*/
- public Map processGetMultiple( Set keys )
+ @Override
+ public Map<Serializable, ICacheElement> processGetMultiple(Set<Serializable> keys)
{
- Map elements = new HashMap();
+ Map<Serializable, ICacheElement> elements = new HashMap<Serializable, ICacheElement>();
if ( keys != null && !keys.isEmpty() )
{
- Iterator iterator = keys.iterator();
-
- while ( iterator.hasNext() )
+ for (Serializable key : keys)
{
- Serializable key = (Serializable) iterator.next();
-
ICacheElement element = get( key );
if ( element != null )
@@ -384,7 +373,7 @@ public abstract class AbstractDiskCache
* (non-Javadoc)
* @see org.apache.jcs.auxiliary.AuxiliaryCache#getGroupKeys(java.lang.String)
*/
- public abstract Set getGroupKeys( String groupName );
+ public abstract Set<Serializable> getGroupKeys( String groupName );
/**
* Removes are not queued. A call to remove is immediate.
@@ -394,6 +383,7 @@ public abstract class AbstractDiskCache
* @throws IOException
* @see org.apache.jcs.engine.behavior.ICache#remove
*/
+ @Override
public final boolean remove( Serializable key )
throws IOException
{
@@ -403,7 +393,7 @@ public abstract class AbstractDiskCache
{
// I'm getting the object, so I can lock on the element
// Remove element from purgatory if it is there
- pe = (PurgatoryElement) purgatory.get( key );
+ pe = purgatory.get( key );
}
if ( pe != null )
@@ -436,6 +426,7 @@ public abstract class AbstractDiskCache
* @throws IOException
* @see org.apache.jcs.engine.behavior.ICache#removeAll
*/
+ @Override
public final void removeAll()
throws IOException
{
@@ -469,6 +460,7 @@ public abstract class AbstractDiskCache
* </ol>
* @throws IOException
*/
+ @Override
public final void dispose()
throws IOException
{
@@ -548,7 +540,7 @@ public abstract class AbstractDiskCache
IStats stats = new Stats();
stats.setTypeName( "Abstract Disk Cache" );
- ArrayList elems = new ArrayList();
+ ArrayList<IStatElement> elems = new ArrayList<IStatElement>();
IStatElement se = null;
@@ -566,11 +558,11 @@ public abstract class AbstractDiskCache
// get as array, convert to list, add list to our outer list
IStats eqStats = this.cacheEventQueue.getStatistics();
IStatElement[] eqSEs = eqStats.getStatElements();
- List eqL = Arrays.asList( eqSEs );
+ List<IStatElement> eqL = Arrays.asList( eqSEs );
elems.addAll( eqL );
// get an array and put them in the Stats object
- IStatElement[] ses = (IStatElement[]) elems.toArray( new StatElement[0] );
+ IStatElement[] ses = elems.toArray( new StatElement[0] );
stats.setStatElements( ses );
return stats;
@@ -607,7 +599,7 @@ public abstract class AbstractDiskCache
* Cache that implements the CacheListener interface, and calls appropriate methods in its
* parent class.
*/
- private class MyCacheListener
+ protected class MyCacheListener
implements ICacheListener
{
/** Id of the listener */
@@ -656,44 +648,35 @@ public abstract class AbstractDiskCache
synchronized ( pe.getCacheElement() )
{
- try
+ // TODO consider a timeout.
+ // we need this so that we can have multiple update
+ // threads and still have removeAll requests come in that
+ // always win
+ removeAllLock.readLock().lock();
+
+ // TODO consider changing purgatory sync
+ // String keyAsString = element.getKey().toString();
+ synchronized ( purgatory )
{
- // TODO consider a timeout.
- // we need this so that we can have multiple update
- // threads and still have removeAll requests come in that
- // always win
- removeAllLock.readLock().acquire();
-
- // TODO consider changing purgatory sync
- // String keyAsString = element.getKey().toString();
- synchronized ( purgatory )
+ // If the element has already been removed from
+ // purgatory do nothing
+ if ( !purgatory.containsKey( pe.getKey() ) )
{
- // If the element has already been removed from
- // purgatory do nothing
- if ( !purgatory.containsKey( pe.getKey() ) )
- {
- return;
- }
-
- element = pe.getCacheElement();
+ return;
}
- // I took this out of the purgatory sync block.
- // If the element is still eligible, spool it.
- if ( pe.isSpoolable() )
- {
- doUpdate( element );
- }
+ element = pe.getCacheElement();
}
- catch ( InterruptedException e )
- {
- log.error( e );
- }
- finally
+
+ // I took this out of the purgatory sync block.
+ // If the element is still eligible, spool it.
+ if ( pe.isSpoolable() )
{
- removeAllLock.readLock().release();
+ doUpdate( element );
}
+ removeAllLock.readLock().unlock();
+
synchronized ( purgatory )
{
// After the update has completed, it is safe to
@@ -806,7 +789,7 @@ public abstract class AbstractDiskCache
* @return A map of matches..
* @throws IOException
*/
- protected final Map doGetMatching( String pattern )
+ protected final Map<Serializable, ICacheElement> doGetMatching( String pattern )
throws IOException
{
return super.getMatchingWithEventLogging( pattern );
@@ -881,6 +864,7 @@ public abstract class AbstractDiskCache
* <p>
* @return disk location
*/
+ @Override
public String getEventLoggingExtraInfo()
{
return getDiskLocation();
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java?rev=1151575&r1=1151574&r2=1151575&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java Wed Jul 27 18:08:23 2011
@@ -27,8 +27,8 @@ import org.apache.jcs.utils.struct.LRUMa
* Extension of LRUMap for logging of removals. Can switch this back to a HashMap easily. This
* provides some abstraction. It also makes it easy to log overflow.
*/
-public class LRUMapJCS
- extends LRUMap
+public class LRUMapJCS<K, V>
+ extends LRUMap<K, V>
{
/** Don't change */
private static final long serialVersionUID = 776964015449842672L;
@@ -66,7 +66,8 @@ public class LRUMapJCS
* @param key
* @param value
*/
- protected void processRemovedLRU( Object key, Object value )
+ @Override
+ protected void processRemovedLRU(K key, V value)
{
if ( log.isDebugEnabled() )
{