From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: 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 --- source/com/c2kernel/entity/CorbaServer.java | 45 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'source/com/c2kernel/entity/CorbaServer.java') 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(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; - + } } -- cgit v1.2.3