From 58463add2582dc438e6abe7b6f502a655232a709 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 22 Jul 2014 15:08:55 +0200 Subject: Close all gateway singletons properly, adding close method to NextKeyManager, and leave the Gateway in a state where it can be reused with another init() call. --- .../com/c2kernel/persistency/NextKeyManager.java | 5 +++++ src/main/java/com/c2kernel/process/Gateway.java | 20 +++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/com/c2kernel/persistency/NextKeyManager.java b/src/main/java/com/c2kernel/persistency/NextKeyManager.java index 48fa5af..1352405 100644 --- a/src/main/java/com/c2kernel/persistency/NextKeyManager.java +++ b/src/main/java/com/c2kernel/persistency/NextKeyManager.java @@ -43,4 +43,9 @@ public interface NextKeyManager { * @throws ObjectNotFoundException */ public ItemPath getLastEntityPath() throws ObjectNotFoundException; + + /** + * Shuts down the next key manager + */ + public void close(); } diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 7a040ac..adbaeb6 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -99,6 +99,7 @@ public class Gateway // Init properties & resources mC2KProps = new ObjectProperties(); + orbDestroyed = false; mResource = res; if (mResource == null) mResource = new Resource(); @@ -178,6 +179,7 @@ public class Gateway mC2KProps.put("com.sun.CORBA.codeset.charsets", "0x05010001, 0x00010109"); // need to force UTF-8 in the Sun ORB mC2KProps.put("com.sun.CORBA.codeset.wcharsets", "0x00010109, 0x05010001"); //Standard initialisation of the ORB + orbDestroyed = false; mORB = org.omg.CORBA.ORB.init(new String[0], mC2KProps); Logger.msg("Gateway.init() - ORB initialised. ORB is " + mORB.getClass().getName() ); @@ -286,6 +288,11 @@ public class Gateway mCorbaServer.close(); mCorbaServer = null; + // close next key manager + if (mNextKeyManager != null) + mNextKeyManager.close(); + mNextKeyManager = null; + // disconnect from storages if (mStorage != null) mStorage.close(); @@ -295,14 +302,15 @@ public class Gateway if (mLookup != null) mLookup.close(); mLookup = null; + mLookupManager = null; // shut down proxy manager & server - if (mProxyServer != null) - mProxyServer.shutdownServer(); if (mProxyManager != null) mProxyManager.shutdown(); + if (mProxyServer != null) + mProxyServer.shutdownServer(); mProxyManager = null; - + mProxyServer = null; // close log consoles Logger.closeConsole(); @@ -312,6 +320,12 @@ public class Gateway getORB().destroy(); orbDestroyed = true; } + + // clean up remaining objects + mModules = null; + mResource = null; + mMarshaller = null; + mC2KProps = null; } static public org.omg.CORBA.ORB getORB() -- cgit v1.2.3