Picketlink SVN: r896 - idm/branches/1.1.0/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache.
by picketlink-commits@lists.jboss.org
Author: bdaw
Date: 2011-04-20 18:26:35 -0400 (Wed, 20 Apr 2011)
New Revision: 896
Modified:
idm/branches/1.1.0/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAPICacheProviderImpl.java
idm/branches/1.1.0/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java
Log:
- set expiration time for JBoss Cache
Modified: idm/branches/1.1.0/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAPICacheProviderImpl.java
===================================================================
--- idm/branches/1.1.0/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAPICacheProviderImpl.java 2011-04-18 16:45:33 UTC (rev 895)
+++ idm/branches/1.1.0/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAPICacheProviderImpl.java 2011-04-20 22:26:35 UTC (rev 896)
@@ -29,6 +29,7 @@
import org.picketlink.idm.api.query.RoleQuery;
import org.picketlink.idm.impl.api.model.GroupKey;
import org.jboss.cache.*;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
import java.io.InputStream;
import java.util.List;
@@ -112,6 +113,8 @@
public static final String MAIN_ROOT = "NODE_MAIN_ROOT";
+ private int expiration = -1;
+
private Fqn getRootNode()
{
return Fqn.fromString("/" + MAIN_ROOT);
@@ -258,6 +261,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, user);
if (log.isLoggable(Level.FINER))
@@ -308,6 +312,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(users));
if (log.isLoggable(Level.FINER))
@@ -362,6 +367,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, count);
if (log.isLoggable(Level.FINER))
@@ -414,6 +420,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, group);
if (log.isLoggable(Level.FINER))
@@ -465,6 +472,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(groups));
if (log.isLoggable(Level.FINER))
@@ -518,6 +526,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, count);
if (log.isLoggable(Level.FINER))
@@ -572,6 +581,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, role);
if (log.isLoggable(Level.FINER))
@@ -616,6 +626,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, role);
if (log.isLoggable(Level.FINER))
@@ -659,6 +670,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableMap(attributes));
if (log.isLoggable(Level.FINER))
@@ -717,6 +729,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableMap(properties));
if (log.isLoggable(Level.FINER))
@@ -775,6 +788,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableMap(properties));
if (log.isLoggable(Level.FINER))
@@ -851,6 +865,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -891,6 +906,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -929,6 +945,7 @@
if (ioNode == null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, result);
if (log.isLoggable(Level.FINER))
@@ -967,6 +984,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -1005,6 +1023,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -1055,6 +1074,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_KEY, results);
if (log.isLoggable(Level.FINER))
@@ -1073,6 +1093,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_UNIQUE_KEY, user);
if (log.isLoggable(Level.FINER))
@@ -1143,6 +1164,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -1161,6 +1183,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_UNIQUE_KEY, group);
if (log.isLoggable(Level.FINER))
@@ -1231,6 +1254,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_KEY, results);
if (log.isLoggable(Level.FINER))
@@ -1249,6 +1273,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_UNIQUE_KEY, role);
if (log.isLoggable(Level.FINER))
@@ -1332,4 +1357,23 @@
return Collections.unmodifiableCollection(collection);
}
+
+ public void setExpiration(Node node)
+ {
+ if (expiration != -1 && expiration > 0)
+ {
+ Long future = new Long(System.currentTimeMillis() + expiration);
+ node.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+ }
+ }
+
+ public int getExpiration()
+ {
+ return expiration;
+ }
+
+ public void setExpiration(int expiration)
+ {
+ this.expiration = expiration;
+ }
}
Modified: idm/branches/1.1.0/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java
===================================================================
--- idm/branches/1.1.0/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java 2011-04-18 16:45:33 UTC (rev 895)
+++ idm/branches/1.1.0/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java 2011-04-20 22:26:35 UTC (rev 896)
@@ -23,6 +23,7 @@
package org.picketlink.idm.impl.cache;
import org.jboss.cache.*;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
import org.picketlink.idm.spi.configuration.IdentityConfigurationContext;
import org.picketlink.idm.spi.model.IdentityObject;
@@ -91,6 +92,8 @@
public static final String MAIN_ROOT = "NODE_MAIN_ROOT";
+ private int expiration = -1;
+
private Fqn getRootNode()
{
return Fqn.fromString("/" + MAIN_ROOT);
@@ -248,6 +251,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, count);
if (log.isLoggable(Level.FINER))
@@ -303,6 +307,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, safeCopyIO(results));
if (log.isLoggable(Level.FINER))
@@ -352,6 +357,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, safeCopyIOR(results));
if (log.isLoggable(Level.FINER))
@@ -401,6 +407,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, results);
if (log.isLoggable(Level.FINER))
@@ -450,6 +457,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, properties);
if (log.isLoggable(Level.FINER))
@@ -518,6 +526,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, properties);
if (log.isLoggable(Level.FINER))
@@ -579,6 +588,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, safeCopyAttr(attributes));
if (log.isLoggable(Level.FINER))
@@ -637,6 +647,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, value);
if (log.isLoggable(Level.FINER))
@@ -729,5 +740,23 @@
return nr;
}
+ public void setExpiration(Node node)
+ {
+ if (expiration != -1 && expiration > 0)
+ {
+ Long future = new Long(System.currentTimeMillis() + expiration);
+ node.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+ }
+ }
+ public int getExpiration()
+ {
+ return expiration;
+ }
+
+ public void setExpiration(int expiration)
+ {
+ this.expiration = expiration;
+ }
+
}