From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: More code cleanup: Refactored Entity Proxy Subscription to handle generics better Rewrote RemoteMap to use TreeMap instead of the internal array for order. It now sorts its keys by number if they parse, else as strings. Removed a no-longer-in-progress outcome form class --- source/com/c2kernel/utils/ActDefCache.java | 33 +++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'source/com/c2kernel/utils/ActDefCache.java') diff --git a/source/com/c2kernel/utils/ActDefCache.java b/source/com/c2kernel/utils/ActDefCache.java index 148d934..2982aa3 100644 --- a/source/com/c2kernel/utils/ActDefCache.java +++ b/source/com/c2kernel/utils/ActDefCache.java @@ -1,26 +1,26 @@ /** - * + * */ package com.c2kernel.utils; import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.proxy.EntityProxyObserver; import com.c2kernel.entity.proxy.ItemProxy; +import com.c2kernel.entity.proxy.MemberSubscription; import com.c2kernel.lifecycle.ActivityDef; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.outcome.Viewpoint; public class ActDefCache { - + SoftCache actCache = new SoftCache(); - + public ActivityDef get(String actName, String actVersion) throws ObjectNotFoundException, InvalidDataException { ActivityDef thisActDef; synchronized(actCache) { - ActCacheEntry thisActDefEntry = ((ActCacheEntry)actCache.get(actName+"_"+actVersion)); + ActCacheEntry thisActDefEntry = actCache.get(actName+"_"+actVersion); if (thisActDefEntry == null) { Logger.msg(6, actName+" v"+actVersion+" not found in cache. Retrieving."); ItemProxy actDefItem = LocalObjectLoader.loadLocalObjectDef("/desc/ActivityDesc/", actName); @@ -50,7 +50,7 @@ public class ActDefCache { } return thisActDef; } - + public void removeAct(String id) { synchronized(actCache) { if (actCache.keySet().contains(id)) { @@ -60,7 +60,7 @@ public class ActDefCache { } } - public class ActCacheEntry implements EntityProxyObserver { + public class ActCacheEntry implements EntityProxyObserver { public String id; public ItemProxy actProxy; public ActivityDef actDef; @@ -70,22 +70,31 @@ public class ActDefCache { this.actDef = actDef; this.parent = parent; this.actProxy = actProxy; - actProxy.subscribe(this, ClusterStorage.VIEWPOINT, false); + actProxy.subscribe(new MemberSubscription(this, ClusterStorage.VIEWPOINT, false)); } + @Override public void finalize() { parent.removeAct(id); actProxy.unsubscribe(this); } - public void add(C2KLocalObject contents) { + @Override + public void add(Viewpoint contents) { parent.removeAct(id); } - + + @Override public void remove(String id) { parent.removeAct(id); } - + + @Override public String toString() { - return "ActDef cache entry: "+id; + return "ActDef cache entry: "+id; + } + @Override + public void control(String control, String msg) { + // TODO Auto-generated method stub + } } } \ No newline at end of file -- cgit v1.2.3