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 2012/05/30 20:14:51 UTC
svn commit: r1344374 [6/14] - in /commons/proper/jcs/trunk: ./
auxiliary-builds/javagroups/src/java/org/apache/jcs/auxiliary/javagroups/
auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/javagroups/
auxiliary-builds/jdk14/src/java/org/apache/jcs...
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java Wed May 30 18:14:43 2012
@@ -19,6 +19,7 @@ package org.apache.jcs.auxiliary.remote.
* under the License.
*/
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -51,8 +52,8 @@ public class RemoteHttpCacheFactory
private String name;
/** store reference of facades to initiate failover */
- private final static HashMap<String, RemoteCacheNoWaitFacade> facades =
- new HashMap<String, RemoteCacheNoWaitFacade>();
+ private final static HashMap<String, RemoteCacheNoWaitFacade<? extends Serializable, ? extends Serializable>> facades =
+ new HashMap<String, RemoteCacheNoWaitFacade<? extends Serializable, ? extends Serializable>>();
/**
* For LOCAL clients we get a handle to all the failovers, but we do not register a listener
@@ -67,17 +68,17 @@ public class RemoteHttpCacheFactory
* @param elementSerializer
* @return AuxiliaryCache
*/
- public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
+ public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
{
RemoteHttpCacheAttributes rca = (RemoteHttpCacheAttributes) iaca;
- ArrayList<ICache> noWaits = new ArrayList<ICache>();
+ ArrayList<ICache<K, V>> noWaits = new ArrayList<ICache<K, V>>();
RemoteHttpCacheManager rcm = RemoteHttpCacheManager.getInstance( cacheMgr, cacheEventLogger, elementSerializer );
// TODO, use the configured value.
rca.setRemoteType( RemoteCacheAttributes.LOCAL );
- ICache ic = rcm.getCache( rca );
+ ICache<K, V> ic = rcm.getCache( rca );
if ( ic != null )
{
noWaits.add( ic );
@@ -87,7 +88,7 @@ public class RemoteHttpCacheFactory
log.info( "noWait is null" );
}
- RemoteCacheNoWaitFacade rcnwf = new RemoteCacheNoWaitFacade( noWaits
+ RemoteCacheNoWaitFacade<K, V> rcnwf = new RemoteCacheNoWaitFacade<K, V>( noWaits
.toArray( new RemoteCacheNoWait[0] ), rca, cacheMgr, cacheEventLogger, elementSerializer );
getFacades().put( rca.getCacheName(), rcnwf );
@@ -119,7 +120,7 @@ public class RemoteHttpCacheFactory
* The facades are what the cache hub talks to.
* @return Returns the facades.
*/
- public static HashMap<String, RemoteCacheNoWaitFacade> getFacades()
+ public static HashMap<String, RemoteCacheNoWaitFacade<? extends Serializable, ? extends Serializable>> getFacades()
{
return facades;
}
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheManager.java Wed May 30 18:14:43 2012
@@ -19,6 +19,7 @@ package org.apache.jcs.auxiliary.remote.
* under the License.
*/
+import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -53,7 +54,8 @@ public class RemoteHttpCacheManager
private static RemoteHttpCacheManager instance;
/** Contains instances of RemoteCacheNoWait managed by a RemoteCacheManager instance. */
- static final Map<String, RemoteCacheNoWait> caches = new HashMap<String, RemoteCacheNoWait>();
+ static final Map<String, RemoteCacheNoWait<? extends Serializable, ? extends Serializable>> caches =
+ new HashMap<String, RemoteCacheNoWait<? extends Serializable, ? extends Serializable>>();
/** The configuration attributes. */
private IRemoteCacheAttributes remoteCacheAttributes;
@@ -150,7 +152,7 @@ public class RemoteHttpCacheManager
* @param cacheName
* @return The cache value
*/
- public AuxiliaryCache getCache( String cacheName )
+ public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( String cacheName )
{
// TODO get some defaults!
// Perhaps we will need a manager per URL????
@@ -169,24 +171,24 @@ public class RemoteHttpCacheManager
* @param cattr
* @return The cache value
*/
- public AuxiliaryCache getCache( RemoteHttpCacheAttributes cattr )
+ public <K extends Serializable, V extends Serializable> AuxiliaryCache<K, V> getCache( RemoteHttpCacheAttributes cattr )
{
- RemoteCacheNoWait remoteCacheNoWait = null;
+ RemoteCacheNoWait<K, V> remoteCacheNoWait = null;
synchronized ( caches )
{
- remoteCacheNoWait = caches.get( cattr.getCacheName() + cattr.getUrl() );
+ remoteCacheNoWait = (RemoteCacheNoWait<K, V>) caches.get( cattr.getCacheName() + cattr.getUrl() );
if ( remoteCacheNoWait == null )
{
- RemoteHttpClientListener listener = new RemoteHttpClientListener( cattr, cacheMgr );
+ RemoteHttpClientListener<K, V> listener = new RemoteHttpClientListener<K, V>( cattr, cacheMgr );
- IRemoteHttpCacheClient remoteService = createRemoteHttpCacheClientForAttributes( cattr );
+ IRemoteHttpCacheClient<K, V> remoteService = createRemoteHttpCacheClientForAttributes( cattr );
- IRemoteCacheClient remoteCacheClient = new RemoteHttpCache( cattr, remoteService, listener );
+ IRemoteCacheClient<K, V> remoteCacheClient = new RemoteHttpCache<K, V>( cattr, remoteService, listener );
remoteCacheClient.setCacheEventLogger( cacheEventLogger );
remoteCacheClient.setElementSerializer( elementSerializer );
- remoteCacheNoWait = new RemoteCacheNoWait( remoteCacheClient );
+ remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient );
remoteCacheNoWait.setCacheEventLogger( cacheEventLogger );
remoteCacheNoWait.setElementSerializer( elementSerializer );
@@ -205,9 +207,9 @@ public class RemoteHttpCacheManager
* @param cattr
* @return IRemoteHttpCacheClient
*/
- protected IRemoteHttpCacheClient createRemoteHttpCacheClientForAttributes( RemoteHttpCacheAttributes cattr )
+ protected <K extends Serializable, V extends Serializable> IRemoteHttpCacheClient<K, V> createRemoteHttpCacheClientForAttributes( RemoteHttpCacheAttributes cattr )
{
- IRemoteHttpCacheClient client = (IRemoteHttpCacheClient) OptionConverter.instantiateByClassName( cattr
+ IRemoteHttpCacheClient<K, V> client = (IRemoteHttpCacheClient<K, V>) OptionConverter.instantiateByClassName( cattr
.getRemoteHttpClientClassName(), IRemoteHttpCacheClient.class, null );
if ( client == null )
@@ -216,7 +218,7 @@ public class RemoteHttpCacheManager
{
log.info( "Creating the default client." );
}
- client = new RemoteHttpCacheClient( );
+ client = new RemoteHttpCacheClient<K, V>( );
}
client.initialize( cattr );
return client;
@@ -230,7 +232,7 @@ public class RemoteHttpCacheManager
public String getStats()
{
StringBuffer stats = new StringBuffer();
- for (RemoteCacheNoWait c : caches.values())
+ for (RemoteCacheNoWait<?, ?> c : caches.values())
{
if ( c != null )
{
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java Wed May 30 18:14:43 2012
@@ -19,6 +19,7 @@ package org.apache.jcs.auxiliary.remote.
* under the License.
*/
+import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@@ -45,7 +46,7 @@ public class RemoteHttpCacheMonitor
private static long idlePeriod = 3 * 1000;
/** Set of remote caches to monitor. This are added on error, if not before. */
- private final Set<RemoteHttpCache> remoteHttpCaches = new HashSet<RemoteHttpCache>();
+ private final Set<RemoteHttpCache<?, ?>> remoteHttpCaches = new HashSet<RemoteHttpCache<?, ?>>();
/**
* Must make sure RemoteCacheMonitor is started before any remote error can be detected!
@@ -102,7 +103,7 @@ public class RemoteHttpCacheMonitor
* <p>
* @param remoteCache
*/
- public void notifyError( RemoteHttpCache remoteCache )
+ public void notifyError( RemoteHttpCache<?, ?> remoteCache )
{
if ( log.isInfoEnabled() )
{
@@ -176,7 +177,7 @@ public class RemoteHttpCacheMonitor
// ignore;
}
- // The "alright" flag must be false here.
+ // The "allright" flag must be false here.
// Simply presume we can fix all the errors until proven otherwise.
synchronized ( this )
{
@@ -184,16 +185,20 @@ public class RemoteHttpCacheMonitor
}
// Make a copy
- Set<RemoteHttpCache> remoteCachesToExamine = new HashSet<RemoteHttpCache>();
+ Set<RemoteHttpCache<Serializable, Serializable>> remoteCachesToExamine =
+ new HashSet<RemoteHttpCache<Serializable, Serializable>>();
synchronized ( this )
{
- remoteCachesToExamine.addAll( this.remoteHttpCaches );
+ for (RemoteHttpCache<?, ?> remoteCache : this.remoteHttpCaches)
+ {
+ remoteCachesToExamine.add( (RemoteHttpCache<Serializable, Serializable>)remoteCache );
+ }
}
// If any cache is in error, it strongly suggests all caches
// managed by the
// same RmicCacheManager instance are in error. So we fix
// them once and for all.
- for (RemoteHttpCache remoteCache : remoteCachesToExamine)
+ for (RemoteHttpCache<Serializable, Serializable> remoteCache : remoteCachesToExamine)
{
try
{
@@ -201,7 +206,7 @@ public class RemoteHttpCacheMonitor
{
RemoteHttpCacheAttributes attributes = remoteCache.getRemoteHttpCacheAttributes();
- IRemoteHttpCacheClient remoteService = RemoteHttpCacheManager.getInstance()
+ IRemoteHttpCacheClient<Serializable, Serializable> remoteService = RemoteHttpCacheManager.getInstance()
.createRemoteHttpCacheClientForAttributes( attributes );
if ( log.isInfoEnabled() )
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpClientListener.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpClientListener.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpClientListener.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/RemoteHttpClientListener.java Wed May 30 18:14:43 2012
@@ -19,14 +19,19 @@ package org.apache.jcs.auxiliary.remote.
* under the License.
*/
+import java.io.Serializable;
+
import org.apache.jcs.auxiliary.remote.AbsractRemoteCacheListener;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
import org.apache.jcs.engine.behavior.ICompositeCacheManager;
/** Does nothing */
-public class RemoteHttpClientListener
- extends AbsractRemoteCacheListener
+public class RemoteHttpClientListener<K extends Serializable, V extends Serializable>
+ extends AbsractRemoteCacheListener<K, V>
{
+ /** TODO serialVersionUID */
+ private static final long serialVersionUID = -9078366610772128010L;
+
/**
* Only need one since it does work for all regions, just reference by multiple region names.
* <p>
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/behavior/IRemoteHttpCacheClient.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/behavior/IRemoteHttpCacheClient.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/behavior/IRemoteHttpCacheClient.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/client/behavior/IRemoteHttpCacheClient.java Wed May 30 18:14:43 2012
@@ -1,6 +1,7 @@
package org.apache.jcs.auxiliary.remote.http.client.behavior;
import java.io.IOException;
+import java.io.Serializable;
import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService;
import org.apache.jcs.auxiliary.remote.http.client.RemoteHttpCacheAttributes;
@@ -28,8 +29,8 @@ import org.apache.jcs.auxiliary.remote.h
* It's not entirely clear that this interface is needed. I simply wanted the initialization method.
* This could be added to the ICacheSerice method.
*/
-public interface IRemoteHttpCacheClient
- extends IRemoteCacheService
+public interface IRemoteHttpCacheClient<K extends Serializable, V extends Serializable>
+ extends IRemoteCacheService<K, V>
{
/**
* The provides an extension point. If you want to extend this and use a special dispatcher,
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java Wed May 30 18:14:43 2012
@@ -39,15 +39,12 @@ import org.apache.jcs.engine.logging.beh
* This class contains common methods for remote cache services. Eventually I hope to extract out
* much of the RMI server to use this as well. I'm starting with the Http service.
*/
-public abstract class AbstractRemoteCacheService
- implements IRemoteCacheService
+public abstract class AbstractRemoteCacheService<K extends Serializable, V extends Serializable>
+ implements IRemoteCacheService<K, V>
{
/** An optional event logger */
private transient ICacheEventLogger cacheEventLogger;
- /** If there is no event logger, we will return this event for all create calls. */
- private static final ICacheEvent EMPTY_ICACHE_EVENT = new CacheEvent();
-
/** The central hub */
private ICompositeCacheManager cacheManager;
@@ -79,7 +76,7 @@ public abstract class AbstractRemoteCach
* @param item
* @throws IOException
*/
- public void update( ICacheElement item )
+ public void update( ICacheElement<K, V> item )
throws IOException
{
update( item, 0 );
@@ -92,10 +89,10 @@ public abstract class AbstractRemoteCach
* @param requesterId
* @throws IOException
*/
- public void update( ICacheElement item, long requesterId )
+ public void update( ICacheElement<K, V> item, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( item, requesterId, ICacheEventLogger.UPDATE_EVENT );
+ ICacheEvent<ICacheElement<K, V>> cacheEvent = createICacheEvent( item, requesterId, ICacheEventLogger.UPDATE_EVENT );
try
{
logUpdateInfo( item );
@@ -115,7 +112,7 @@ public abstract class AbstractRemoteCach
* @param requesterId
* @throws IOException
*/
- abstract void processUpdate( ICacheElement item, long requesterId )
+ abstract void processUpdate( ICacheElement<K, V> item, long requesterId )
throws IOException;
/**
@@ -123,7 +120,7 @@ public abstract class AbstractRemoteCach
* <p>
* @param item
*/
- private void logUpdateInfo( ICacheElement item )
+ private void logUpdateInfo( ICacheElement<K, V> item )
{
if ( log.isInfoEnabled() )
{
@@ -150,7 +147,7 @@ public abstract class AbstractRemoteCach
* @return ICacheElement
* @throws IOException
*/
- public ICacheElement get( String cacheName, Serializable key )
+ public ICacheElement<K, V> get( String cacheName, K key )
throws IOException
{
return this.get( cacheName, key, 0 );
@@ -169,11 +166,11 @@ public abstract class AbstractRemoteCach
* @return ICacheElement
* @throws IOException
*/
- public ICacheElement get( String cacheName, Serializable key, long requesterId )
+ public ICacheElement<K, V> get( String cacheName, K key, long requesterId )
throws IOException
{
- ICacheElement element = null;
- ICacheEvent cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.GET_EVENT );
+ ICacheElement<K, V> element = null;
+ ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.GET_EVENT );
try
{
element = processGet( cacheName, key, requesterId );
@@ -196,7 +193,7 @@ public abstract class AbstractRemoteCach
* @return ICacheElement
* @throws IOException
*/
- abstract ICacheElement processGet( String cacheName, Serializable key, long requesterId )
+ abstract ICacheElement<K, V> processGet( String cacheName, K key, long requesterId )
throws IOException;
/**
@@ -207,7 +204,7 @@ public abstract class AbstractRemoteCach
* @return Map of keys and wrapped objects
* @throws IOException
*/
- public Map<Serializable, ICacheElement> getMatching( String cacheName, String pattern )
+ public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern )
throws IOException
{
return getMatching( cacheName, pattern, 0 );
@@ -222,10 +219,10 @@ public abstract class AbstractRemoteCach
* @return Map of keys and wrapped objects
* @throws IOException
*/
- public Map<Serializable, ICacheElement> getMatching( String cacheName, String pattern, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, pattern, requesterId,
+ ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, pattern, requesterId,
ICacheEventLogger.GETMATCHING_EVENT );
try
{
@@ -246,7 +243,7 @@ public abstract class AbstractRemoteCach
* @return Map of keys and wrapped objects
* @throws IOException
*/
- abstract Map<Serializable, ICacheElement> processGetMatching( String cacheName, String pattern, long requesterId )
+ abstract Map<K, ICacheElement<K, V>> processGetMatching( String cacheName, String pattern, long requesterId )
throws IOException;
/**
@@ -254,11 +251,11 @@ public abstract class AbstractRemoteCach
* <p>
* @param cacheName
* @param keys
- * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+ * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
* data in cache for any of these keys
* @throws IOException
*/
- public Map<Serializable, ICacheElement> getMultiple( String cacheName, Set<Serializable> keys )
+ public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys )
throws IOException
{
return this.getMultiple( cacheName, keys, 0 );
@@ -272,14 +269,14 @@ public abstract class AbstractRemoteCach
* @param cacheName
* @param keys
* @param requesterId
- * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+ * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
* data in cache for any of these keys
* @throws IOException
*/
- public Map<Serializable, ICacheElement> getMultiple( String cacheName, Set<Serializable> keys, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, (Serializable) keys, requesterId,
+ ICacheEvent<Serializable> cacheEvent = createICacheEvent( cacheName, (Serializable) keys, requesterId,
ICacheEventLogger.GETMULTIPLE_EVENT );
try
{
@@ -297,11 +294,11 @@ public abstract class AbstractRemoteCach
* @param cacheName
* @param keys
* @param requesterId
- * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+ * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
* data in cache for any of these keys
* @throws IOException
*/
- abstract Map<Serializable, ICacheElement> processGetMultiple( String cacheName, Set<Serializable> keys, long requesterId )
+ abstract Map<K, ICacheElement<K, V>> processGetMultiple( String cacheName, Set<K> keys, long requesterId )
throws IOException;
/**
@@ -311,7 +308,7 @@ public abstract class AbstractRemoteCach
* @param group
* @return A Set of group keys
*/
- public Set<Serializable> getGroupKeys( String cacheName, String group )
+ public Set<K> getGroupKeys( String cacheName, String group )
{
return processGetGroupKeys( cacheName, group );
}
@@ -323,9 +320,9 @@ public abstract class AbstractRemoteCach
* @param groupName
* @return Set
*/
- public Set<Serializable> processGetGroupKeys( String cacheName, String groupName )
+ public Set<K> processGetGroupKeys( String cacheName, String groupName )
{
- CompositeCache cache = getCacheManager().getCache( cacheName );
+ CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
return cache.getGroupKeys( groupName );
}
@@ -337,7 +334,7 @@ public abstract class AbstractRemoteCach
* @param key
* @throws IOException
*/
- public void remove( String cacheName, Serializable key )
+ public void remove( String cacheName, K key )
throws IOException
{
remove( cacheName, key, 0 );
@@ -353,10 +350,10 @@ public abstract class AbstractRemoteCach
* @param requesterId
* @throws IOException
*/
- public void remove( String cacheName, Serializable key, long requesterId )
+ public void remove( String cacheName, K key, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.REMOVE_EVENT );
+ ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.REMOVE_EVENT );
try
{
processRemove( cacheName, key, requesterId );
@@ -375,7 +372,7 @@ public abstract class AbstractRemoteCach
* @param requesterId
* @throws IOException
*/
- abstract void processRemove( String cacheName, Serializable key, long requesterId )
+ abstract void processRemove( String cacheName, K key, long requesterId )
throws IOException;
/**
@@ -402,7 +399,7 @@ public abstract class AbstractRemoteCach
public void removeAll( String cacheName, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, "all", requesterId, ICacheEventLogger.REMOVEALL_EVENT );
+ ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "all", requesterId, ICacheEventLogger.REMOVEALL_EVENT );
try
{
processRemoveAll( cacheName, requesterId );
@@ -445,7 +442,7 @@ public abstract class AbstractRemoteCach
public void dispose( String cacheName, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, "none", requesterId, ICacheEventLogger.DISPOSE_EVENT );
+ ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "none", requesterId, ICacheEventLogger.DISPOSE_EVENT );
try
{
processDispose( cacheName, requesterId );
@@ -484,11 +481,11 @@ public abstract class AbstractRemoteCach
* @param eventName
* @return ICacheEvent
*/
- protected ICacheEvent createICacheEvent( ICacheElement item, long requesterId, String eventName )
+ protected ICacheEvent<ICacheElement<K, V>> createICacheEvent( ICacheElement<K, V> item, long requesterId, String eventName )
{
if ( cacheEventLogger == null )
{
- return EMPTY_ICACHE_EVENT;
+ return new CacheEvent<ICacheElement<K, V>>();
}
String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger.createICacheEvent( getEventLogSourceName(), item.getCacheName(), eventName, ipAddress,
@@ -504,11 +501,11 @@ public abstract class AbstractRemoteCach
* @param eventName
* @return ICacheEvent
*/
- protected ICacheEvent createICacheEvent( String cacheName, Serializable key, long requesterId, String eventName )
+ protected <T extends Serializable> ICacheEvent<T> createICacheEvent( String cacheName, T key, long requesterId, String eventName )
{
if ( cacheEventLogger == null )
{
- return EMPTY_ICACHE_EVENT;
+ return new CacheEvent<T>();
}
String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger.createICacheEvent( getEventLogSourceName(), cacheName, eventName, ipAddress, key );
@@ -534,7 +531,7 @@ public abstract class AbstractRemoteCach
* <p>
* @param cacheEvent
*/
- protected void logICacheEvent( ICacheEvent cacheEvent )
+ protected <T extends Serializable> void logICacheEvent( ICacheEvent<T> cacheEvent )
{
if ( cacheEventLogger != null )
{
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteCacheServiceAdaptor.java Wed May 30 18:14:43 2012
@@ -19,6 +19,7 @@ package org.apache.jcs.auxiliary.remote.
* under the License.
*/
+import java.io.IOException;
import java.io.Serializable;
import java.util.Collections;
import java.util.Map;
@@ -38,13 +39,13 @@ import org.apache.jcs.engine.control.Com
* <p>
* This is essentially an adaptor on top of the service.
*/
-public class RemoteCacheServiceAdaptor
+public class RemoteCacheServiceAdaptor<K extends Serializable, V extends Serializable>
{
/** The Logger. */
private final static Log log = LogFactory.getLog( RemoteCacheServiceAdaptor.class );
/** The service that does the work. */
- private IRemoteCacheService remoteCacheService;
+ private IRemoteCacheService<K, V> remoteCacheService;
/** This is for testing without the factory. */
protected RemoteCacheServiceAdaptor()
@@ -59,7 +60,8 @@ public class RemoteCacheServiceAdaptor
*/
public RemoteCacheServiceAdaptor( CompositeCacheManager cacheManager )
{
- setRemoteCacheService( RemoteHttpCacheSeviceFactory.createRemoteHttpCacheService( cacheManager ) );
+ IRemoteCacheService<K, V> rcs = RemoteHttpCacheSeviceFactory.createRemoteHttpCacheService( cacheManager );
+ setRemoteCacheService( rcs );
}
/**
@@ -68,9 +70,9 @@ public class RemoteCacheServiceAdaptor
* @param request
* @return RemoteHttpCacheResponse, never null
*/
- public RemoteCacheResponse processRequest( RemoteCacheRequest request )
+ public RemoteCacheResponse<K, V> processRequest( RemoteCacheRequest<K, V> request )
{
- RemoteCacheResponse response = new RemoteCacheResponse();
+ RemoteCacheResponse<K, V> response = new RemoteCacheResponse<K, V>();
if ( request == null )
{
@@ -86,7 +88,7 @@ public class RemoteCacheServiceAdaptor
switch ( request.getRequestType() )
{
case RemoteCacheRequest.REQUEST_TYPE_GET:
- ICacheElement element = getRemoteCacheService().get( request.getCacheName(), request.getKey(),
+ ICacheElement<K, V> element = getRemoteCacheService().get( request.getCacheName(), request.getKey(),
request.getRequesterId() );
if ( element != null )
{
@@ -94,7 +96,7 @@ public class RemoteCacheServiceAdaptor
}
break;
case RemoteCacheRequest.REQUEST_TYPE_GET_MULTIPLE:
- Map<Serializable, ICacheElement> elementMap = getRemoteCacheService().getMultiple( request.getCacheName(),
+ Map<K, ICacheElement<K, V>> elementMap = getRemoteCacheService().getMultiple( request.getCacheName(),
request.getKeySet(),
request.getRequesterId() );
if ( elementMap != null )
@@ -103,7 +105,7 @@ public class RemoteCacheServiceAdaptor
}
break;
case RemoteCacheRequest.REQUEST_TYPE_GET_MATCHING:
- Map<Serializable, ICacheElement> elementMapMatching = getRemoteCacheService().getMatching( request.getCacheName(),
+ Map<K, ICacheElement<K, V>> elementMapMatching = getRemoteCacheService().getMatching( request.getCacheName(),
request.getPattern(),
request.getRequesterId() );
if ( elementMapMatching != null )
@@ -129,13 +131,14 @@ public class RemoteCacheServiceAdaptor
// DO NOTHING
break;
case RemoteCacheRequest.REQUEST_TYPE_GET_GROUP_KEYS:
- Set<Serializable> groupKeys = getRemoteCacheService().getGroupKeys( request.getCacheName(),
+ Set<K> groupKeys = getRemoteCacheService().getGroupKeys( request.getCacheName(),
request.getKey() + "" );
if ( groupKeys == null )
{
groupKeys = Collections.emptySet();
}
- response.getPayload().put( request.getKey(), groupKeys );
+ // FIXME: Re-enable
+ //response.getPayload().put( request.getKey(), groupKeys );
break;
default:
String message = "Unknown event type. Cannot process " + request;
@@ -145,7 +148,7 @@ public class RemoteCacheServiceAdaptor
break;
}
}
- catch ( Exception e )
+ catch ( IOException e )
{
String message = "Problem processing request. " + request + " Error: " + e.getMessage();
log.error( message, e );
@@ -160,7 +163,7 @@ public class RemoteCacheServiceAdaptor
/**
* @param remoteHttpCacheService the remoteHttpCacheService to set
*/
- public void setRemoteCacheService( IRemoteCacheService remoteHttpCacheService )
+ public void setRemoteCacheService( IRemoteCacheService<K, V> remoteHttpCacheService )
{
this.remoteCacheService = remoteHttpCacheService;
}
@@ -168,7 +171,7 @@ public class RemoteCacheServiceAdaptor
/**
* @return the remoteHttpCacheService
*/
- public IRemoteCacheService getRemoteCacheService()
+ public IRemoteCacheService<K, V> getRemoteCacheService()
{
return remoteCacheService;
}
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteHttpCacheService.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteHttpCacheService.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteHttpCacheService.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteHttpCacheService.java Wed May 30 18:14:43 2012
@@ -36,8 +36,8 @@ import org.apache.jcs.engine.logging.beh
* For now we assume that all clients are non-cluster clients. And listener notification is not
* supported.
*/
-public class RemoteHttpCacheService
- extends AbstractRemoteCacheService
+public class RemoteHttpCacheService<K extends Serializable, V extends Serializable>
+ extends AbstractRemoteCacheService<K, V>
{
/** The name used in the event logs. */
private static final String EVENT_LOG_SOURCE_NAME = "RemoteHttpCacheServer";
@@ -73,10 +73,10 @@ public class RemoteHttpCacheService
* @throws IOException
*/
@Override
- public ICacheElement processGet( String cacheName, Serializable key, long requesterId )
+ public ICacheElement<K, V> processGet( String cacheName, K key, long requesterId )
throws IOException
{
- CompositeCache cache = getCacheManager().getCache( cacheName );
+ CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
boolean keepLocal = !remoteHttpCacheServerAttributes.isAllowClusterGet();
if ( keepLocal )
@@ -102,10 +102,10 @@ public class RemoteHttpCacheService
* @throws IOException
*/
@Override
- public Map<Serializable, ICacheElement> processGetMultiple( String cacheName, Set<Serializable> keys, long requesterId )
+ public Map<K, ICacheElement<K, V>> processGetMultiple( String cacheName, Set<K> keys, long requesterId )
throws IOException
{
- CompositeCache cache = getCacheManager().getCache( cacheName );
+ CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
boolean keepLocal = !remoteHttpCacheServerAttributes.isAllowClusterGet();
if ( keepLocal )
@@ -131,10 +131,10 @@ public class RemoteHttpCacheService
* @throws IOException
*/
@Override
- public Map<Serializable, ICacheElement> processGetMatching( String cacheName, String pattern, long requesterId )
+ public Map<K, ICacheElement<K, V>> processGetMatching( String cacheName, String pattern, long requesterId )
throws IOException
{
- CompositeCache cache = getCacheManager().getCache( cacheName );
+ CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
boolean keepLocal = !remoteHttpCacheServerAttributes.isAllowClusterGet();
if ( keepLocal )
@@ -158,10 +158,10 @@ public class RemoteHttpCacheService
* @throws IOException
*/
@Override
- public void processUpdate( ICacheElement item, long requesterId )
+ public void processUpdate( ICacheElement<K, V> item, long requesterId )
throws IOException
{
- CompositeCache cache = getCacheManager().getCache( item.getCacheName() );
+ CompositeCache<K, V> cache = getCacheManager().getCache( item.getCacheName() );
boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency();
if ( keepLocal )
@@ -186,10 +186,10 @@ public class RemoteHttpCacheService
* @throws IOException
*/
@Override
- public void processRemove( String cacheName, Serializable key, long requesterId )
+ public void processRemove( String cacheName, K key, long requesterId )
throws IOException
{
- CompositeCache cache = getCacheManager().getCache( cacheName );
+ CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency();
if ( keepLocal )
@@ -216,7 +216,7 @@ public class RemoteHttpCacheService
public void processRemoveAll( String cacheName, long requesterId )
throws IOException
{
- CompositeCache cache = getCacheManager().getCache( cacheName );
+ CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency();
if ( keepLocal )
@@ -240,7 +240,7 @@ public class RemoteHttpCacheService
public void processDispose( String cacheName, long requesterId )
throws IOException
{
- CompositeCache cache = getCacheManager().getCache( cacheName );
+ CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
cache.dispose();
}
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteHttpCacheSeviceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteHttpCacheSeviceFactory.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteHttpCacheSeviceFactory.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/http/server/RemoteHttpCacheSeviceFactory.java Wed May 30 18:14:43 2012
@@ -19,6 +19,7 @@ package org.apache.jcs.auxiliary.remote.
* under the License.
*/
+import java.io.Serializable;
import java.util.Properties;
import org.apache.commons.logging.Log;
@@ -41,13 +42,13 @@ public class RemoteHttpCacheSeviceFactor
* @param cacheManager
* @return RemoteHttpCacheService
*/
- public static RemoteHttpCacheService createRemoteHttpCacheService( ICompositeCacheManager cacheManager )
+ public static <K extends Serializable, V extends Serializable> RemoteHttpCacheService<K, V> createRemoteHttpCacheService( ICompositeCacheManager cacheManager )
{
Properties props = cacheManager.getConfigurationProperties();
ICacheEventLogger cacheEventLogger = configureCacheEventLogger( props );
RemoteHttpCacheServerAttributes attributes = configureRemoteHttpCacheServerAttributes( props );
- RemoteHttpCacheService service = new RemoteHttpCacheService( cacheManager, attributes, cacheEventLogger );
+ RemoteHttpCacheService<K, V> service = new RemoteHttpCacheService<K, V>( cacheManager, attributes, cacheEventLogger );
if ( log.isInfoEnabled() )
{
log.info( "Created new RemoteHttpCacheService " + service );
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java Wed May 30 18:14:43 2012
@@ -63,9 +63,9 @@ import org.apache.jcs.engine.logging.beh
* between the two servers. Since caches are usually high get and low put, this should allow you to
* scale.
*/
-public class RemoteCacheServer
+public class RemoteCacheServer<K extends Serializable, V extends Serializable>
extends UnicastRemoteObject
- implements IRemoteCacheService, IRemoteCacheObserver, IRemoteCacheServiceAdmin, Unreferenced
+ implements IRemoteCacheService<K, V>, IRemoteCacheObserver, IRemoteCacheServiceAdmin, Unreferenced
{
/** For serialization. Don't change. */
private static final long serialVersionUID = -8072345435941473116L;
@@ -80,12 +80,12 @@ public class RemoteCacheServer
private int puts = 0;
/** Maps cache name to CacheListeners object. association of listeners (regions). */
- private final Hashtable<String, CacheListeners> cacheListenersMap =
- new Hashtable<String, CacheListeners>();
+ private final Hashtable<String, CacheListeners<K, V>> cacheListenersMap =
+ new Hashtable<String, CacheListeners<K, V>>();
/** maps cluster listeners to regions. */
- private final Hashtable<String, CacheListeners> clusterListenersMap =
- new Hashtable<String, CacheListeners>();
+ private final Hashtable<String, CacheListeners<K, V>> clusterListenersMap =
+ new Hashtable<String, CacheListeners<K, V>>();
/** The central hub */
private CompositeCacheManager cacheManager;
@@ -108,9 +108,6 @@ public class RemoteCacheServer
/** An optional event logger */
private transient ICacheEventLogger cacheEventLogger;
- /** If there is no event logger, we will return this event for all create calls. */
- private static final ICacheEvent EMPTY_ICACHE_EVENT = new CacheEvent();
-
/**
* Constructor for the RemoteCacheServer object. This initializes the server with the values
* from the config file.
@@ -165,7 +162,8 @@ public class RemoteCacheServer
for ( int i = 0; i < list.length; i++ )
{
String name = list[i];
- cacheListenersMap.put( name, new CacheListeners( cacheManager.getCache( name ) ) );
+ CompositeCache<K, V> cache = cacheManager.getCache( name );
+ cacheListenersMap.put( name, new CacheListeners<K, V>( cache ) );
}
}
@@ -202,7 +200,7 @@ public class RemoteCacheServer
* @param item
* @throws IOException
*/
- public void put( ICacheElement item )
+ public void put( ICacheElement<K, V> item )
throws IOException
{
update( item );
@@ -212,7 +210,7 @@ public class RemoteCacheServer
* @param item
* @throws IOException
*/
- public void update( ICacheElement item )
+ public void update( ICacheElement<K, V> item )
throws IOException
{
update( item, 0 );
@@ -225,10 +223,10 @@ public class RemoteCacheServer
* @param requesterId
* @throws IOException
*/
- public void update( ICacheElement item, long requesterId )
+ public void update( ICacheElement<K, V> item, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( item, requesterId, ICacheEventLogger.UPDATE_EVENT );
+ ICacheEvent<ICacheElement<K, V>> cacheEvent = createICacheEvent( item, requesterId, ICacheEventLogger.UPDATE_EVENT );
try
{
processUpdate( item, requesterId );
@@ -262,7 +260,7 @@ public class RemoteCacheServer
* @param item
* @param requesterId
*/
- private void processUpdate( ICacheElement item, long requesterId )
+ private void processUpdate( ICacheElement<K, V> item, long requesterId )
{
long start = 0;
if ( timing )
@@ -274,7 +272,7 @@ public class RemoteCacheServer
try
{
- CacheListeners cacheDesc = getCacheListeners( item.getCacheName() );
+ CacheListeners<K, V> cacheDesc = getCacheListeners( item.getCacheName() );
/* Object val = */item.getVal();
boolean fromCluster = isRequestFromCluster( requesterId );
@@ -289,7 +287,7 @@ public class RemoteCacheServer
{
try
{
- CompositeCache c = (CompositeCache) cacheDesc.cache;
+ CompositeCache<K, V> c = (CompositeCache<K, V>) cacheDesc.cache;
// If the source of this request was not from a cluster,
// then consider it a local update. The cache manager will
@@ -338,7 +336,7 @@ public class RemoteCacheServer
// IF LOCAL CLUSTER CONSISTENCY IS CONFIGURED
if ( !fromCluster || ( fromCluster && remoteCacheServerAttributes.getLocalClusterConsistency() ) )
{
- ICacheEventQueue[] qlist = getEventQList( cacheDesc, requesterId );
+ ICacheEventQueue<K, V>[] qlist = getEventQList( cacheDesc, requesterId );
if ( qlist != null )
{
@@ -388,7 +386,7 @@ public class RemoteCacheServer
* <p>
* @param item
*/
- private void logUpdateInfo( ICacheElement item )
+ private void logUpdateInfo( ICacheElement<K, V> item )
{
if ( log.isInfoEnabled() )
{
@@ -415,7 +413,7 @@ public class RemoteCacheServer
* @return ICacheElement
* @throws IOException
*/
- public ICacheElement get( String cacheName, Serializable key )
+ public ICacheElement<K, V> get( String cacheName, K key )
throws IOException
{
return this.get( cacheName, key, 0 );
@@ -434,11 +432,11 @@ public class RemoteCacheServer
* @return ICacheElement
* @throws IOException
*/
- public ICacheElement get( String cacheName, Serializable key, long requesterId )
+ public ICacheElement<K, V> get( String cacheName, K key, long requesterId )
throws IOException
{
- ICacheElement element = null;
- ICacheEvent cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.GET_EVENT );
+ ICacheElement<K, V> element = null;
+ ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.GET_EVENT );
try
{
element = processGet( cacheName, key, requesterId );
@@ -453,14 +451,14 @@ public class RemoteCacheServer
/**
* Returns a cache bean from the specified cache; or null if the key does not exist.
* <p>
- * Adding the requestor id, allows the cache to determine the source of the get.
+ * Adding the requester id, allows the cache to determine the source of the get.
* <p>
* @param cacheName
* @param key
* @param requesterId
* @return ICacheElement
*/
- private ICacheElement processGet( String cacheName, Serializable key, long requesterId )
+ private ICacheElement<K, V> processGet( String cacheName, K key, long requesterId )
{
boolean fromCluster = isRequestFromCluster( requesterId );
@@ -470,7 +468,7 @@ public class RemoteCacheServer
+ "] fromCluster = " + fromCluster );
}
- CacheListeners cacheDesc = null;
+ CacheListeners<K, V> cacheDesc = null;
try
{
cacheDesc = getCacheListeners( cacheName );
@@ -486,7 +484,7 @@ public class RemoteCacheServer
}
}
- ICacheElement element = null;
+ ICacheElement<K, V> element = null;
element = getFromCacheListeners( key, fromCluster, cacheDesc, element );
return element;
@@ -501,12 +499,12 @@ public class RemoteCacheServer
* @param element
* @return ICacheElement
*/
- private ICacheElement getFromCacheListeners( Serializable key, boolean fromCluster, CacheListeners cacheDesc,
- ICacheElement element )
+ private ICacheElement<K, V> getFromCacheListeners( K key, boolean fromCluster, CacheListeners<K, V> cacheDesc,
+ ICacheElement<K, V> element )
{
if ( cacheDesc != null )
{
- CompositeCache c = (CompositeCache) cacheDesc.cache;
+ CompositeCache<K, V> c = (CompositeCache<K, V>) cacheDesc.cache;
// If we have a get come in from a client and we don't have the item
// locally, we will allow the cache to look in other non local sources,
@@ -556,7 +554,7 @@ public class RemoteCacheServer
* @return Map of keys and wrapped objects
* @throws IOException
*/
- public Map<Serializable, ICacheElement> getMatching( String cacheName, String pattern )
+ public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern )
throws IOException
{
return getMatching( cacheName, pattern, 0 );
@@ -571,10 +569,10 @@ public class RemoteCacheServer
* @return Map of keys and wrapped objects
* @throws IOException
*/
- public Map<Serializable, ICacheElement> getMatching( String cacheName, String pattern, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, pattern, requesterId,
+ ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, pattern, requesterId,
ICacheEventLogger.GETMATCHING_EVENT );
try
{
@@ -594,7 +592,7 @@ public class RemoteCacheServer
* @param requesterId
* @return Map of keys and wrapped objects
*/
- protected Map<Serializable, ICacheElement> processGetMatching( String cacheName, String pattern, long requesterId )
+ protected Map<K, ICacheElement<K, V>> processGetMatching( String cacheName, String pattern, long requesterId )
{
boolean fromCluster = isRequestFromCluster( requesterId );
@@ -604,7 +602,7 @@ public class RemoteCacheServer
+ "] fromCluster = " + fromCluster );
}
- CacheListeners cacheDesc = null;
+ CacheListeners<K, V> cacheDesc = null;
try
{
cacheDesc = getCacheListeners( cacheName );
@@ -631,12 +629,12 @@ public class RemoteCacheServer
* @param cacheDesc
* @return Map of keys to results
*/
- private Map<Serializable, ICacheElement> getMatchingFromCacheListeners( String pattern, boolean fromCluster, CacheListeners cacheDesc )
+ private Map<K, ICacheElement<K, V>> getMatchingFromCacheListeners( String pattern, boolean fromCluster, CacheListeners<K, V> cacheDesc )
{
- Map<Serializable, ICacheElement> elements = null;
+ Map<K, ICacheElement<K, V>> elements = null;
if ( cacheDesc != null )
{
- CompositeCache c = (CompositeCache) cacheDesc.cache;
+ CompositeCache<K, V> c = (CompositeCache<K, V>) cacheDesc.cache;
// We always want to go remote and then merge the items. But this can lead to inconsistencies after
// failover recovery. Removed items may show up. There is no good way to prevent this.
@@ -673,11 +671,11 @@ public class RemoteCacheServer
* <p>
* @param cacheName
* @param keys
- * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+ * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
* data in cache for any of these keys
* @throws IOException
*/
- public Map<Serializable, ICacheElement> getMultiple( String cacheName, Set<Serializable> keys )
+ public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys )
throws IOException
{
return this.getMultiple( cacheName, keys, 0 );
@@ -691,14 +689,14 @@ public class RemoteCacheServer
* @param cacheName
* @param keys
* @param requesterId
- * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+ * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
* data in cache for any of these keys
* @throws IOException
*/
- public Map<Serializable, ICacheElement> getMultiple( String cacheName, Set<Serializable> keys, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, (Serializable) keys, requesterId,
+ ICacheEvent<Serializable> cacheEvent = createICacheEvent( cacheName, (Serializable) keys, requesterId,
ICacheEventLogger.GETMULTIPLE_EVENT );
try
{
@@ -716,12 +714,12 @@ public class RemoteCacheServer
* @param cacheName
* @param keys
* @param requesterId
- * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+ * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
* data in cache for any of these keys
*/
- private Map<Serializable, ICacheElement> processGetMultiple( String cacheName, Set<Serializable> keys, long requesterId )
+ private Map<K, ICacheElement<K, V>> processGetMultiple( String cacheName, Set<K> keys, long requesterId )
{
- Map<Serializable, ICacheElement> elements = null;
+ Map<K, ICacheElement<K, V>> elements = null;
boolean fromCluster = isRequestFromCluster( requesterId );
@@ -731,7 +729,7 @@ public class RemoteCacheServer
+ "] fromCluster = " + fromCluster );
}
- CacheListeners cacheDesc = null;
+ CacheListeners<K, V> cacheDesc = null;
try
{
cacheDesc = getCacheListeners( cacheName );
@@ -774,11 +772,11 @@ public class RemoteCacheServer
* @param cacheDesc
* @return Map
*/
- private Map<Serializable, ICacheElement> getMultipleFromCacheListeners( Set<Serializable> keys, Map<Serializable, ICacheElement> elements, boolean fromCluster, CacheListeners cacheDesc )
+ private Map<K, ICacheElement<K, V>> getMultipleFromCacheListeners( Set<K> keys, Map<K, ICacheElement<K, V>> elements, boolean fromCluster, CacheListeners<K, V> cacheDesc )
{
if ( cacheDesc != null )
{
- CompositeCache c = (CompositeCache) cacheDesc.cache;
+ CompositeCache<K, V> c = (CompositeCache<K, V>) cacheDesc.cache;
// If we have a getMultiple come in from a client and we don't have the item
// locally, we will allow the cache to look in other non local sources,
@@ -829,7 +827,7 @@ public class RemoteCacheServer
* @param group
* @return A Set of group keys
*/
- public Set<Serializable> getGroupKeys( String cacheName, String group )
+ public Set<K> getGroupKeys( String cacheName, String group )
{
return processGetGroupKeys( cacheName, group );
}
@@ -841,9 +839,9 @@ public class RemoteCacheServer
* @param group
* @return Set
*/
- protected Set<Serializable> processGetGroupKeys( String cacheName, String group )
+ protected Set<K> processGetGroupKeys( String cacheName, String group )
{
- CacheListeners cacheDesc = null;
+ CacheListeners<K, V> cacheDesc = null;
try
{
cacheDesc = getCacheListeners( cacheName );
@@ -858,7 +856,7 @@ public class RemoteCacheServer
return Collections.emptySet();
}
- CompositeCache c = (CompositeCache) cacheDesc.cache;
+ CompositeCache<K, V> c = (CompositeCache<K, V>) cacheDesc.cache;
return c.getGroupKeys( group );
}
@@ -869,7 +867,7 @@ public class RemoteCacheServer
* @param key
* @throws IOException
*/
- public void remove( String cacheName, Serializable key )
+ public void remove( String cacheName, K key )
throws IOException
{
remove( cacheName, key, 0 );
@@ -885,10 +883,10 @@ public class RemoteCacheServer
* @param requesterId
* @throws IOException
*/
- public void remove( String cacheName, Serializable key, long requesterId )
+ public void remove( String cacheName, K key, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.REMOVE_EVENT );
+ ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.REMOVE_EVENT );
try
{
processRemove( cacheName, key, requesterId );
@@ -907,7 +905,7 @@ public class RemoteCacheServer
* @param requesterId
* @throws IOException
*/
- private void processRemove( String cacheName, Serializable key, long requesterId )
+ private void processRemove( String cacheName, K key, long requesterId )
throws IOException
{
if ( log.isDebugEnabled() )
@@ -915,7 +913,7 @@ public class RemoteCacheServer
log.debug( "remove [" + key + "] from cache [" + cacheName + "]" );
}
- CacheListeners cacheDesc = cacheListenersMap.get( cacheName );
+ CacheListeners<K, V> cacheDesc = cacheListenersMap.get( cacheName );
boolean fromCluster = isRequestFromCluster( requesterId );
@@ -928,7 +926,7 @@ public class RemoteCacheServer
boolean removeSuccess = false;
// No need to notify if it was not cached.
- CompositeCache c = (CompositeCache) cacheDesc.cache;
+ CompositeCache<K, V> c = (CompositeCache<K, V>) cacheDesc.cache;
if ( fromCluster )
{
@@ -957,7 +955,7 @@ public class RemoteCacheServer
// IF LOCAL CLUSTER CONSISTENCY IS CONFIGURED
if ( !fromCluster || ( fromCluster && remoteCacheServerAttributes.getLocalClusterConsistency() ) )
{
- ICacheEventQueue[] qlist = getEventQList( cacheDesc, requesterId );
+ ICacheEventQueue<K, V>[] qlist = getEventQList( cacheDesc, requesterId );
for ( int i = 0; i < qlist.length; i++ )
{
@@ -992,7 +990,7 @@ public class RemoteCacheServer
public void removeAll( String cacheName, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, "all", requesterId, ICacheEventLogger.REMOVEALL_EVENT );
+ ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "all", requesterId, ICacheEventLogger.REMOVEALL_EVENT );
try
{
processRemoveAll( cacheName, requesterId );
@@ -1013,7 +1011,7 @@ public class RemoteCacheServer
private void processRemoveAll( String cacheName, long requesterId )
throws IOException
{
- CacheListeners cacheDesc = cacheListenersMap.get( cacheName );
+ CacheListeners<K, V> cacheDesc = cacheListenersMap.get( cacheName );
boolean fromCluster = isRequestFromCluster( requesterId );
@@ -1024,7 +1022,7 @@ public class RemoteCacheServer
synchronized ( cacheDesc )
{
// No need to broadcast, or notify if it was not cached.
- CompositeCache c = (CompositeCache) cacheDesc.cache;
+ CompositeCache<K, V> c = (CompositeCache<K, V>) cacheDesc.cache;
if ( fromCluster )
{
@@ -1046,7 +1044,7 @@ public class RemoteCacheServer
// update registered listeners
if ( !fromCluster || ( fromCluster && remoteCacheServerAttributes.getLocalClusterConsistency() ) )
{
- ICacheEventQueue[] qlist = getEventQList( cacheDesc, requesterId );
+ ICacheEventQueue<K, V>[] qlist = getEventQList( cacheDesc, requesterId );
for ( int i = 0; i < qlist.length; i++ )
{
@@ -1089,7 +1087,7 @@ public class RemoteCacheServer
public void dispose( String cacheName, long requesterId )
throws IOException
{
- ICacheEvent cacheEvent = createICacheEvent( cacheName, "none", requesterId, ICacheEventLogger.DISPOSE_EVENT );
+ ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "none", requesterId, ICacheEventLogger.DISPOSE_EVENT );
try
{
processDispose( cacheName, requesterId );
@@ -1113,7 +1111,7 @@ public class RemoteCacheServer
log.info( "Dispose request received from listener [" + requesterId + "]" );
}
- CacheListeners cacheDesc = cacheListenersMap.get( cacheName );
+ CacheListeners<K, V> cacheDesc = cacheListenersMap.get( cacheName );
// this is dangerous
if ( cacheDesc != null )
@@ -1121,7 +1119,7 @@ public class RemoteCacheServer
// best attempt to achieve ordered free-cache-op and notification.
synchronized ( cacheDesc )
{
- ICacheEventQueue[] qlist = getEventQList( cacheDesc, requesterId );
+ ICacheEventQueue<K, V>[] qlist = getEventQList( cacheDesc, requesterId );
for ( int i = 0; i < qlist.length; i++ )
{
@@ -1142,9 +1140,9 @@ public class RemoteCacheServer
{
synchronized ( cacheListenersMap )
{
- for (CacheListeners cacheDesc : cacheListenersMap.values())
+ for (CacheListeners<K, V> cacheDesc : cacheListenersMap.values())
{
- ICacheEventQueue[] qlist = getEventQList( cacheDesc, 0 );
+ ICacheEventQueue<K, V>[] qlist = getEventQList( cacheDesc, 0 );
for ( int i = 0; i < qlist.length; i++ )
{
@@ -1162,9 +1160,9 @@ public class RemoteCacheServer
* @param cacheName
* @return The cacheListeners value
*/
- protected CacheListeners getCacheListeners( String cacheName )
+ protected CacheListeners<K, V> getCacheListeners( String cacheName )
{
- CacheListeners cacheListeners = cacheListenersMap.get( cacheName );
+ CacheListeners<K, V> cacheListeners = cacheListenersMap.get( cacheName );
synchronized ( cacheListenersMap )
{
if ( cacheListeners == null )
@@ -1172,7 +1170,8 @@ public class RemoteCacheServer
cacheListeners = cacheListenersMap.get( cacheName );
if ( cacheListeners == null )
{
- cacheListeners = new CacheListeners( cacheManager.getCache( cacheName ) );
+ CompositeCache<K, V> cache = cacheManager.getCache( cacheName );
+ cacheListeners = new CacheListeners<K, V>( cache );
cacheListenersMap.put( cacheName, cacheListeners );
}
}
@@ -1187,9 +1186,9 @@ public class RemoteCacheServer
* @param cacheName
* @return The clusterListeners value
*/
- protected CacheListeners getClusterListeners( String cacheName )
+ protected CacheListeners<K, V> getClusterListeners( String cacheName )
{
- CacheListeners cacheListeners = clusterListenersMap.get( cacheName );
+ CacheListeners<K, V> cacheListeners = clusterListenersMap.get( cacheName );
synchronized ( clusterListenersMap )
{
if ( cacheListeners == null )
@@ -1197,7 +1196,8 @@ public class RemoteCacheServer
cacheListeners = clusterListenersMap.get( cacheName );
if ( cacheListeners == null )
{
- cacheListeners = new CacheListeners( cacheManager.getCache( cacheName ) );
+ CompositeCache<K, V> cache = cacheManager.getCache( cacheName );
+ cacheListeners = new CacheListeners<K, V>( cache );
clusterListenersMap.put( cacheName, cacheListeners );
}
}
@@ -1217,9 +1217,9 @@ public class RemoteCacheServer
* @param requesterId
* @return The eventQList value
*/
- private ICacheEventQueue[] getEventQList( CacheListeners cacheListeners, long requesterId )
+ private ICacheEventQueue<K, V>[] getEventQList( CacheListeners<K, V> cacheListeners, long requesterId )
{
- ICacheEventQueue[] list = null;
+ ICacheEventQueue<K, V>[] list = null;
synchronized ( cacheListeners.eventQMap )
{
list = cacheListeners.eventQMap.values().toArray( new ICacheEventQueue[0] );
@@ -1228,7 +1228,7 @@ public class RemoteCacheServer
// Set those not qualified to null; Count those qualified.
for ( int i = 0; i < list.length; i++ )
{
- ICacheEventQueue q = list[i];
+ ICacheEventQueue<K, V> q = list[i];
if ( q.isWorking() && q.getListenerId() != requesterId )
{
count++;
@@ -1245,7 +1245,7 @@ public class RemoteCacheServer
}
// Returns only the qualified.
- ICacheEventQueue[] qq = new ICacheEventQueue[count];
+ ICacheEventQueue<K, V>[] qq = new ICacheEventQueue[count];
count = 0;
for ( int i = 0; i < list.length; i++ )
{
@@ -1262,14 +1262,14 @@ public class RemoteCacheServer
* <p>
* @param eventQMap
*/
- private static void cleanupEventQMap( Map<Long, ICacheEventQueue> eventQMap )
+ private static <KK extends Serializable, VV extends Serializable> void cleanupEventQMap( Map<Long, ICacheEventQueue<KK, VV>> eventQMap )
{
synchronized ( eventQMap )
{
- for (Iterator<Map.Entry<Long, ICacheEventQueue>> itr = eventQMap.entrySet().iterator(); itr.hasNext(); )
+ for (Iterator<Map.Entry<Long, ICacheEventQueue<KK, VV>>> itr = eventQMap.entrySet().iterator(); itr.hasNext(); )
{
- Map.Entry<Long, ICacheEventQueue> e = itr.next();
- ICacheEventQueue q = e.getValue();
+ Map.Entry<Long, ICacheEventQueue<KK, VV>> e = itr.next();
+ ICacheEventQueue<KK, VV> q = e.getValue();
// this does not care if the q is alive (i.e. if
// there are active threads; it cares if the queue
@@ -1295,16 +1295,16 @@ public class RemoteCacheServer
* remote calls involved.
* @throws IOException
*/
- public void addCacheListener( String cacheName, ICacheListener listener )
+ public <KK extends Serializable, VV extends Serializable> void addCacheListener( String cacheName, ICacheListener<KK, VV> listener )
throws IOException
{
if ( cacheName == null || listener == null )
{
throw new IllegalArgumentException( "cacheName and listener must not be null" );
}
- CacheListeners cacheListeners;
+ CacheListeners<KK, VV> cacheListeners;
- IRemoteCacheListener ircl = (IRemoteCacheListener) listener;
+ IRemoteCacheListener<KK, VV> ircl = (IRemoteCacheListener<KK, VV>) listener;
String listenerAddress = ircl.getLocalHostAddress();
@@ -1312,14 +1312,14 @@ public class RemoteCacheServer
if ( remoteType == IRemoteCacheAttributes.CLUSTER )
{
log.debug( "adding cluster listener, listenerAddress [" + listenerAddress + "]" );
- cacheListeners = getClusterListeners( cacheName );
+ cacheListeners = (CacheListeners<KK, VV>)getClusterListeners( cacheName );
}
else
{
log.debug( "adding normal listener, listenerAddress [" + listenerAddress + "]" );
- cacheListeners = getCacheListeners( cacheName );
+ cacheListeners = (CacheListeners<KK, VV>)getCacheListeners( cacheName );
}
- Map<Long, ICacheEventQueue> eventQMap = cacheListeners.eventQMap;
+ Map<Long, ICacheEventQueue<KK, VV>> eventQMap = cacheListeners.eventQMap;
cleanupEventQMap( eventQMap );
// synchronized ( listenerId )
@@ -1383,8 +1383,8 @@ public class RemoteCacheServer
}
}
- CacheEventQueueFactory fact = new CacheEventQueueFactory();
- ICacheEventQueue q = fact.createCacheEventQueue( listener, id, cacheName, remoteCacheServerAttributes
+ CacheEventQueueFactory<KK, VV> fact = new CacheEventQueueFactory<KK, VV>();
+ ICacheEventQueue<KK, VV> q = fact.createCacheEventQueue( listener, id, cacheName, remoteCacheServerAttributes
.getEventQueuePoolName(), remoteCacheServerAttributes.getEventQueueType() );
eventQMap.put(Long.valueOf(listener.getListenerId()), q);
@@ -1402,7 +1402,7 @@ public class RemoteCacheServer
* @param listener The feature to be added to the CacheListener attribute
* @throws IOException
*/
- public void addCacheListener( ICacheListener listener )
+ public <KK extends Serializable, VV extends Serializable> void addCacheListener( ICacheListener<KK, VV> listener )
throws IOException
{
for (String cacheName : cacheListenersMap.keySet())
@@ -1424,7 +1424,7 @@ public class RemoteCacheServer
* @param listener
* @throws IOException
*/
- public void removeCacheListener( String cacheName, ICacheListener listener )
+ public <KK extends Serializable, VV extends Serializable> void removeCacheListener( String cacheName, ICacheListener<KK, VV> listener )
throws IOException
{
removeCacheListener( cacheName, listener.getListenerId() );
@@ -1448,7 +1448,7 @@ public class RemoteCacheServer
boolean isClusterListener = isRequestFromCluster( listenerId );
- CacheListeners cacheDesc = null;
+ CacheListeners<K, V> cacheDesc = null;
if ( isClusterListener )
{
@@ -1458,9 +1458,9 @@ public class RemoteCacheServer
{
cacheDesc = getCacheListeners( cacheName );
}
- Map<Long, ICacheEventQueue> eventQMap = cacheDesc.eventQMap;
+ Map<Long, ICacheEventQueue<K, V>> eventQMap = cacheDesc.eventQMap;
cleanupEventQMap( eventQMap );
- ICacheEventQueue q = eventQMap.remove( Long.valueOf( listenerId ) );
+ ICacheEventQueue<K, V> q = eventQMap.remove( Long.valueOf( listenerId ) );
if ( q != null )
{
@@ -1497,7 +1497,7 @@ public class RemoteCacheServer
* @param listener
* @throws IOException
*/
- public void removeCacheListener( ICacheListener listener )
+ public <KK extends Serializable, VV extends Serializable> void removeCacheListener( ICacheListener<KK, VV> listener )
throws IOException
{
for (String cacheName : cacheListenersMap.keySet())
@@ -1606,11 +1606,11 @@ public class RemoteCacheServer
* @param eventName
* @return ICacheEvent
*/
- private ICacheEvent createICacheEvent( ICacheElement item, long requesterId, String eventName )
+ private ICacheEvent<ICacheElement<K, V>> createICacheEvent( ICacheElement<K, V> item, long requesterId, String eventName )
{
if ( cacheEventLogger == null )
{
- return EMPTY_ICACHE_EVENT;
+ return new CacheEvent<ICacheElement<K, V>>();
}
String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger
@@ -1626,11 +1626,11 @@ public class RemoteCacheServer
* @param eventName
* @return ICacheEvent
*/
- private ICacheEvent createICacheEvent( String cacheName, Serializable key, long requesterId, String eventName )
+ private <T extends Serializable> ICacheEvent<T> createICacheEvent( String cacheName, T key, long requesterId, String eventName )
{
if ( cacheEventLogger == null )
{
- return EMPTY_ICACHE_EVENT;
+ return new CacheEvent<T>();
}
String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger.createICacheEvent( "RemoteCacheServer", cacheName, eventName, ipAddress, key );
@@ -1656,7 +1656,7 @@ public class RemoteCacheServer
* <p>
* @param cacheEvent
*/
- protected void logICacheEvent( ICacheEvent cacheEvent )
+ protected <T extends Serializable> void logICacheEvent( ICacheEvent<T> cacheEvent )
{
if ( cacheEventLogger != null )
{
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java Wed May 30 18:14:43 2012
@@ -25,9 +25,9 @@ public class RemoteCacheRequestFactory
* @param requesterId
* @return RemoteHttpCacheRequest
*/
- public static RemoteCacheRequest createGetRequest( String cacheName, Serializable key, long requesterId )
+ public static <K extends Serializable, V extends Serializable> RemoteCacheRequest<K, V> createGetRequest( String cacheName, K key, long requesterId )
{
- RemoteCacheRequest request = new RemoteCacheRequest();
+ RemoteCacheRequest<K, V> request = new RemoteCacheRequest<K, V>();
request.setCacheName( cacheName );
request.setKey( key );
request.setRequesterId( requesterId );
@@ -49,9 +49,9 @@ public class RemoteCacheRequestFactory
* @param requesterId
* @return RemoteHttpCacheRequest
*/
- public static RemoteCacheRequest createGetMatchingRequest( String cacheName, String pattern, long requesterId )
+ public static <K extends Serializable, V extends Serializable> RemoteCacheRequest<K, V> createGetMatchingRequest( String cacheName, String pattern, long requesterId )
{
- RemoteCacheRequest request = new RemoteCacheRequest();
+ RemoteCacheRequest<K, V> request = new RemoteCacheRequest<K, V>();
request.setCacheName( cacheName );
request.setPattern( pattern );
request.setRequesterId( requesterId );
@@ -73,9 +73,9 @@ public class RemoteCacheRequestFactory
* @param requesterId
* @return RemoteHttpCacheRequest
*/
- public static RemoteCacheRequest createGetMultipleRequest( String cacheName, Set<Serializable> keys, long requesterId )
+ public static <K extends Serializable, V extends Serializable> RemoteCacheRequest<K, V> createGetMultipleRequest( String cacheName, Set<K> keys, long requesterId )
{
- RemoteCacheRequest request = new RemoteCacheRequest();
+ RemoteCacheRequest<K, V> request = new RemoteCacheRequest<K, V>();
request.setCacheName( cacheName );
request.setKeySet( keys );
request.setRequesterId( requesterId );
@@ -97,9 +97,9 @@ public class RemoteCacheRequestFactory
* @param requesterId
* @return RemoteHttpCacheRequest
*/
- public static RemoteCacheRequest createRemoveRequest( String cacheName, Serializable key, long requesterId )
+ public static <K extends Serializable, V extends Serializable> RemoteCacheRequest<K, V> createRemoveRequest( String cacheName, K key, long requesterId )
{
- RemoteCacheRequest request = new RemoteCacheRequest();
+ RemoteCacheRequest<K, V> request = new RemoteCacheRequest<K, V>();
request.setCacheName( cacheName );
request.setKey( key );
request.setRequesterId( requesterId );
@@ -121,9 +121,9 @@ public class RemoteCacheRequestFactory
* @param requesterId
* @return RemoteHttpCacheRequest
*/
- public static RemoteCacheRequest createGetGroupKeysRequest( String cacheName, String groupName, long requesterId )
+ public static RemoteCacheRequest<String, String> createGetGroupKeysRequest( String cacheName, String groupName, long requesterId )
{
- RemoteCacheRequest request = new RemoteCacheRequest();
+ RemoteCacheRequest<String, String> request = new RemoteCacheRequest<String, String>();
request.setCacheName( cacheName );
request.setKey( groupName );
request.setRequesterId( requesterId );
@@ -144,9 +144,9 @@ public class RemoteCacheRequestFactory
* @param requesterId
* @return RemoteHttpCacheRequest
*/
- public static RemoteCacheRequest createRemoveAllRequest( String cacheName, long requesterId )
+ public static <K extends Serializable, V extends Serializable> RemoteCacheRequest<K, V> createRemoveAllRequest( String cacheName, long requesterId )
{
- RemoteCacheRequest request = new RemoteCacheRequest();
+ RemoteCacheRequest<K, V> request = new RemoteCacheRequest<K, V>();
request.setCacheName( cacheName );
request.setRequesterId( requesterId );
request.setRequestType( RemoteCacheRequest.REQUEST_TYPE_REMOVE_ALL );
@@ -166,9 +166,9 @@ public class RemoteCacheRequestFactory
* @param requesterId
* @return RemoteHttpCacheRequest
*/
- public static RemoteCacheRequest createDisposeRequest( String cacheName, long requesterId )
+ public static <K extends Serializable, V extends Serializable> RemoteCacheRequest<K, V> createDisposeRequest( String cacheName, long requesterId )
{
- RemoteCacheRequest request = new RemoteCacheRequest();
+ RemoteCacheRequest<K, V> request = new RemoteCacheRequest<K, V>();
request.setCacheName( cacheName );
request.setRequesterId( requesterId );
request.setRequestType( RemoteCacheRequest.REQUEST_TYPE_DISPOSE );
@@ -188,9 +188,9 @@ public class RemoteCacheRequestFactory
* @param requesterId
* @return RemoteHttpCacheRequest
*/
- public static RemoteCacheRequest createUpdateRequest( ICacheElement cacheElement, long requesterId )
+ public static <K extends Serializable, V extends Serializable> RemoteCacheRequest<K, V> createUpdateRequest( ICacheElement<K, V> cacheElement, long requesterId )
{
- RemoteCacheRequest request = new RemoteCacheRequest();
+ RemoteCacheRequest<K, V> request = new RemoteCacheRequest<K, V>();
if ( cacheElement != null )
{
request.setCacheName( cacheElement.getCacheName() );
@@ -218,9 +218,9 @@ public class RemoteCacheRequestFactory
* @param requesterId
* @return RemoteHttpCacheRequest
*/
- public static RemoteCacheRequest createAliveCheckRequest( long requesterId )
+ public static <K extends Serializable, V extends Serializable> RemoteCacheRequest<K, V> createAliveCheckRequest( long requesterId )
{
- RemoteCacheRequest request = new RemoteCacheRequest();
+ RemoteCacheRequest<K, V> request = new RemoteCacheRequest<K, V>();
request.setRequesterId( requesterId );
request.setRequestType( RemoteCacheRequest.REQUEST_TYPE_ALIVE_CHECK );
Propchange: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java
('svn:mergeinfo' removed)
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheRequest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheRequest.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheRequest.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheRequest.java Wed May 30 18:14:43 2012
@@ -8,10 +8,10 @@ import org.apache.jcs.engine.behavior.IC
/**
* The basic request wrapper. The different types of requests are differentiated by their types.
* <p>
- * Rather than creating sub object types, I created on object thsat has values for all types of
+ * Rather than creating sub object types, I created on object that has values for all types of
* requests.
*/
-public class RemoteCacheRequest
+public class RemoteCacheRequest<K extends Serializable, V extends Serializable>
implements Serializable
{
/** Don't change. */
@@ -54,16 +54,16 @@ public class RemoteCacheRequest
private String cacheName;
/** The key, if this request has a key. */
- private Serializable key;
+ private K key;
/** The keySet, if this request has a keySet. Only getMultiple requests. */
- private Set<Serializable> keySet;
+ private Set<K> keySet;
/** The pattern, if this request uses a pattern. Only getMatching requests. */
private String pattern;
/** The ICacheEleemnt, if this request contains a value. Only update requests will have this. */
- private ICacheElement cacheElement;
+ private ICacheElement<K, V> cacheElement;
/**
* @param requestType the requestType to set
@@ -100,7 +100,7 @@ public class RemoteCacheRequest
/**
* @param key the key to set
*/
- public void setKey( Serializable key )
+ public void setKey( K key )
{
this.key = key;
}
@@ -108,7 +108,7 @@ public class RemoteCacheRequest
/**
* @return the key
*/
- public Serializable getKey()
+ public K getKey()
{
return key;
}
@@ -132,7 +132,7 @@ public class RemoteCacheRequest
/**
* @param cacheElement the cacheElement to set
*/
- public void setCacheElement( ICacheElement cacheElement )
+ public void setCacheElement( ICacheElement<K, V> cacheElement )
{
this.cacheElement = cacheElement;
}
@@ -140,7 +140,7 @@ public class RemoteCacheRequest
/**
* @return the cacheElement
*/
- public ICacheElement getCacheElement()
+ public ICacheElement<K, V> getCacheElement()
{
return cacheElement;
}
@@ -164,7 +164,7 @@ public class RemoteCacheRequest
/**
* @param keySet the keySet to set
*/
- public void setKeySet( Set<Serializable> keySet )
+ public void setKeySet( Set<K> keySet )
{
this.keySet = keySet;
}
@@ -172,7 +172,7 @@ public class RemoteCacheRequest
/**
* @return the keySet
*/
- public Set<Serializable> getKeySet()
+ public Set<K> getKeySet()
{
return keySet;
}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheRequest.java
('svn:mergeinfo' removed)
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheResponse.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheResponse.java?rev=1344374&r1=1344373&r2=1344374&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheResponse.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheResponse.java Wed May 30 18:14:43 2012
@@ -4,11 +4,13 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import org.apache.jcs.engine.behavior.ICacheElement;
+
/**
* This is the response wrapper. The servlet wraps all different type of responses in one of these
* objects.
*/
-public class RemoteCacheResponse
+public class RemoteCacheResponse<K extends Serializable, V extends Serializable>
implements Serializable
{
/** Don't change. */
@@ -21,10 +23,10 @@ public class RemoteCacheResponse
private String errorMessage;
/**
- * The payload. Typically a key / ICacheElement map. A normal get will return a map with one
+ * The payload. Typically a key / ICacheElement<K, V> map. A normal get will return a map with one
* record.
*/
- private Map<Serializable, ? super Object> payload = new HashMap<Serializable, Object>();
+ private Map<K, ICacheElement<K, V>> payload = new HashMap<K, ICacheElement<K,V>>();
/**
* @param success the success to set
@@ -61,7 +63,7 @@ public class RemoteCacheResponse
/**
* @param payload the payload to set
*/
- public void setPayload( Map<Serializable, ? super Object> payload )
+ public void setPayload( Map<K, ICacheElement<K, V>> payload )
{
this.payload = payload;
}
@@ -69,7 +71,7 @@ public class RemoteCacheResponse
/**
* @return the payload
*/
- public Map<Serializable, ? super Object> getPayload()
+ public Map<K, ICacheElement<K, V>> getPayload()
{
return payload;
}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/value/RemoteCacheResponse.java
('svn:mergeinfo' removed)