summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/utils/ActDefCache.java
diff options
context:
space:
mode:
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