summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/entity/CorbaServer.java
diff options
context:
space:
mode:
authorogattaz <olivier@gattaz.com>2014-07-07 10:59:14 +0200
committerogattaz <olivier@gattaz.com>2014-07-07 10:59:14 +0200
commit6772bfb46b72d859c316a9f6573d0c6be477ad5c (patch)
treedafa343584216685e68b6edae37570eb97cf9d0c /src/main/java/com/c2kernel/entity/CorbaServer.java
parent2fd193d7936084de91eae46e8c2763914d87ab71 (diff)
parent0b689a787288f5a4ba568157905c3a0577f83821 (diff)
Merge branch 'master' of ssh://dev.cccs.uwe.ac.uk:22/var/git/cristal-kernel
Diffstat (limited to 'src/main/java/com/c2kernel/entity/CorbaServer.java')
-rw-r--r--src/main/java/com/c2kernel/entity/CorbaServer.java33
1 files changed, 16 insertions, 17 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);
}
/**