diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
| commit | 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch) | |
| tree | 5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/entity/CorbaServer.java | |
| parent | 036cbdba66f804743c4c838ed598d6972c4b3e17 (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/entity/CorbaServer.java')
| -rw-r--r-- | source/com/c2kernel/entity/CorbaServer.java | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/source/com/c2kernel/entity/CorbaServer.java b/source/com/c2kernel/entity/CorbaServer.java index 883bb1b..84d2ef2 100644 --- a/source/com/c2kernel/entity/CorbaServer.java +++ b/source/com/c2kernel/entity/CorbaServer.java @@ -39,7 +39,7 @@ public class CorbaServer { public CorbaServer() throws InvalidDataException {
mEntityCache = new SoftCache<EntityPath, Servant>(50);
-
+
// init POA
try {
setupPOA();
@@ -48,15 +48,16 @@ public class CorbaServer { Logger.error(ex);
throw new InvalidDataException("Error initialising POA", "");
}
-
+
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
Thread.currentThread().setName("ORB Invoker");
Gateway.getORB().run();
}
}).start();
}
-
+
public void close() {
try {
mPOAManager.deactivate(true, true);
@@ -64,12 +65,12 @@ public class CorbaServer { Logger.error(ex);
}
}
-
+
/**************************************************************************
* Initialises the C2KRootPOA with policies which are suitable for Factory objects
- **************************************************************************/
+ **************************************************************************/
public void setupPOA() throws Exception {
-
+
//Initialise the RootPOA
mRootPOA = org.omg.PortableServer.POAHelper.narrow(
Gateway.getORB().resolve_initial_references("RootPOA"));
@@ -78,8 +79,6 @@ public class CorbaServer { mPOAManager = mRootPOA.the_POAManager();
- org.omg.CORBA.Policy[] poaPolicies;
-
// Create POA for use by the entities
org.omg.CORBA.Policy[] policies = new org.omg.CORBA.Policy[6];
@@ -103,32 +102,32 @@ public class CorbaServer { policies );
mAgentPOA = mRootPOA.create_POA( "Agent",
mRootPOA.the_POAManager(),
- policies );
+ policies );
//Create the locators
TraceableLocator itemLocator = new TraceableLocator( mItemPOA );
- mItemPOA.set_servant_manager( itemLocator._this( Gateway.getORB() ) );
-
+ mItemPOA.set_servant_manager( itemLocator._this( Gateway.getORB() ) );
+
ActiveLocator agentLocator = new ActiveLocator( mAgentPOA );
mAgentPOA.set_servant_manager( agentLocator._this( Gateway.getORB() ) );
-
+
}
-
+
/**************************************************************************
* Returns a CORBA servant for a pre-existing entity
- **************************************************************************/
+ **************************************************************************/
private Servant getEntity(int sysKey, org.omg.PortableServer.POA poa) throws ObjectNotFoundException {
try {
EntityPath entityPath = new EntityPath(sysKey);
Servant entity = null;
synchronized (mEntityCache) {
- entity = (Servant)mEntityCache.get(entityPath);
+ entity = mEntityCache.get(entityPath);
if (entity == null) {
Logger.msg(7, "Creating new servant for "+sysKey);
-
- Class entityClass = Gateway.getLDAPLookup().getEntityClass(entityPath);
-
+
+ Class<?> entityClass = Gateway.getLDAPLookup().getEntityClass(entityPath);
+
if (entityClass == TraceableEntity.class) {
if (poa == null) poa = mItemPOA;
entity = new TraceableEntity(sysKey, poa);
@@ -141,12 +140,12 @@ public class CorbaServer { }
}
return entity;
-
+
} catch (InvalidEntityPathException ex) {
throw new ObjectNotFoundException("Invalid Entity Key", "");
- }
+ }
}
-
+
/**************************************************************************
* Wrapper for fetching Items
**************************************************************************/
@@ -186,6 +185,6 @@ public class CorbaServer { mEntityCache.put(entityPath, entity);
}
return entity;
-
+
}
}
|
