summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/utils/ActDefCache.java
diff options
context:
space:
mode:
authorabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
committerabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
commit0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch)
tree5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/utils/ActDefCache.java
parent036cbdba66f804743c4c838ed598d6972c4b3e17 (diff)
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
Diffstat (limited to 'source/com/c2kernel/utils/ActDefCache.java')
-rw-r--r--source/com/c2kernel/utils/ActDefCache.java33
1 files changed, 21 insertions, 12 deletions
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<String, ActCacheEntry> actCache = new SoftCache<String, ActCacheEntry>();
-
+
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<Viewpoint> {
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<Viewpoint>(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