Author: nfilotto
Date: 2011-11-02 12:40:39 -0400 (Wed, 02 Nov 2011)
New Revision: 5153
Modified:
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
Log:
EXOJCR-1616: Don't use anonymous inner classes when it will be accessed by
java-reflection
Modified:
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
===================================================================
---
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java 2011-11-02
16:18:34 UTC (rev 5152)
+++
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java 2011-11-02
16:40:39 UTC (rev 5153)
@@ -27,6 +27,7 @@
import org.exoplatform.services.cache.impl.jboss.AbstractExoCacheCreator;
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
+import org.jboss.cache.eviction.FIFOAlgorithm;
import org.jboss.cache.eviction.FIFOAlgorithmConfig;
import java.io.Serializable;
@@ -90,35 +91,49 @@
final FIFOAlgorithmConfig fifo = new FIFOAlgorithmConfig(maxNodes);
fifo.setMinTimeToLive(minTimeToLive);
Fqn<String> rooFqn = addEvictionRegion(config, cache, fifo);
- return new AbstractExoCache<Serializable, Object>(config, cache, rooFqn)
+ return new FIFOExoCache(config, cache, rooFqn, fifo);
+ }
+
+
+ /**
+ * The {@link FIFOAlgorithm} implementation of an ExoCache
+ */
+ public static class FIFOExoCache extends AbstractExoCache<Serializable, Object>
+ {
+
+ private final FIFOAlgorithmConfig fifo;
+
+ public FIFOExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache,
Fqn<String> rootFqn, FIFOAlgorithmConfig fifo)
{
+ super(config, cache, rootFqn);
+ this.fifo = fifo;
+ }
- public void setMaxSize(int max)
- {
- fifo.setMaxNodes(max);
- }
+ public void setMaxSize(int max)
+ {
+ fifo.setMaxNodes(max);
+ }
- public void setLiveTime(long period)
- {
- fifo.setMinTimeToLive(period);
- }
+ public void setLiveTime(long period)
+ {
+ fifo.setMinTimeToLive(period);
+ }
- @ManagedName("MaxNodes")
- @ManagedDescription("This is the maximum number of nodes allowed in this
region. " +
- "0 denotes immediate expiry, -1 denotes no limit.")
- public int getMaxSize()
- {
- return fifo.getMaxNodes();
- }
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this
region. " +
+ "0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return fifo.getMaxNodes();
+ }
- @ManagedName("MinTimeToLive")
- @ManagedDescription("the minimum amount of time a node must be allowed to
live after " +
- "being accessed before it is allowed to be considered for eviction. 0
denotes that " +
- "this feature is disabled, which is the default value.")
- public long getLiveTime()
- {
- return fifo.getMinTimeToLive();
- }
- };
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time a node must be allowed to live
after " +
+ "being accessed before it is allowed to be considered for eviction. 0
denotes that " +
+ "this feature is disabled, which is the default value.")
+ public long getLiveTime()
+ {
+ return fifo.getMinTimeToLive();
+ }
}
}
Modified:
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
===================================================================
---
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java 2011-11-02
16:18:34 UTC (rev 5152)
+++
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java 2011-11-02
16:40:39 UTC (rev 5153)
@@ -74,36 +74,7 @@
final MRUAlgorithmConfig mru = new MRUAlgorithmConfig(maxNodes);
mru.setMinTimeToLive(minTimeToLive);
Fqn<String> rooFqn = addEvictionRegion(config, cache, mru);
- return new AbstractExoCache<Serializable, Object>(config, cache, rooFqn)
- {
-
- public void setMaxSize(int max)
- {
- mru.setMaxNodes(max);
- }
-
- public void setLiveTime(long period)
- {
- mru.setMinTimeToLive(period);
- }
-
- @ManagedName("MaxNodes")
- @ManagedDescription("This is the maximum number of nodes allowed in this
region. " +
- "0 denotes immediate expiry, -1 denotes no limit.")
- public int getMaxSize()
- {
- return mru.getMaxNodes();
- }
-
- @ManagedName("MinTimeToLive")
- @ManagedDescription("the minimum amount of time a node must be allowed to
live after " +
- "being accessed before it is allowed to be considered for eviction.
" +
- "0 denotes that this feature is disabled, which is the default
value.")
- public long getLiveTime()
- {
- return mru.getMinTimeToLive();
- }
- };
+ return new MRUExoCache(config, cache, rooFqn, mru);
}
/**
@@ -121,4 +92,47 @@
{
return EXPECTED_IMPL;
}
+
+ /**
+ * The MRU implementation of an ExoCache
+ */
+ public static class MRUExoCache extends AbstractExoCache<Serializable, Object>
+ {
+
+ private final MRUAlgorithmConfig mru;
+
+ public MRUExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache,
Fqn<String> rooFqn,
+ MRUAlgorithmConfig mru)
+ {
+ super(config, cache, rooFqn);
+ this.mru = mru;
+ }
+
+ public void setMaxSize(int max)
+ {
+ mru.setMaxNodes(max);
+ }
+
+ public void setLiveTime(long period)
+ {
+ mru.setMinTimeToLive(period);
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this
region. "
+ + "0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return mru.getMaxNodes();
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time a node must be allowed to live
after "
+ + "being accessed before it is allowed to be considered for eviction.
"
+ + "0 denotes that this feature is disabled, which is the default
value.")
+ public long getLiveTime()
+ {
+ return mru.getMinTimeToLive();
+ }
+ }
}