Author: julien_viet
Date: 2011-09-07 13:32:38 -0400 (Wed, 07 Sep 2011)
New Revision: 7334
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/description/CacheValue.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/description/SimpleDataCache.java
Log:
GTNPORTAL-2085 : Proper serialization for description cache
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/description/CacheValue.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/description/CacheValue.java 2011-09-07
17:32:17 UTC (rev 7333)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/description/CacheValue.java 2011-09-07
17:32:38 UTC (rev 7334)
@@ -21,12 +21,13 @@
import org.exoplatform.portal.mop.Described;
+import java.io.Serializable;
import java.util.concurrent.atomic.AtomicLong;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
*/
-public class CacheValue
+public class CacheValue implements Serializable
{
/** . */
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/description/SimpleDataCache.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/description/SimpleDataCache.java 2011-09-07
17:32:17 UTC (rev 7333)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/description/SimpleDataCache.java 2011-09-07
17:32:38 UTC (rev 7334)
@@ -19,6 +19,7 @@
package org.exoplatform.portal.mop.description;
+import org.exoplatform.commons.serialization.MarshalledObject;
import org.exoplatform.portal.mop.Described;
import org.exoplatform.portal.pom.config.POMSession;
@@ -31,33 +32,46 @@
{
/** . */
- private final ConcurrentHashMap<CacheKey, CacheValue> map;
+ private final ConcurrentHashMap<MarshalledObject<CacheKey>,
MarshalledObject<CacheValue>> map;
public SimpleDataCache()
{
- this.map = new ConcurrentHashMap<CacheKey, CacheValue>();
+ this.map = new ConcurrentHashMap<MarshalledObject<CacheKey>,
MarshalledObject<CacheValue>>();
}
@Override
protected Described.State getState(POMSession session, CacheKey key)
{
- CacheValue value = map.get(key);
- if (value == null)
+ MarshalledObject<CacheKey> marshalledKey = MarshalledObject.marshall(key);
+ MarshalledObject<CacheValue> marshalledValue = map.get(marshalledKey);
+ if (marshalledValue == null)
{
- value = getValue(session, key);
+ CacheValue value = getValue(session, key);
+ if (value != null)
+ {
+ map.put(marshalledKey, MarshalledObject.marshall(value));
+ return value.state;
+ }
+ else
+ {
+ return null;
+ }
}
- return value != null ? value.state : null;
+ else
+ {
+ return marshalledValue.unmarshall().state;
+ }
}
@Override
protected void removeState(CacheKey key)
{
- map.remove(key);
+ map.remove(MarshalledObject.marshall(key));
}
@Override
protected void putValue(CacheKey key, CacheValue value)
{
- map.put(key, value);
+ map.put(MarshalledObject.marshall(key), MarshalledObject.marshall(value));
}
}
Show replies by date