Author: julien_viet
Date: 2011-09-07 13:32:17 -0400 (Wed, 07 Sep 2011)
New Revision: 7333
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationData.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/SimpleDataCache.java
Log:
GTNPORTAL-2086 : Proper serialization for navigation cache
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationData.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationData.java 2011-09-07
17:30:31 UTC (rev 7332)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/NavigationData.java 2011-09-07
17:32:17 UTC (rev 7333)
@@ -69,4 +69,16 @@
this.state = state;
this.rootId = rootId;
}
+
+ protected Object readResolve()
+ {
+ if (key == null && state == null && rootId == null)
+ {
+ return EMPTY;
+ }
+ else
+ {
+ return this;
+ }
+ }
}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/SimpleDataCache.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/SimpleDataCache.java 2011-09-07
17:30:31 UTC (rev 7332)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/navigation/SimpleDataCache.java 2011-09-07
17:32:17 UTC (rev 7333)
@@ -19,6 +19,7 @@
package org.exoplatform.portal.mop.navigation;
+import org.exoplatform.commons.serialization.MarshalledObject;
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.pom.config.POMSession;
@@ -35,57 +36,78 @@
{
/** . */
- protected Map<SiteKey, NavigationData> navigations;
+ protected Map<MarshalledObject<SiteKey>,
MarshalledObject<NavigationData>> navigations;
/** . */
- protected Map<String, NodeData> nodes;
+ protected Map<MarshalledObject<String>, MarshalledObject<NodeData>>
nodes;
public SimpleDataCache()
{
- this.navigations = new ConcurrentHashMap<SiteKey, NavigationData>();
- this.nodes = new ConcurrentHashMap<String, NodeData>();
+ this.navigations = new ConcurrentHashMap<MarshalledObject<SiteKey>,
MarshalledObject<NavigationData>>();
+ this.nodes = new ConcurrentHashMap<MarshalledObject<String>,
MarshalledObject<NodeData>>();
}
@Override
protected void removeNodes(Collection<String> keys)
{
- nodes.keySet().removeAll(keys);
+ for (String key : keys)
+ {
+ nodes.remove(MarshalledObject.marshall(key));
+ }
}
@Override
protected NodeData getNode(POMSession session, String key)
{
- NodeData node = nodes.get(key);
- if (node == null)
+ MarshalledObject<String> marshalledKey = MarshalledObject.marshall(key);
+ MarshalledObject<NodeData> marshalledNode = nodes.get(marshalledKey);
+ if (marshalledNode == null)
{
- node = loadNode(session, key);
+ NodeData node = loadNode(session, key);
if (node != null)
{
- nodes.put(key, node);
+ nodes.put(marshalledKey, MarshalledObject.marshall(node));
+ return node;
}
+ else
+ {
+ return null;
+ }
}
- return node;
+ else
+ {
+ return marshalledNode.unmarshall();
+ }
}
@Override
protected void removeNavigation(SiteKey key)
{
- navigations.remove(key);
+ navigations.remove(MarshalledObject.marshall(key));
}
@Override
protected NavigationData getNavigation(POMSession session, SiteKey key)
{
- NavigationData navigation = navigations.get(key);
- if (navigation == null)
+ MarshalledObject<SiteKey> marshalledKey = MarshalledObject.marshall(key);
+ MarshalledObject<NavigationData> marshalledNavigation =
navigations.get(marshalledKey);
+ if (marshalledNavigation == null)
{
- navigation = loadNavigation(session, key);
+ NavigationData navigation = loadNavigation(session, key);
if (navigation != null)
{
- navigations.put(key, navigation);
+ navigations.put(marshalledKey, MarshalledObject.marshall(navigation));
+ return navigation;
}
+ else
+ {
+ return null;
+ }
}
- return navigations.get(key);
+ else
+ {
+ return marshalledNavigation.unmarshall();
+ }
}
@Override
Show replies by date