summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-06-12 10:24:01 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-06-23 14:18:26 +0200
commitc45ee34928eaa7d148c60fb520f279362414af5a (patch)
treee211dc522ec8d3eaeda9236d809b189fa4fd01fe
parent94ceb4f38ed0ba171d17076415dc912b469cd7e5 (diff)
Separate PredefinedStepContainers for Agents and Items (and Server Item)
-rw-r--r--src/main/java/com/c2kernel/entity/CorbaServer.java33
-rw-r--r--src/main/java/com/c2kernel/lookup/Lookup.java15
2 files changed, 24 insertions, 24 deletions
diff --git a/src/main/java/com/c2kernel/entity/CorbaServer.java b/src/main/java/com/c2kernel/entity/CorbaServer.java
index 3a01ed7..60c10a8 100644
--- a/src/main/java/com/c2kernel/entity/CorbaServer.java
+++ b/src/main/java/com/c2kernel/entity/CorbaServer.java
@@ -117,29 +117,28 @@ public class CorbaServer {
/**************************************************************************
* Returns a CORBA servant for a pre-existing entity
**************************************************************************/
- private Servant getEntity(int sysKey, org.omg.PortableServer.POA poa) throws ObjectNotFoundException {
+ private Servant getItem(int sysKey, org.omg.PortableServer.POA poa) throws ObjectNotFoundException {
try {
- ItemPath entityPath = new ItemPath(sysKey);
- Servant entity = null;
+ ItemPath itemPath = Gateway.getLookup().getItemPath(sysKey);
+ Servant item = null;
synchronized (mEntityCache) {
- entity = mEntityCache.get(entityPath);
- if (entity == null) {
+ item = mEntityCache.get(itemPath);
+ if (item == null) {
Logger.msg(7, "Creating new servant for "+sysKey);
- Class<?> entityClass = Gateway.getLookup().getItemClass(entityPath);
-
- if (entityClass == TraceableEntity.class) {
- if (poa == null) poa = mItemPOA;
- entity = new TraceableEntity(sysKey, poa);
- }
- else if (entityClass == ActiveEntity.class) {
+ if (itemPath instanceof AgentPath) {
if (poa == null) poa = mAgentPOA;
- entity = new ActiveEntity(sysKey, poa);
+ item = new ActiveEntity(sysKey, poa);
+ }
+ else if (itemPath instanceof ItemPath) {
+ if (poa == null) poa = mItemPOA;
+ item = new TraceableEntity(sysKey, poa);
}
- mEntityCache.put(entityPath, entity);
+
+ mEntityCache.put(itemPath, item);
}
}
- return entity;
+ return item;
} catch (InvalidItemPathException ex) {
throw new ObjectNotFoundException("Invalid Entity Key", "");
@@ -150,14 +149,14 @@ public class CorbaServer {
* Wrapper for fetching Items
**************************************************************************/
public TraceableEntity getItem(int sysKey) throws ObjectNotFoundException {
- return (TraceableEntity)getEntity(sysKey, mItemPOA);
+ return (TraceableEntity)getItem(sysKey, mItemPOA);
}
/**************************************************************************
* Wrapper for fetching Agents
**************************************************************************/
public ActiveEntity getAgent(int sysKey) throws ObjectNotFoundException {
- return (ActiveEntity)getEntity(sysKey, mAgentPOA);
+ return (ActiveEntity)getItem(sysKey, mAgentPOA);
}
/**
diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java
index 5c6d1e9..d71034f 100644
--- a/src/main/java/com/c2kernel/lookup/Lookup.java
+++ b/src/main/java/com/c2kernel/lookup/Lookup.java
@@ -35,15 +35,16 @@ public interface Lookup {
public void close();
// Path resolution
-
/**
- * Decide whether a path references an Item or an Agent, from its directory data
- * @param path The path of the Item or Agent
- * @return TraceableEntity.class or ActiveEntity.class
- * @throws ObjectNotFoundException When the path doesn't exist in the directory
+ * Fetch the correct subclass class of ItemPath for a particular Item, derived from its lookup entry. This is used by Item
+ *
+ * @param sysKey The system key of the Item
+ * @return an ItemPath or AgentPath
+ * @throws InvalidItemPathException When the system key is invalid/out-of-range
+ * @throws ObjectNotFoundException When the Item does not exist in the directory.
*/
- public Class<?> getItemClass(Path path) throws ObjectNotFoundException;
-
+ public ItemPath getItemPath(int sysKey) throws InvalidItemPathException, ObjectNotFoundException;
+
/**
* Find the ItemPath for which a DomainPath is an alias.
*