Modified: river/jtsk/trunk/src/org/apache/river/mercury/MailboxImpl.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/mercury/MailboxImpl.java?rev=1719761&r1=1719760&r2=1719761&view=diff
==============================================================================
--- river/jtsk/trunk/src/org/apache/river/mercury/MailboxImpl.java (original)
+++ river/jtsk/trunk/src/org/apache/river/mercury/MailboxImpl.java Sun Dec 13 
04:43:42 2015
@@ -21,7 +21,6 @@ package org.apache.river.mercury;
 import org.apache.river.config.Config;
 import org.apache.river.constants.TimeConstants;
 import org.apache.river.constants.ThrowableConstants;
-import org.apache.river.landlord.FixedLeasePeriodPolicy;
 import org.apache.river.landlord.LeasedResource;
 import org.apache.river.landlord.LeaseFactory;
 import org.apache.river.landlord.LeasePeriodPolicy;
@@ -44,7 +43,6 @@ import org.apache.river.thread.ReadersWr
 import org.apache.river.thread.ReadyState;
 import org.apache.river.thread.RetryTask;
 import org.apache.river.thread.WakeupManager;
-import net.jini.activation.ActivationExporter;
 import net.jini.config.Configuration;
 import net.jini.config.ConfigurationProvider;
 import net.jini.config.ConfigurationException;
@@ -54,10 +52,6 @@ import net.jini.export.Exporter;
 import net.jini.export.ProxyAccessor;
 import net.jini.id.Uuid;
 import net.jini.id.UuidFactory;
-import net.jini.jeri.BasicILFactory;
-import net.jini.jeri.BasicJeriExporter;
-import net.jini.jeri.tcp.TcpServerEndpoint;
-import net.jini.security.BasicProxyPreparer;
 import net.jini.security.ProxyPreparer;
 import net.jini.security.proxytrust.ServerProxyTrust;
 import net.jini.security.TrustVerifier;
@@ -169,94 +163,94 @@ class MailboxImpl implements MailboxBack
     static final String MERCURY = "org.apache.river.mercury";
 
     /** Logger for lease related messages */
-    static final Logger leaseLogger = 
+    static final Logger LEASE_LOGGER = 
         Logger.getLogger(MERCURY + ".lease");
     
     /** Logger for event delivery related messages */
-    static final Logger deliveryLogger = 
+    static final Logger DELIVERY_LOGGER = 
         Logger.getLogger(MERCURY + ".delivery");
     
     /** Logger for service administration related messages */
-    static final Logger adminLogger = 
+    static final Logger ADMIN_LOGGER = 
         Logger.getLogger(MERCURY + ".admin");
     
     /** Logger for service initialization related messages */
-    static final Logger initLogger = 
+    static final Logger INIT_LOGGER = 
         Logger.getLogger(MERCURY + ".init");
     
     /** Logger for event reception related messages */
-    static final Logger receiveLogger = 
+    static final Logger RECEIVE_LOGGER = 
         Logger.getLogger(MERCURY + ".receive");
     
     /** Logger for lease expiration related messages */
-    static final Logger expirationLogger = 
+    static final Logger EXPIRATION_LOGGER = 
         Logger.getLogger(MERCURY + ".expiration");
     
     /** Logger for service recovery related messages */
-    static final Logger recoveryLogger = 
+    static final Logger RECOVERY_LOGGER = 
         Logger.getLogger(MERCURY + ".recovery");
     
     /** Logger for service persistence related messages */
-    static final Logger persistenceLogger = 
+    static final Logger PERSISTENCE_LOGGER = 
         Logger.getLogger(MERCURY + ".persistence");
     
     /** Logger for (successful) service startup message */
-    static final Logger startupLogger =
+    static final Logger STARTUP_LOGGER =
         Logger.getLogger(MERCURY + ".startup");
    
     /** Logger for service operation messages */
-    static final Logger operationsLogger =
+    static final Logger OPERATIONS_LOGGER =
         Logger.getLogger(MERCURY + ".operations");
 
-    static final String mailboxSourceClass = 
+    static final String MAILBOX_SOURCE_CLASS = 
        MailboxImpl.class.getName();
 
-    private static final String notifierSourceClass = 
+    private static final String NOTIFIER_SOURCE_CLASS = 
        Notifier.class.getName();
 
-    private static final String notifyTaskSourceClass = 
+    private static final String NOTIFY_TASK_SOURCE_CLASS = 
        NotifyTask.class.getName();
 
-    private static final String destroyThreadSourceClass = 
+    private static final String DESTROY_THREAD_SOURCE_CLASS = 
        DestroyThread.class.getName();
 
-    private static final String expirationThreadSourceClass = 
+    private static final String EXPIRATION_THREAD_SOURCE_CLASS = 
        ExpirationThread.class.getName();
 
-    private static final String registrationLogObjSourceClass = 
+    private static final String REGISTRATION_LOG_OBJ_SOURCE_CLASS = 
        RegistrationLogObj.class.getName();
 
-    private static final String registrationEnabledLogObjSourceClass = 
+    private static final String REGISTRATION_ENABLED_LOG_OBJ_SOURCE_CLASS = 
        RegistrationEnabledLogObj.class.getName();
 
-    private static final String registrationDisabledLogObjSourceClass = 
+    private static final String REGISTRATION_DISABLED_LOG_OBJ_SOURCE_CLASS = 
        RegistrationDisabledLogObj.class.getName();
 
-    private static final String registrationIteratorEnabledLogObjSourceClass = 
+    private static final String 
REGISTRATION_ITERATOR_ENABLED_LOG_OBJ_SOURCE_CLASS = 
        RegistrationIteratorEnabledLogObj.class.getName();
     
-    private static final String lookupGroupsChangedLogObjSourceClass = 
+    private static final String LOOKUP_GROUPS_CHANGED_LOG_OBJ_SOURCE_CLASS = 
        LookupGroupsChangedLogObj.class.getName();
 
-    private static final String lookupLocatorsChangedLogObjSourceClass = 
+    private static final String LOOKUP_LOCATORS_CHANGED_LOG_OBJ_SOURCE_CLASS = 
        LookupLocatorsChangedLogObj.class.getName();
 
-    private static final String attrsAddedLogObjSourceClass = 
+    private static final String ATTRS_ADDED_LOG_OBJ_SOURCE_CLASS = 
        AttrsAddedLogObj.class.getName();
 
-    private static final String attrsModifiedLogObjSourceClass = 
+    private static final String ATTRS_MODIFIED_LOG_OBJ_SOURCE_CLASS = 
        AttrsModifiedLogObj.class.getName();
 
-    private static final String registrationRenewedLogObjSourceClass = 
+    private static final String REGISTRATION_RENEWED_LOG_OBJ_SOURCE_CLASS = 
        RegistrationRenewedLogObj.class.getName();
 
-    private static final String registrationCancelledLogObjSourceClass = 
+    private static final String REGISTRATION_CANCELLED_LOG_OBJ_SOURCE_CLASS = 
        RegistrationCancelledLogObj.class.getName();
 
-    private static final String unknownEventExceptionLogObjSourceClass = 
+    private static final String UNKNOWN_EVENT_EXCEPTION_LOG_OBJ_SOURCE_CLASS = 
        UnknownEventExceptionLogObj.class.getName();
 
-    private static final String snapshotThreadSourceClass = 
+    private static final String SNAPSHOT_THREAD_SOURCE_CLASS = 
        SnapshotThread.class.getName();
 
     /** ServiceInfo product value */
@@ -270,6 +264,12 @@ class MailboxImpl implements MailboxBack
        org.apache.river.constants.VersionConstants.SERVER_VERSION;
     /** Log format version */
     private static final int LOG_VERSION = 2;
+    
+    /** The attributes to use when joining lookup services */
+    private static final Entry[] BASE_LOOKUP_ATTRS = new Entry[] { 
+           new ServiceInfo(PRODUCT, MANUFACTURER, VENDOR, VERSION, "", ""),
+            new BasicServiceType("Event Mailbox")
+    };
 
     /** The inner proxy of this server */
     private /*final*/ volatile MailboxBackEnd serverStub;
@@ -307,7 +307,7 @@ class MailboxImpl implements MailboxBack
     // HashMap is unsynchronized, but we are performing external
     // synchronization via the <code>concurrentObj</code> field. 
     private final Map<Uuid,NotifyTask> activeReg;
-    /** Reliable log to hold registration state information */
+    /** Reliable loG to hold registration state information */
     // Note that event state is kept separately
     private final ReliableLog log;
     /** Flag indicating whether system is in a state of recovery */
@@ -327,6 +327,8 @@ class MailboxImpl implements MailboxBack
     private final String persistenceDirectory;
     /** Proxy preparer for listeners */
     private final ProxyPreparer listenerPreparer;
+    /** Proxy preparer recovered */
+    private ProxyPreparer recoveredListenerPreparer;
     /** The exporter for exporting and unexporting */
     protected final Exporter exporter;
    /** ServiceID returned from the lookup registration process */
@@ -353,12 +355,7 @@ class MailboxImpl implements MailboxBack
      * this is just used as a shortcut.
      */
     private DiscoveryManagement lookupDiscMgr = null;
-
-    /** The attributes to use when joining lookup services */
-    private final Entry[] baseLookupAttrs = new Entry[] { 
-           new ServiceInfo(PRODUCT, MANUFACTURER, VENDOR, VERSION, "", ""),
-            new BasicServiceType("Event Mailbox")
-    };
+    
     private Entry[] lookupAttrs = new Entry[] {};
     /** 
      * The lookup groups we should join. 
@@ -383,7 +380,7 @@ class MailboxImpl implements MailboxBack
     private final Thread notifier;
     /** Object for coordinating actions with the notification thread */
     private final Object eventNotifier = new Object();
-    /** Registration expirer thread */
+    /** Registration expireR thread */
     private final Thread expirer;
     /** Earliest expiration time of any registration */
     private long minRegExpiration = Long.MAX_VALUE;
@@ -434,12 +431,12 @@ class MailboxImpl implements MailboxBack
     ///////////////////////
 
     public Object getProxy() {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "getProxy");
        }
-       if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+       if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "getProxy", serverStub);
        }
        return serverStub;
@@ -447,13 +444,13 @@ class MailboxImpl implements MailboxBack
 
     /* inherit javadoc */
     public Object getServiceProxy() {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "getServiceProxy");
        }
         readyState.check();
-       if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+       if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "getServiceProxy", mailboxProxy);
        }
         return mailboxProxy;
@@ -461,13 +458,13 @@ class MailboxImpl implements MailboxBack
 
     /* inherit javadoc */
     public Object getAdmin() throws RemoteException {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "getAdmin");
        }
         readyState.check();
-       if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+       if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "getAdmin", mailboxAdminProxy);
        }
         return mailboxAdminProxy;
@@ -482,24 +479,8 @@ class MailboxImpl implements MailboxBack
     MailboxImpl(ActivationID activationID, MarshalledObject data) 
        throws Exception
     {
-        this((String[]) new MarshalledInstance(data).get(false), activationID, 
true, new Object[] {activationID, data} );
-//        if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.entering(mailboxSourceClass, 
-//             "MailboxImpl", 
-//             new Object[] {activationID, data});
-//     }
-//     this.activationID = activationID;
-//     try {
-//         // Initialize state
-//         init((String[])data.get());
-//     } catch (Throwable e) {
-//         cleanup();
-//         initFailed(e);
-//     }         
-//        if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.exiting(mailboxSourceClass, 
-//             "MailboxImpl");
-//     }
+        this((String[]) new MarshalledInstance(data).get(false), activationID,
+                true, new Object[] {activationID, data} );
     }
     
     /////////////////////////
@@ -512,574 +493,197 @@ class MailboxImpl implements MailboxBack
      * This method is only intended for debugging purposes at this time.
      *  
      */
-    // @param log directory where persistent state is maintained
+    // @param loG directory where persistent state is maintained
     MailboxImpl(String[] configArgs, LifeCycle lc, boolean persistent) 
        throws Exception
     {
         this(configArgs, null, persistent, new Object[] 
{Arrays.asList(configArgs), lc, Boolean.valueOf(persistent)});
        lifeCycle = lc; 
-//        if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.entering(mailboxSourceClass, 
-//             "MailboxImpl", 
-//             new Object[] { configArgs, lc, Boolean.valueOf(persistent)});
-//     }
-//     try {
-//         lifeCycle = lc;
-//         this.persistent = persistent;
-//            init(configArgs);
-//     } catch (Throwable e) {
-//         cleanup();
-//         initFailed(e);
-//     }         
-//        if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.exiting(mailboxSourceClass, 
-//             "MailboxImpl");
-//     }
-    }
-    
-    private MailboxImpl(String[] configArgs, final ActivationID activID, final 
boolean persistant, Object [] logMessage){
-        if (operationsLogger.isLoggable(Level.FINER)) {
-            operationsLogger.entering(
-               MailboxImpl.class.getName(), "MailboxImpl",logMessage );
-       }
-        this.persistent = persistant;
+    }
+    
+    private static Configuration config(String[] configArgs) 
+            throws ConfigurationException
+    {
+        Configuration config;
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+            OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
+                "init", (Object[])configArgs);
+        }
+        config =
+            ConfigurationProvider.getInstance(
+                configArgs, MailboxImpl.class.getClassLoader());
+        return config;
+    }
+    
+    private static LoginContext loginContext(Configuration config) 
+            throws ConfigurationException
+    {
+        return config.getEntry(MERCURY, "loginContext", LoginContext.class, 
null);
+    }
+    
+    private static MailboxImplInit init(final Configuration config, 
LoginContext loginContext, final ActivationID activID, final boolean 
persistant, Object [] logMessage) throws ConfigurationException, 
LoginException, RemoteException, ActivationException, IOException, Exception{
         MailboxImplInit init = null;
-        final Configuration config;
-        LoginContext loginContext = null;
-        try {
-           if (operationsLogger.isLoggable(Level.FINER)) {
-                operationsLogger.entering(mailboxSourceClass, 
-                    "init", (Object[])configArgs);
-           }
-           config =
-                ConfigurationProvider.getInstance(
-                    configArgs, getClass().getClassLoader());
-            loginContext = (LoginContext) config.getEntry(
-                MERCURY, "loginContext", LoginContext.class, null);
-            if (loginContext != null) {
+        if (loginContext != null) {
 //                doInitWithLogin(config, loginContext);
-                /* */
-                if (operationsLogger.isLoggable(Level.FINER)) {
-                    operationsLogger.entering(mailboxSourceClass, 
-                        "doInitWithLogin", new Object[] { config, 
loginContext});
-                }
-                loginContext.login();
-                try {
-                    init = Subject.doAsPrivileged(
-                        loginContext.getSubject(),
-                        new PrivilegedExceptionAction<MailboxImplInit>() {
-                            public MailboxImplInit run() throws Exception {
+            /* */
+            if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+                OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
+                    "doInitWithLogin", new Object[] { config, loginContext});
+            }
+            loginContext.login();
+            try {
+                init = Subject.doAsPrivileged(loginContext.getSubject(),
+                    new PrivilegedExceptionAction<MailboxImplInit>() {
+                        public MailboxImplInit run() 
+                                throws 
+                                ConfigurationException, 
+                                RemoteException, 
+                                ActivationException, 
+                                IOException 
+                        {
 //                                doInit(config);
-                                // Create these threads here so they inherit
-                                // current context.
-                                return new MailboxImplInit(config,
-                                        persistant, 
-                                        activID, 
-                                        baseLookupAttrs, 
-                                        new LocalLogHandler(),
-                                        persistant ? new SnapshotThread(): 
null,
-                                        new Notifier(config),
-                                        new ExpirationThread()
-                                        );
-                            }
-                        },
-                        null);
-                } catch (PrivilegedActionException e) {
-                    try {
-                        loginContext.logout();
-                    } catch (LoginException le) {
-        //TODO - Move to end of cleanup()
-                        if (initLogger.isLoggable(Levels.HANDLED)) {
-                            initLogger.log(Levels.HANDLED, "Trouble logging 
out", le);
+                            // Thread need to inherit the
+                            // current context.
+                            return new MailboxImplInit(config,
+                                    persistant, 
+                                    activID, 
+                                    BASE_LOOKUP_ATTRS);
                         }
+                    },
+                    null);
+            } catch (PrivilegedActionException e) {
+                try {
+                    loginContext.logout();
+                } catch (LoginException le) {
+    //TODO - Move to end of cleanup()
+                    if (INIT_LOGGER.isLoggable(Levels.HANDLED)) {
+                        INIT_LOGGER.log(Levels.HANDLED, "Trouble logging out", 
le);
                     }
-                    throw e.getException();
                 }
-                if (operationsLogger.isLoggable(Level.FINER)) {
-                    operationsLogger.exiting(mailboxSourceClass, 
-                        "doInitWithLogin");
-                }
-                /* */
-            } else {
-//                doInit(config);
-                init = new MailboxImplInit(config, 
-                        persistant, 
-                        activID, 
-                        baseLookupAttrs, 
-                        new LocalLogHandler(),
-                        persistant ? new SnapshotThread(): null,
-                        new Notifier(config),
-                        new ExpirationThread()
-                        );
-                
+                throw e.getException(); 
             }
-            if (operationsLogger.isLoggable(Level.FINER)) {
-                operationsLogger.exiting(mailboxSourceClass, 
-                    "init");
-            }
-        } catch (Throwable t){
-            thrown = t;
-        } finally {
-            if (init != null){
-                activationID = init.activationID;
-                activationSystem = init.activationSystem;
-                activationPrepared = init.activationPrepared;
-                exporter = init.exporter;
-                listenerPreparer = init.listenerPreparer;
-                locatorToJoinPreparer = init.locatorToJoinPreparer;
-                leasePolicy = init.leasePolicy;
-                persistenceDirectory = init.persistenceDirectory;
-                recoveredLocatorToJoinPreparer = 
init.recoveredLocatorToJoinPreparer;
-                logToSnapshotThreshold = init.logToSnapshotThreshold;
-                log = init.log;
-                serviceID = init.serviceID;
-                lookupGroups = init.lookupGroups;
-                lookupLocators = init.lookupLocators;
-                lookupAttrs = init.lookupAttrs;
-                maxUnexportDelay = init.maxUnexportDelay;
-                unexportRetryDelay = init.unexportRetryDelay;
-                lookupDiscMgr = init.lookupDiscMgr;
-                regByExpiration = init.regByExpiration;
-                regByID = init.regByID;
-                activeReg = init.activeReg;
-                /** <code>EventLogIterator</code> generator */
-                eventLogFactory = init.eventLogFactory;
-                pendingReg = init.pendingReg;
-                snapshotter = init.snapshotter;
-                notifier = init.notifier;
-                expirer = init.expirer;
-                this.config = init.config;
-                this.loginContext = loginContext;
-                context = init.context;
-                
-            } else {
-                activationID = activID;
-                activationSystem = null;
-                activationPrepared = false;
-                exporter = null;
-                listenerPreparer = null;
-                locatorToJoinPreparer = null;
-                leasePolicy = null;
-                persistenceDirectory = null;
-                recoveredLocatorToJoinPreparer = null;
-                logToSnapshotThreshold = 0;
-                log = null;
-                serviceID = null;
-                lookupGroups = null;
-                lookupLocators = null;
-                lookupAttrs = null;
-                maxUnexportDelay = 0;
-                unexportRetryDelay = 0;
-                lookupDiscMgr = null;
-                regByExpiration = null;
-                regByID = null;
-                activeReg = null;
-                /** <code>EventLogIterator</code> generator */
-                eventLogFactory = null;
-                pendingReg = null;
-                snapshotter = null;
-                notifier = null;
-                expirer = null;
-                this.config = null;
-                this.loginContext = loginContext;
-                context = null;
+            if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+                OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
+                    "doInitWithLogin");
             }
-            // Assign fields.
+            /* */
+        } else {
+            init = new MailboxImplInit(config, 
+                    persistant, 
+                    activID, 
+                    BASE_LOOKUP_ATTRS
+                    );
+
+        }
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+            OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
+                "init");
         }
+        return init;
+    }
         
+    private MailboxImpl( 
+            Configuration config,  
+            final ActivationID activID, 
+            final boolean persistant, 
+            Object [] logMessage ) throws LoginException, 
+            ActivationException, IOException, RemoteException, Exception
+    {
+        this(init(config, loginContext(config), activID, persistant, 
logMessage), activID, persistant, logMessage);
     }
+    
+    private MailboxImpl(MailboxImplInit init, 
+            ActivationID activID,
+            final boolean persistent,
+            final Object [] logMessage )
+    {
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+            OPERATIONS_LOGGER.entering(
+               MailboxImpl.class.getName(), "MailboxImpl",logMessage );
+       }
+        this.persistent = persistent; 
+        activationID = init.activationID;
+        activationSystem = init.activationSystem;
+        activationPrepared = init.activationPrepared;
+        exporter = init.exporter;
+        listenerPreparer = init.listenerPreparer;
+        recoveredListenerPreparer = init.recoveredListenerPreparer;
+        locatorToJoinPreparer = init.locatorToJoinPreparer;
+        leasePolicy = init.leasePolicy;
+        persistenceDirectory = init.persistenceDirectory;
+        recoveredLocatorToJoinPreparer = init.recoveredLocatorToJoinPreparer;
+        logToSnapshotThreshold = init.logToSnapshotThreshold;
+        serviceID = init.serviceID;
+        lookupGroups = init.lookupGroups;
+        lookupLocators = init.lookupLocators;
+        lookupAttrs = init.lookupAttrs;
+        maxUnexportDelay = init.maxUnexportDelay;
+        unexportRetryDelay = init.unexportRetryDelay;
+        lookupDiscMgr = init.lookupDiscMgr;
+        regByExpiration = init.regByExpiration;
+        regByID = init.regByID;
+        activeReg = init.activeReg;
+        /** <code>EventLogIterator</code> generator */
+        eventLogFactory = init.eventLogFactory;
+        pendingReg = init.pendingReg;
+        this.config = init.config;
+        this.loginContext = init.loginContext;
+        context = init.context;
 
-//    /** Initialization common to both activatable and transient instances. */
-//    private void init(String[] configArgs) 
-//     throws Exception
-//    {
-//       if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.entering(mailboxSourceClass, 
-//             "init", (Object[])configArgs);
-//       }
-//       final Configuration config =
-//            ConfigurationProvider.getInstance(
-//             configArgs, getClass().getClassLoader());
-//        loginContext = (LoginContext) config.getEntry(
-//            MERCURY, "loginContext", LoginContext.class, null);
-//        if (loginContext != null) {
-//            doInitWithLogin(config, loginContext);
-//        } else {
-//            doInit(config);
-//     }
-//     if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.exiting(mailboxSourceClass, 
-//             "init");
-//     }
-//    }
+        // Assign fields
+        
+        Thread snapShotter = null;
+        Thread notifieR = null;
+        Thread expireR = null;
+        ReliableLog loG = null;
+        try {
+            Object [] result
+                = AccessController.doPrivileged(new 
PrivilegedExceptionAction<Object[]>(){
+                    public Object [] run() throws Exception {
+                        Object [] res = new Object [4];
+                        res [0] = persistent ? new SnapshotThread(): null;
+                        res [1] = new Notifier(config);
+                        res [2] = new ExpirationThread();
+                        
+                        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+                            OPERATIONS_LOGGER.entering(
+                                MailboxImpl.class.getName(), "MailboxImpl",
+                                    logMessage );
+                        }
+                        if(persistent){
+                            res [3] = new ReliableLog(persistenceDirectory,
+                                    new LocalLogHandler());
+                        } else {
+                            res [3] = null;
+                        }
+                        return res;
+                    }
+                }, context);
+            snapShotter = (Thread) result[0];
+            notifieR = (Thread) result [1];
+            expireR = (Thread) result [2];
+            loG = (ReliableLog) result [3];
+            thrown = null;
+        } catch (PrivilegedActionException ex) {
+            thrown = ex.getException();
+        }
+        this.log = loG;
+        this.snapshotter = snapShotter;
+        this.notifier = notifieR;
+        this.expirer = expireR;
+    }
     
-    /** 
-     * Method that attempts to login before delegating the
-     * rest of the initialization process to <code>doInit</code>
-     */
-//    private void doInitWithLogin(final Configuration config, 
-//        LoginContext loginContext) throws Exception 
-//    {
-//        if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.entering(mailboxSourceClass, 
-//             "doInitWithLogin", new Object[] { config, loginContext});
-//     }
-//        loginContext.login();
-//     try {
-//            Subject.doAsPrivileged(
-//                loginContext.getSubject(),
-//                new PrivilegedExceptionAction() {
-//                    public Object run() throws Exception {
-//                        doInit(config);
-//                        return null;
-//                    }
-//                },
-//                null);
-//     } catch (PrivilegedActionException e) {
-//         try {
-//             loginContext.logout();
-//         } catch (LoginException le) {
-////TODO - Move to end of cleanup()
-//             if (initLogger.isLoggable(Levels.HANDLED)) {
-//                 initLogger.log(Levels.HANDLED, "Trouble logging out", le);
-//             }
-//         }
-//         throw e.getException();
-//        }
-//        if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.exiting(mailboxSourceClass, 
-//             "doInitWithLogin");
-//     }
-//    }
-    
-//    /** Initialization common to both activatable and transient instances. */
-//    private void doInit(Configuration config) throws Exception { 
-//
-//        if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.entering(mailboxSourceClass, 
-//             "doInit", config);
-//     }
-////TODO - defer "big" default object to catch block around getNonNullEntry()
-//    
-//        // Get activation specific configuration items, if activated
-//     if (activationID != null) {
-//            ProxyPreparer activationSystemPreparer =
-//                (ProxyPreparer) Config.getNonNullEntry(config,
-//                 MERCURY, "activationSystemPreparer", 
-//                 ProxyPreparer.class, new BasicProxyPreparer());
-//            if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, "activationSystemPreparer: 
{0}", 
-//             activationSystemPreparer);
-//         }           
-//            activationSystem =
-//                (ActivationSystem) activationSystemPreparer.prepareProxy(
-//                    ActivationGroup.getSystem());
-//            if (initLogger.isLoggable(Level.FINEST)) {
-//                initLogger.log(Level.FINEST, "Prepared activation system is: 
{0}", 
-//             activationSystem);
-//         }           
-//            ProxyPreparer activationIdPreparer = 
-//             (ProxyPreparer)  Config.getNonNullEntry(config,
-//                 MERCURY, "activationIdPreparer", 
-//                 ProxyPreparer.class, new BasicProxyPreparer());
-//            if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, "activationIdPreparer: {0}", 
-//             activationIdPreparer);
-//         }           
-//            activationID = (ActivationID) activationIdPreparer.prepareProxy(
-//                activationID);
-//            if (initLogger.isLoggable(Level.FINEST)) {
-//                initLogger.log(Level.FINEST, "Prepared activationID is: 
{0}", 
-//             activationID);
-//         }           
-//            activationPrepared = true;
-//     
-//            exporter = (Exporter)Config.getNonNullEntry(config,
-//             MERCURY, "serverExporter", Exporter.class,
-//             new ActivationExporter(
-//                 activationID, 
-//                 new BasicJeriExporter(
-//                     TcpServerEndpoint.getInstance(0), 
-//                     new BasicILFactory(), false, true)),
-//             activationID);
-//            if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, "Activatable service exporter 
is: {0}", 
-//             exporter);
-//         }           
-//     } else { //Get non-activatable configuration items
-//            exporter = (Exporter) Config.getNonNullEntry(config,
-//                MERCURY, "serverExporter", Exporter.class, 
-//             new BasicJeriExporter(
-//                 TcpServerEndpoint.getInstance(0), 
-//                 new BasicILFactory(), false, true));
-//            if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, 
-//             "Non-activatable service exporter is: {0}", exporter);          
-//         }
-//     }
-//
-//        listenerPreparer = (ProxyPreparer) Config.getNonNullEntry(
-//         config, MERCURY, "listenerPreparer", ProxyPreparer.class,
-//            new BasicProxyPreparer());
-//        if (initLogger.isLoggable(Level.CONFIG)) {
-//            initLogger.log(Level.CONFIG, "Listener preparer is: {0}", 
-//         listenerPreparer);  
-//     }
-//     
-//        /* Get the proxy preparers for the lookup locators to join */
-//        locatorToJoinPreparer = (ProxyPreparer)Config.getNonNullEntry
-//             (config, MERCURY, "locatorToJoinPreparer",
-//              ProxyPreparer.class, new BasicProxyPreparer());
-//        if (initLogger.isLoggable(Level.CONFIG)) {
-//            initLogger.log(Level.CONFIG, "Locator preparer is: {0}", 
-//         locatorToJoinPreparer);
-//     }       
-//     
-//        // Create lease policy -- used by recovery logic, below
-//        leasePolicy = (LeasePeriodPolicy) Config.getNonNullEntry(config,
-//         MERCURY, "leasePeriodPolicy", LeasePeriodPolicy.class,
-//            new FixedLeasePeriodPolicy(3 * HOURS, 1 * HOURS));
-//        if (initLogger.isLoggable(Level.CONFIG)) {
-//            initLogger.log(Level.CONFIG, "LeasePeriodPolicy is: {0}", 
-//         leasePolicy);
-//     }       
-//         
-//     // Note: referenced by recovery logic in rebuildTransientState()        
-//        ProxyPreparer recoveredListenerPreparer = null;
-//        if (persistent) {
-//         persistenceDirectory = 
-//             (String)Config.getNonNullEntry(
-//                    config, MERCURY, "persistenceDirectory", String.class);
-//            if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, "Persistence directory is: 
{0}", 
-//             persistenceDirectory);
-//         }   
-//         // Note: referenced by recovery logic in rebuildTransientState()    
-//            recoveredListenerPreparer = 
-//             (ProxyPreparer) Config.getNonNullEntry(
-//             config, MERCURY, "recoveredListenerPreparer", 
ProxyPreparer.class,
-//                new BasicProxyPreparer());
-//            if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, "Recovered listener preparer 
is: {0}", 
-//             recoveredListenerPreparer);     
-//         }
-//         // Note: referenced by recovery logic, below        
-//            recoveredLocatorToJoinPreparer = 
(ProxyPreparer)Config.getNonNullEntry
-//                 (config, MERCURY, "recoveredLocatorToJoinPreparer",
-//                  ProxyPreparer.class, new BasicProxyPreparer());
-//            if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, "Recovered locator preparer is: 
{0}", 
-//             recoveredLocatorToJoinPreparer);
-//         }   
-//
-//         logToSnapshotThreshold = Config.getIntEntry(config,
-//                MERCURY, "logToSnapshotThreshold", 50, 0, Integer.MAX_VALUE);
-//         
-////            log = new ReliableLog(persistenceDirectory, new 
LocalLogHandler());
-//
-//         if (initLogger.isLoggable(Level.FINEST)) {
-//                initLogger.log(Level.FINEST, "Recovering persistent state");
-//         }
-//            inRecovery = true;
-//            log.recover();
-//            inRecovery = false;
-//     }
-//
-//     if (serviceID == null) { // First time up, get initial values
-//         if (initLogger.isLoggable(Level.FINEST)) {
-//                initLogger.log(Level.FINEST, "Getting initial values.");
-//         }
-//         serviceID = UuidFactory.generate();
-//         if (initLogger.isLoggable(Level.FINEST)) {
-//                initLogger.log(Level.FINEST, "ServiceID: {0}", serviceID);
-//         }
-//         // Can be null for ALL_GROUPS
-//            lookupGroups = (String[])config.getEntry(MERCURY, 
-//             "initialLookupGroups", String[].class, 
-//             new String[] { "" }); //default to public group
-//         if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, "Initial groups:");
-//             dumpGroups(lookupGroups, initLogger, Level.CONFIG);
-//         }
-//         /*
-//          * Note: Configuration provided locators are assumed to be 
-//          * prepared already.
-//          */
-//            lookupLocators = (LookupLocator[]) Config.getNonNullEntry(config,
-//             MERCURY, "initialLookupLocators", LookupLocator[].class, 
-//             new LookupLocator[0]);
-//         if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, "Initial locators:");
-//             dumpLocators(lookupLocators, initLogger, Level.CONFIG);
-//         }
-//
-//            final Entry[] initialAttrs = 
-//             (Entry[])Config.getNonNullEntry(config,
-//                 MERCURY, "initialLookupAttributes" ,
-//                 Entry[].class, new Entry[0]);
-//         if (initLogger.isLoggable(Level.CONFIG)) {
-//                initLogger.log(Level.CONFIG, "Initial lookup attributes:");
-//             dumpAttrs(initialAttrs, initLogger, Level.CONFIG);
-//         }
-//            if (initialAttrs.length == 0) {
-//                lookupAttrs = baseLookupAttrs;
-//            } else {
-//                lookupAttrs = 
-//                 new Entry[initialAttrs.length + baseLookupAttrs.length];
-//                int i=0;
-//                for (int j=0; j<baseLookupAttrs.length; j++, i++)
-//                    lookupAttrs[i] = baseLookupAttrs[j];
-//                for (int j=0; j<initialAttrs.length; j++, i++)
-//                    lookupAttrs[i] = initialAttrs[j];
-//            }
-//         if (initLogger.isLoggable(Level.FINEST)) {
-//                initLogger.log(Level.FINEST, 
-//                 "Combined lookup attributes:"); 
-//             dumpAttrs(lookupAttrs, initLogger, Level.FINEST);
-//         }
-//        } else { // recovered logic
-//         if (initLogger.isLoggable(Level.FINEST)) {
-//                initLogger.log(Level.FINEST, "Preparing recovered 
locators:"); 
-//             dumpLocators(lookupLocators, initLogger, Level.FINEST);
-//         }
-//            prepareExistingLocators(
-//             recoveredLocatorToJoinPreparer, lookupLocators);
-////TODO - Add recovered state debug: groups, locators, etc.
-//     }
-//     
-//        if (persistent) {
-//         // Take snapshot of current state.
-//         if (initLogger.isLoggable(Level.FINEST)) {
-//                initLogger.log(Level.FINEST, "Taking snapshot.");
-//         }
-//            log.snapshot();
-//
-//            // Reconstruct any transient state, if necessary.
-//            rebuildTransientState(recoveredListenerPreparer);
-//         
-//            /*  ----  ----- */
-//         // Start snapshot thread belongs in start method
-////       snapshotter = new SnapshotThread();
-//            snapshotter.start();
-//     }
-//        
-//     maxUnexportDelay = Config.getLongEntry(config, MERCURY, 
-//         "maxUnexportDelay", 2 * MINUTES, 0, Long.MAX_VALUE);
-//
-//     unexportRetryDelay = Config.getLongEntry(config, MERCURY, 
-//         "unexportRetryDelay", SECONDS, 1, Long.MAX_VALUE);
-//        
-//        /*  ---  The following will go into start method --- */
-//
-//        // Start threads
-////   notifier = new Notifier(config);
-//        notifier.start();
-////   expirer = new ExpirationThread();
-//        expirer.start();
-//
-//     // Export server instance and get its reference
-//     serverStub = (MailboxBackEnd)exporter.export(this);
-//        if (initLogger.isLoggable(Level.FINEST)) {
-//            initLogger.log(Level.FINEST, "Service stub is: {0}", 
-//         serverStub);        
-//     }       
-//
-//        // Create the proxy that will be registered in the lookup service
-//        mailboxProxy = 
-//         MailboxProxy.create(serverStub, serviceID);
-//        if (initLogger.isLoggable(Level.FINEST)) {
-//            initLogger.log(Level.FINEST, "Service proxy is: {0}", 
-//         mailboxProxy);
-//     }               
-//
-//        // Create the admin proxy for this service
-//        mailboxAdminProxy = 
-//         MailboxAdminProxy.create(serverStub, serviceID);
-//        if (initLogger.isLoggable(Level.FINEST)) {
-//            initLogger.log(Level.FINEST, "Service admin proxy is: {0}", 
-//         mailboxAdminProxy);         
-//     }
-//
-//     // Create leaseFactory
-//     leaseFactory = new LeaseFactory(serverStub, serviceID);
-//
-//        // Get shorthand reference to the discovery manager
-//     try {
-//            lookupDiscMgr  = 
-//                (DiscoveryManagement)Config.getNonNullEntry(config,
-//                 MERCURY, "discoveryManager",
-//                    DiscoveryManagement.class);
-//            if(lookupDiscMgr instanceof DiscoveryGroupManagement) {
-//                 // Verify proper initial state ---> NO_GROUPS
-//                String[] groups =
-//                    ((DiscoveryGroupManagement)lookupDiscMgr).getGroups();
-//                if( (groups == DiscoveryGroupManagement.ALL_GROUPS) ||
-//                    (groups.length != 0) )
-//                {
-//                    throw new ConfigurationException(
-//                        "discoveryManager entry must be configured " +
-//                     " with no groups.");
-//                }//endif
-//         } else {
-//               throw new ConfigurationException(
-//                    "discoveryManager entry must implement " +
-//                    "DiscoveryGroupManagement");
-//            }
-//         
-//            if(lookupDiscMgr instanceof DiscoveryLocatorManagement) {
-//                LookupLocator[] locs =
-//                        
((DiscoveryLocatorManagement)lookupDiscMgr).getLocators();
-//                if( (locs != null) && (locs.length != 0) ) {
-//                    throw new ConfigurationException(
-//                        "discoveryManager entry must be configured " +
-//                     "with no locators");
-//                }//endif
-//         } else {
-//                throw new ConfigurationException(
-//                    "discoveryManager entry must implement " +
-//                    "DiscoveryLocatorManagement");
-//            }  
-//         
-//         ((DiscoveryGroupManagement)lookupDiscMgr).setGroups(lookupGroups);
-//         
((DiscoveryLocatorManagement)lookupDiscMgr).setLocators(lookupLocators);
-//     } catch (NoSuchEntryException e) {
-//         lookupDiscMgr  =
-//             new LookupDiscoveryManager(lookupGroups, lookupLocators,
-//                    null, config);
-//     }
-//        if (initLogger.isLoggable(Level.FINEST)) {
-//            initLogger.log(Level.FINEST, "Discovery manager is: {0}", 
-//         lookupDiscMgr);
-//     }               
-//
-//        ServiceID lookupID = new ServiceID(
-//         serviceID.getMostSignificantBits(),
-//         serviceID.getLeastSignificantBits());
-//
-//     if (initLogger.isLoggable(Level.FINEST)) {
-//            initLogger.log(Level.FINEST, "Creating JoinManager.");
-//     }
-//     joiner = new JoinManager(
-//         mailboxProxy,                // service object
-//         lookupAttrs,               // service attributes
-//         lookupID,                 // Service ID
-//         lookupDiscMgr,             // DiscoveryManagement ref - default
-//         null,                      // LeaseRenewalManager reference
-//         config); 
-//                           
-//        if (operationsLogger.isLoggable(Level.FINER)) {
-//         operationsLogger.exiting(mailboxSourceClass, 
-//             "doInit");
-//     }
-//        readyState.ready();
-//
-//     if (startupLogger.isLoggable(Level.INFO)) {
-//            startupLogger.log
-//                   (Level.INFO, "Mercury started: {0}", this);
-//        }
-//
-//    } // End doInit()
-//    
+    private MailboxImpl(String[] configArgs,
+            final ActivationID activID, 
+            final boolean persistant, 
+            Object [] logMessage) 
+        throws ConfigurationException, ActivationException,
+            IOException, RemoteException, Exception
+    {
+        this(config(configArgs), activID, persistant, logMessage);
+    }
+   
+    /* Recovery and starting of threads performed here */
     public void start() throws Exception {
         concurrentObj.writeLock();
         if (started) return;
@@ -1092,39 +696,212 @@ class MailboxImpl implements MailboxBack
                 @Override
                 public Object run() throws Exception {
                     if (persistent){
+                        if (MailboxImpl.INIT_LOGGER.isLoggable(Level.FINEST)) {
+                        MailboxImpl.INIT_LOGGER.log(Level.FINEST, "Recovering 
persistent state");
+                        }
+                        log.recover();  
+                    }
+                    if (serviceID == null) {
+                        // First time up, get initial values
+                        if (MailboxImpl.INIT_LOGGER.isLoggable(Level.FINEST)) {
+                            MailboxImpl.INIT_LOGGER.log(Level.FINEST, "Getting 
initial values.");
+                        }
+                        serviceID = UuidFactory.generate();
+                        if (MailboxImpl.INIT_LOGGER.isLoggable(Level.FINEST)) {
+                            MailboxImpl.INIT_LOGGER.log(Level.FINEST, 
"ServiceID: {0}", serviceID);
+                        }
+                        // Can be null for ALL_GROUPS
+                        lookupGroups = (String[]) 
config.getEntry(MailboxImpl.MERCURY, "initialLookupGroups", String[].class, new 
String[]{""}); //default to public group
+                        //default to public group
+                        if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) {
+                            MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Initial 
groups:");
+                            MailboxImpl.dumpGroups(lookupGroups, 
MailboxImpl.INIT_LOGGER, Level.CONFIG);
+                        }
+                        /*
+                         * Note: Configuration provided locators are assumed 
to be
+                         * prepared already.
+                         */
+                        lookupLocators = (LookupLocator[]) 
Config.getNonNullEntry(config, MailboxImpl.MERCURY, "initialLookupLocators", 
LookupLocator[].class, new LookupLocator[0]);
+                        if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) {
+                            MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Initial 
locators:");
+                            MailboxImpl.dumpLocators(lookupLocators, 
MailboxImpl.INIT_LOGGER, Level.CONFIG);
+                        }
+                        final Entry[] initialAttrs = (Entry[]) 
Config.getNonNullEntry(config, MailboxImpl.MERCURY, "initialLookupAttributes", 
Entry[].class, new Entry[0]);
+                        if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) {
+                            MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Initial 
lookup attributes:");
+                            MailboxImpl.dumpAttrs(initialAttrs, 
MailboxImpl.INIT_LOGGER, Level.CONFIG);
+                        }
+                        if (initialAttrs.length == 0) {
+                            lookupAttrs = BASE_LOOKUP_ATTRS;
+                        } else {
+                            lookupAttrs = new Entry[initialAttrs.length + 
BASE_LOOKUP_ATTRS.length];
+                            int i = 0;
+                            for (int j = 0; j < BASE_LOOKUP_ATTRS.length; j++, 
i++) {
+                                lookupAttrs[i] = BASE_LOOKUP_ATTRS[j];
+                            }
+                            for (int j = 0; j < initialAttrs.length; j++, i++) 
{
+                                lookupAttrs[i] = initialAttrs[j];
+                            }
+                        }
+                        if (MailboxImpl.INIT_LOGGER.isLoggable(Level.FINEST)) {
+                            MailboxImpl.INIT_LOGGER.log(Level.FINEST, 
"Combined lookup attributes:");
+                            MailboxImpl.dumpAttrs(lookupAttrs, 
MailboxImpl.INIT_LOGGER, Level.FINEST);
+                        }
+                    } else {
+                        // recovered logic
+                        if (MailboxImpl.INIT_LOGGER.isLoggable(Level.FINEST)) {
+                            MailboxImpl.INIT_LOGGER.log(Level.FINEST, 
"Preparing recovered locators:");
+                            MailboxImpl.dumpLocators(lookupLocators, 
MailboxImpl.INIT_LOGGER, Level.FINEST);
+                        }
+                        
MailboxImpl.prepareExistingLocators(recoveredLocatorToJoinPreparer, 
lookupLocators);
+                        //TODO - Add recovered state debug: groups, locators, 
etc.
+                    }
+                    if (persistent) {
+                        // Take snapshot of current state.
+                        if (MailboxImpl.INIT_LOGGER.isLoggable(Level.FINEST)) {
+                            MailboxImpl.INIT_LOGGER.log(Level.FINEST, "Taking 
snapshot.");
+                        }
+                        log.snapshot();
+                        
+                        // Reconstruct any transient state, if necessary.
+                        // Rebuilds internal data structures after a restart.
+                        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+                            OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
+                                "RebuildTransientState", 
recoveredListenerPreparer);
+                        }
+
+                        // Reconstruct regByExpiration and pendingReg data 
structures,
+                        // if necessary.
+                        if (!regByID.isEmpty()) {
+                            if (RECOVERY_LOGGER.isLoggable(Level.FINEST)) {
+                                RECOVERY_LOGGER.log(Level.FINEST, "Rebuilding 
transient state ...");
+                            }
+                            Collection regs = regByID.values();
+                            Iterator iter = regs.iterator();
+                            ServiceRegistration reg = null;
+                            Uuid uuid = null;
+                            EventLogIterator eli = null; 
+                            while (iter.hasNext()) {
+                                reg = (ServiceRegistration)iter.next(); // get 
Reg
+                                uuid = (Uuid)reg.getCookie();           // get 
its Uuid
+                                if (RECOVERY_LOGGER.isLoggable(Level.FINEST)) {
+                                    RECOVERY_LOGGER.log(Level.FINEST, 
"Checking reg : {0}", reg);
+                                }
+                                // Check if registration is still current
+                                if (ensureCurrent(reg)) {
+                                    if 
(RECOVERY_LOGGER.isLoggable(Level.FINEST)) {
+                                        RECOVERY_LOGGER.log(Level.FINEST,
+                                        "Restoring reg transient state ...");
+                                    }
+                                    try {
+                                        concurrentObj.writeUnlock();//release
+                                        // Holding a lock while calling this 
method should be avoided.
+                                        
reg.restoreTransientState(recoveredListenerPreparer);
+                                    } catch (Exception e) {
+                                        if 
(RECOVERY_LOGGER.isLoggable(Levels.HANDLED)) {
+                                            RECOVERY_LOGGER.log(Levels.HANDLED,
+                                                "Trouble restoring reg 
transient state", e);
+                                        }
+                                        try {
+                                            reg.setEventTarget(null);
+                                        } catch (IOException ioe) {
+                                            throw new AssertionError(
+                                                "Setting a null target threw 
an exception: "
+                                                + ioe);
+                                        }
+                                    } finally {
+                                        concurrentObj.writeLock();//relock
+                                    } 
+
+                                    if 
(RECOVERY_LOGGER.isLoggable(Level.FINEST)) {
+                                        RECOVERY_LOGGER.log(Level.FINEST,
+                                            "Reinitializing iterator ...");
+                                    }
+                                    // regenerate an EventLogIterator for this 
Reg
+                                    // Note that event state is maintained 
separately
+                                    // through the event loG mechanism.
+                                    eli = persistent?
+                                        eventLogFactory.iterator(uuid, 
+                                            
getEventLogPath(persistenceDirectory, uuid)):
+                                        eventLogFactory.iterator(uuid); 
+                                    reg.setIterator(eli);
+                                    if 
(RECOVERY_LOGGER.isLoggable(Level.FINEST)) {
+                                        RECOVERY_LOGGER.log(Level.FINEST, 
+                                        "Adding registration to expiration 
watch list");
+                                    }
+                                    // Put Reg into time sorted collection
+                                    regByExpiration.put(reg, reg);
+
+                                    // Check if registration needs to be added 
to the
+                                    // pending list. Note, we could have 
processed
+                                    // an "enabled" log record during 
recovery, so 
+                                    // only add it if it's not already there.
+                                    // We don't need to check activeReg since 
the
+                                    // the notifieR hasn't kicked in yet. 
Don't call
+                                    // enableRegistration() since it clears 
the "unknown
+                                    // events" list which we want to maintain.
+                                    if (reg.hasEventTarget() &&
+                                        !pendingReg.contains(uuid))
+                                    {
+                                        if 
(RECOVERY_LOGGER.isLoggable(Level.FINEST)) {
+                                            RECOVERY_LOGGER.log(Level.FINEST, 
+                                                "Adding registration to 
pending task list");
+                                        }
+                                        pendingReg.add(uuid);
+
+                                    }
+                                } else {
+                                    /* Registration has expired, so remove it 
via the iterator,
+                                     * which is the only "safe" way to do it 
during a traversal.
+                                     * Call the overloaded version of 
removeRegistration()
+                                     * which will avoid directly removing the 
registration
+                                     * from regByID (which would result in a 
+                                     * ConcurrentModificationException). See 
Bug 4507320.
+                                     */
+                                    if 
(RECOVERY_LOGGER.isLoggable(Level.FINEST)) {
+                                        RECOVERY_LOGGER.log(Level.FINEST,
+                                            "Removing expired registration: ");
+                                    }
+                                    iter.remove();
+                                    removeRegistration(uuid, reg, true);
+                                }
+                            }
+                        }
+                        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+                            OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
+                                "rebuildTransientState");
+                        }
+                    
                         // Start snapshot thread belongs in start method
-            //     snapshotter = new SnapshotThread();
                         snapshotter.start();
                     }
 
                     /*  ---  The following will go into start method --- */
 
                     // Start threads
-            // notifier = new Notifier(config);
                     notifier.start();
-            // expirer = new ExpirationThread();
                     expirer.start();
 
                     // Export server instance and get its reference
                     serverStub = 
(MailboxBackEnd)exporter.export(MailboxImpl.this);
-                    if (initLogger.isLoggable(Level.FINEST)) {
-                        initLogger.log(Level.FINEST, "Service stub is: {0}", 
+                    if (INIT_LOGGER.isLoggable(Level.FINEST)) {
+                        INIT_LOGGER.log(Level.FINEST, "Service stub is: {0}", 
                         serverStub);   
                     }  
 
                     // Create the proxy that will be registered in the lookup 
service
                     mailboxProxy = 
                         MailboxProxy.create(serverStub, serviceID);
-                    if (initLogger.isLoggable(Level.FINEST)) {
-                        initLogger.log(Level.FINEST, "Service proxy is: {0}", 
+                    if (INIT_LOGGER.isLoggable(Level.FINEST)) {
+                        INIT_LOGGER.log(Level.FINEST, "Service proxy is: {0}", 
                         mailboxProxy);
                     }          
 
                     // Create the admin proxy for this service
                     mailboxAdminProxy = 
                         MailboxAdminProxy.create(serverStub, serviceID);
-                    if (initLogger.isLoggable(Level.FINEST)) {
-                        initLogger.log(Level.FINEST, "Service admin proxy is: 
{0}", 
+                    if (INIT_LOGGER.isLoggable(Level.FINEST)) {
+                        INIT_LOGGER.log(Level.FINEST, "Service admin proxy is: 
{0}", 
                         mailboxAdminProxy);            
                     }
 
@@ -1175,8 +952,8 @@ class MailboxImpl implements MailboxBack
                             new LookupDiscoveryManager(lookupGroups, 
lookupLocators,
                                 null, config);
                     }
-                    if (initLogger.isLoggable(Level.FINEST)) {
-                        initLogger.log(Level.FINEST, "Discovery manager is: 
{0}", 
+                    if (INIT_LOGGER.isLoggable(Level.FINEST)) {
+                        INIT_LOGGER.log(Level.FINEST, "Discovery manager is: 
{0}", 
                         lookupDiscMgr);
                     }          
 
@@ -1184,8 +961,8 @@ class MailboxImpl implements MailboxBack
                         serviceID.getMostSignificantBits(),
                         serviceID.getLeastSignificantBits());
 
-                    if (initLogger.isLoggable(Level.FINEST)) {
-                        initLogger.log(Level.FINEST, "Creating JoinManager.");
+                    if (INIT_LOGGER.isLoggable(Level.FINEST)) {
+                        INIT_LOGGER.log(Level.FINEST, "Creating JoinManager.");
                     }
                     joiner = new JoinManager(
                         mailboxProxy,                // service object
@@ -1195,14 +972,14 @@ class MailboxImpl implements MailboxBack
                         null,                      // LeaseRenewalManager 
reference
                         config); 
 
-                    if (operationsLogger.isLoggable(Level.FINER)) {
-                        operationsLogger.exiting(mailboxSourceClass, 
+                    if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+                        OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                             "doInit");
                     }
                     readyState.ready();
 
-                    if (startupLogger.isLoggable(Level.INFO)) {
-                        startupLogger.log
+                    if (STARTUP_LOGGER.isLoggable(Level.INFO)) {
+                        STARTUP_LOGGER.log
                                (Level.INFO, "Mercury started: {0}", this);
                     }
                     return null;
@@ -1221,202 +998,97 @@ class MailboxImpl implements MailboxBack
         }
     }
 
-    // Rebuilds internal data structures after a restart.
-    private void rebuildTransientState(ProxyPreparer 
recoveredListenerPreparer) {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
-               "rebuildTransientState", recoveredListenerPreparer);
-       }
-
-       // Reconstruct regByExpiration and pendingReg data structures,
-       // if necessary.
-       if (!regByID.isEmpty()) {
-           if (recoveryLogger.isLoggable(Level.FINEST)) {
-                recoveryLogger.log(Level.FINEST, "Rebuilding transient state 
...");
-            }
-           Collection regs = regByID.values();
-           Iterator iter = regs.iterator();
-           ServiceRegistration reg = null;
-           Uuid uuid = null;
-            EventLogIterator eli = null; 
-           while (iter.hasNext()) {
-               reg = (ServiceRegistration)iter.next(); // get Reg
-               uuid = (Uuid)reg.getCookie();           // get its Uuid
-               if (recoveryLogger.isLoggable(Level.FINEST)) {
-                    recoveryLogger.log(Level.FINEST, "Checking reg : {0}", 
reg);
-               }
-               // Check if registration is still current
-               if (ensureCurrent(reg)) {
-                   if (recoveryLogger.isLoggable(Level.FINEST)) {
-                        recoveryLogger.log(Level.FINEST,
-                       "Restoring reg transient state ...");
-                   }
-                    try {
-                        reg.restoreTransientState(recoveredListenerPreparer);
-                    } catch (Exception e) {
-                       if (recoveryLogger.isLoggable(Levels.HANDLED)) {
-                            recoveryLogger.log(Levels.HANDLED,
-                               "Trouble restoring reg transient state", e);
-                       }
-                        try {
-                            reg.setEventTarget(null);
-                        } catch (IOException ioe) {
-                            throw new AssertionError(
-                                "Setting a null target threw an exception: "
-                                + ioe);
-                        }
-                    }  
-                               
-                   if (recoveryLogger.isLoggable(Level.FINEST)) {
-                        recoveryLogger.log(Level.FINEST,
-                           "Reinitializing iterator ...");
-                   }
-                   // regenerate an EventLogIterator for this Reg
-                   // Note that event state is maintained separately
-                   // through the event log mechanism.
-                    eli = persistent?
-                       eventLogFactory.iterator(uuid, 
-                           getEventLogPath(persistenceDirectory, uuid)):
-                       eventLogFactory.iterator(uuid); 
-                   reg.setIterator(eli);
-                   if (recoveryLogger.isLoggable(Level.FINEST)) {
-                        recoveryLogger.log(Level.FINEST, 
-                       "Adding registration to expiration watch list");
-                   }
-                   // Put Reg into time sorted collection
-                   regByExpiration.put(reg, reg);
-
-                   // Check if registration needs to be added to the
-                   // pending list. Note, we could have processed
-                   // an "enabled" log record during recovery, so 
-                   // only add it if it's not already there.
-                   // We don't need to check activeReg since the
-                   // the notifier hasn't kicked in yet. Don't call
-                   // enableRegistration() since it clears the "unknown
-                   // events" list which we want to maintain.
-                   if (reg.hasEventTarget() &&
-                       !pendingReg.contains(uuid))
-                   {
-                       if (recoveryLogger.isLoggable(Level.FINEST)) {
-                            recoveryLogger.log(Level.FINEST, 
-                               "Adding registration to pending task list");
-                       }
-                       pendingReg.add(uuid);
-
-                   }
-               } else {
-                   /* Registration has expired, so remove it via the iterator,
-                    * which is the only "safe" way to do it during a traversal.
-                    * Call the overloaded version of removeRegistration()
-                    * which will avoid directly removing the registration
-                    * from regByID (which would result in a 
-                    * ConcurrentModificationException). See Bug 4507320.
-                    */
-                   if (recoveryLogger.isLoggable(Level.FINEST)) {
-                        recoveryLogger.log(Level.FINEST,
-                           "Removing expired registration: ");
-                   }
-                   iter.remove();
-                   removeRegistration(uuid, reg, true);
-               }
-           }
-       }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
-               "rebuildTransientState");
-       }
-    }
     /*
      *
      */
     private void cleanup() {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, "cleanup");
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, "cleanup");
        }
         if (serverStub != null) { // implies that exporter != null
            try {
-                if(initLogger.isLoggable(Level.FINEST)) {
-                    initLogger.log(Level.FINEST, "Unexporting service");
+                if(INIT_LOGGER.isLoggable(Level.FINEST)) {
+                    INIT_LOGGER.log(Level.FINEST, "Unexporting service");
                }                   
                exporter.unexport(true);
            } catch (Throwable t) {
-                if(initLogger.isLoggable(Levels.HANDLED)) {
-                    initLogger.log(Levels.HANDLED, "Trouble unexporting 
service", t);
+                if(INIT_LOGGER.isLoggable(Levels.HANDLED)) {
+                    INIT_LOGGER.log(Levels.HANDLED, "Trouble unexporting 
service", t);
                }                   
            }
        }
        
        if (joiner != null) {
            try {
-                if(initLogger.isLoggable(Level.FINEST)) {
-                    initLogger.log(Level.FINEST, "Terminating join manager");
+                if(INIT_LOGGER.isLoggable(Level.FINEST)) {
+                    INIT_LOGGER.log(Level.FINEST, "Terminating join manager");
                }                   
                joiner.terminate();
            } catch (Throwable t) {
-                if(initLogger.isLoggable(Levels.HANDLED)) {
-                    initLogger.log(Levels.HANDLED, 
+                if(INIT_LOGGER.isLoggable(Levels.HANDLED)) {
+                    INIT_LOGGER.log(Levels.HANDLED, 
                    "Trouble terminating join manager", t);
                }                   
            }
        }
        if (lookupDiscMgr != null) {
            try {
-                if(initLogger.isLoggable(Level.FINEST)) {
-                    initLogger.log(Level.FINEST, 
+                if(INIT_LOGGER.isLoggable(Level.FINEST)) {
+                    INIT_LOGGER.log(Level.FINEST, 
                    "Terminating lookup discovery manager");                
                }
                lookupDiscMgr.terminate();
            } catch (Throwable t) {
-                if(initLogger.isLoggable(Levels.HANDLED)) {
-                    initLogger.log(Levels.HANDLED, 
+                if(INIT_LOGGER.isLoggable(Levels.HANDLED)) {
+                    INIT_LOGGER.log(Levels.HANDLED, 
                    "Trouble terminating lookup discovery manager", t); 
                }           
            }
        }
        if (notifier != null) {
            try {
-                if(initLogger.isLoggable(Level.FINEST)) {
-                    initLogger.log(Level.FINEST, 
+                if(INIT_LOGGER.isLoggable(Level.FINEST)) {
+                    INIT_LOGGER.log(Level.FINEST, 
                        "Interrupting notifier");       
                }           
                notifier.interrupt();
            } catch (Throwable t) {
-                if(initLogger.isLoggable(Levels.HANDLED)) {
-                    initLogger.log(Levels.HANDLED, 
+                if(INIT_LOGGER.isLoggable(Levels.HANDLED)) {
+                    INIT_LOGGER.log(Levels.HANDLED, 
                        "Trouble interrupting notifier", t);                
                }
            }
        }
        if (expirer != null) {
            try {
-                if(initLogger.isLoggable(Level.FINEST)) {
-                    initLogger.log(Level.FINEST, 
+                if(INIT_LOGGER.isLoggable(Level.FINEST)) {
+                    INIT_LOGGER.log(Level.FINEST, 
                        "Interrupting expirer");
                }                   
                expirer.interrupt();
            } catch (Throwable t) {
-                if(initLogger.isLoggable(Levels.HANDLED)) {
-                    initLogger.log(Levels.HANDLED, 
+                if(INIT_LOGGER.isLoggable(Levels.HANDLED)) {
+                    INIT_LOGGER.log(Levels.HANDLED, 
                        "Trouble interrupting expirer", t);     
                }           
            }
        }
         if (snapshotter != null) {
            try {
-                if(initLogger.isLoggable(Level.FINEST)) {
-                    initLogger.log(Level.FINEST, 
+                if(INIT_LOGGER.isLoggable(Level.FINEST)) {
+                    INIT_LOGGER.log(Level.FINEST, 
                        "Interrupting snapshotter");
                }                   
                snapshotter.interrupt();
            } catch (Throwable t) {
-                if(initLogger.isLoggable(Levels.HANDLED)) {
-                    initLogger.log(Levels.HANDLED, 
+                if(INIT_LOGGER.isLoggable(Levels.HANDLED)) {
+                    INIT_LOGGER.log(Levels.HANDLED, 
                        "Trouble interrupting snapshotter", t); 
                }           
            }
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, "cleanup");
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, "cleanup");
        }
     }
 
@@ -1464,8 +1136,8 @@ class MailboxImpl implements MailboxBack
                 preparedTarget =
                     (RemoteEventListener) 
                        listenerPreparer.prepareProxy(target);
-                if(deliveryLogger.isLoggable(Level.FINEST)) {
-                    deliveryLogger.log(Level.FINEST, 
+                if(DELIVERY_LOGGER.isLoggable(Level.FINEST)) {
+                    DELIVERY_LOGGER.log(Level.FINEST, 
                        "prepared listener: {0}", preparedTarget);
                }
            } catch (RemoteException e) {
@@ -1610,8 +1282,8 @@ class MailboxImpl implements MailboxBack
 
     // This method's javadoc is inherited from an interface of this class
     public void destroy() {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "destroy");
        }
         readyState.check();
@@ -1633,8 +1305,8 @@ class MailboxImpl implements MailboxBack
             ServiceRegistration[] regs = 
                 (ServiceRegistration[])regByID.values().toArray(
                     new ServiceRegistration[regByID.size()]);
-            if (adminLogger.isLoggable(Level.FINEST)) {
-                adminLogger.log(Level.FINEST,
+            if (ADMIN_LOGGER.isLoggable(Level.FINEST)) {
+                ADMIN_LOGGER.log(Level.FINEST,
                     "Notifying {0} possible registrations",
                      Integer.valueOf(regByID.size()));
             }
@@ -1643,8 +1315,8 @@ class MailboxImpl implements MailboxBack
                 removeRegistration(regs[i].getCookie(), regs[i]);
                 // Notify any associated iterations so they can return early
                 regs[i].getIteratorCondition().signal();           
-                if(adminLogger.isLoggable(Level.FINEST)) {
-                    adminLogger.log(Level.FINEST, 
+                if(ADMIN_LOGGER.isLoggable(Level.FINEST)) {
+                    ADMIN_LOGGER.log(Level.FINEST, 
                         "Iterator for reg {0} notified",
                         regs[i]);
                 }
@@ -1654,8 +1326,8 @@ class MailboxImpl implements MailboxBack
        }        
         
        (new DestroyThread()).start();
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "destroy");
        }
     }
@@ -1667,15 +1339,15 @@ class MailboxImpl implements MailboxBack
 
     // This method's javadoc is inherited from an interface of this class
     public Entry[] getLookupAttributes() throws RemoteException {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "getLookupAttributes");
        }
         readyState.check();
        concurrentObj.readLock();
        try {
-            if (operationsLogger.isLoggable(Level.FINER)) {
-               operationsLogger.exiting(mailboxSourceClass, 
+            if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+               OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                    "getLookupAttributes");
             }
            return lookupAttrs;
@@ -1686,8 +1358,8 @@ class MailboxImpl implements MailboxBack
 
     // This method's javadoc is inherited from an interface of this class
     public void addLookupAttributes(Entry[] attrSets) throws RemoteException {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "addLookupAttributes");
        }
         readyState.check();
@@ -1701,8 +1373,8 @@ class MailboxImpl implements MailboxBack
        } finally {
            concurrentObj.writeUnlock();
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "addLookupAttributes");
        }
     }
@@ -1712,8 +1384,8 @@ class MailboxImpl implements MailboxBack
                                       Entry[] attrSets)
        throws RemoteException
     {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "modifyLookupAttributes");
        }
         readyState.check();
@@ -1727,8 +1399,8 @@ class MailboxImpl implements MailboxBack
        } finally {
            concurrentObj.writeUnlock();
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "modifyLookupAttributes");
        }
     }
@@ -1736,15 +1408,15 @@ class MailboxImpl implements MailboxBack
 
     // This method's javadoc is inherited from an interface of this class
     public String[] getLookupGroups() throws RemoteException {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "getLookupGroups");
        }
         readyState.check();
        concurrentObj.readLock();
        try {
-            if (operationsLogger.isLoggable(Level.FINER)) {
-               operationsLogger.exiting(mailboxSourceClass, 
+            if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+               OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                    "getLookupGroups");
            }
            return lookupGroups;
@@ -1755,8 +1427,8 @@ class MailboxImpl implements MailboxBack
 
     // This method's javadoc is inherited from an interface of this class
     public void addLookupGroups(String[] groups) throws RemoteException {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "addLookupGroups");
        }
         readyState.check();
@@ -1774,16 +1446,16 @@ class MailboxImpl implements MailboxBack
        } finally {
            concurrentObj.writeUnlock();
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "addLookupGroups");
        }
     }
 
     // This method's javadoc is inherited from an interface of this class
     public void removeLookupGroups(String[] groups) throws RemoteException {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "removeLookupGroups");
        }
         readyState.check();
@@ -1797,16 +1469,16 @@ class MailboxImpl implements MailboxBack
        } finally {
            concurrentObj.writeUnlock();
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "removeLookupGroups");
        }
     }
 
     // This method's javadoc is inherited from an interface of this class
     public void setLookupGroups(String[] groups) throws RemoteException {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "setLookupGroups");
        }
         readyState.check();
@@ -1824,23 +1496,23 @@ class MailboxImpl implements MailboxBack
        } finally {
            concurrentObj.writeUnlock();
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "setLookupGroups");
        }
     }
 
     // This method's javadoc is inherited from an interface of this class
     public LookupLocator[] getLookupLocators() throws RemoteException {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "getLookupLocators");
        }
         readyState.check();
        concurrentObj.readLock();
        try {
-            if (operationsLogger.isLoggable(Level.FINER)) {
-               operationsLogger.exiting(mailboxSourceClass, 
+            if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+               OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                    "getLookupLocators");
             }
            return lookupLocators;
@@ -1853,8 +1525,8 @@ class MailboxImpl implements MailboxBack
     public void addLookupLocators(LookupLocator[] locators)
        throws RemoteException
     {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "addLookupLocators");
        }
         readyState.check();
@@ -1871,8 +1543,8 @@ class MailboxImpl implements MailboxBack
        } finally {
            concurrentObj.writeUnlock();
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "addLookupLocators");
        }
     }
@@ -1881,8 +1553,8 @@ class MailboxImpl implements MailboxBack
     public void removeLookupLocators(LookupLocator[] locators)
        throws RemoteException
     {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "removeLookupLocators");
        }
         readyState.check();
@@ -1899,8 +1571,8 @@ class MailboxImpl implements MailboxBack
        } finally {
            concurrentObj.writeUnlock();
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "removeLookupLocators");
        }
     }
@@ -1909,8 +1581,8 @@ class MailboxImpl implements MailboxBack
     public void setLookupLocators(LookupLocator[] locators)
        throws RemoteException
     {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "setLookupLocators");
        }
         readyState.check();
@@ -1927,8 +1599,8 @@ class MailboxImpl implements MailboxBack
        } finally {
            concurrentObj.writeUnlock();
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "setLookupLocators");
        }
     }
@@ -1942,8 +1614,8 @@ class MailboxImpl implements MailboxBack
      * throw a UnknownEventException back to the event sender.
      */
     private void addUnknownEvent(Uuid regID, EventID evid) {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
            "addUnknownEvent", new Object[] {regID, evid});
        }
        concurrentObj.writeLock();
@@ -1952,8 +1624,8 @@ class MailboxImpl implements MailboxBack
        } finally {
            concurrentObj.writeUnlock();
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "addUnknownEvent");
        }
     }
@@ -1964,8 +1636,8 @@ class MailboxImpl implements MailboxBack
      * holds a write lock.
      */
     private void addUnknownEventDo(Uuid regID, EventID evid) {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
            "addUnknownEventDo", new Object[] {regID, evid});
        }
         //Ensure that the registration is still valid
@@ -1973,22 +1645,22 @@ class MailboxImpl implements MailboxBack
         if(reg == null || !ensureCurrent(reg)) {
             return; // nothing to do ... registration is gone
         }
-        if(deliveryLogger.isLoggable(Level.FINEST)) {
-            deliveryLogger.log(Level.FINEST, "Using reg: {0} ", reg);
+        if(DELIVERY_LOGGER.isLoggable(Level.FINEST)) {
+            DELIVERY_LOGGER.log(Level.FINEST, "Using reg: {0} ", reg);
         }
 
-        // TODO - check if already there and save a log record.
+        // TODO - check if already there and save a loG record.
         // Add EventID to the list
         reg.getUnknownEvents().put(evid, evid);
         // Log this event
         addLogRecord(new UnknownEventExceptionLogObj(regID, evid));
 
-        if(deliveryLogger.isLoggable(Level.FINEST)) {
-            deliveryLogger.log(Level.FINEST, "UnknownEvents size: {0}", 
+        if(DELIVERY_LOGGER.isLoggable(Level.FINEST)) {
+            DELIVERY_LOGGER.log(Level.FINEST, "UnknownEvents size: {0}", 
                 Integer.valueOf(reg.getUnknownEvents().size()));
         }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "addUnknownEventDo");
        }
     }
@@ -2007,8 +1679,8 @@ class MailboxImpl implements MailboxBack
     private ServiceRegistration getServiceRegistration(Uuid regID) 
         throws ThrowThis
     {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "getServiceRegistration", regID);
        }
         ServiceRegistration reg = (ServiceRegistration)regByID.get(regID); 
@@ -2022,8 +1694,8 @@ class MailboxImpl implements MailboxBack
                    "has expired"));
        }
        // Must be a valid registration at this point
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.exiting(MAILBOX_SOURCE_CLASS, 
                "getServiceRegistration", reg);
        }
        return reg;
@@ -2044,8 +1716,8 @@ class MailboxImpl implements MailboxBack
     private void removeRegistration(Uuid regID, ServiceRegistration reg,
                                     boolean initializing) 
     {
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.entering(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {
+           OPERATIONS_LOGGER.entering(MAILBOX_SOURCE_CLASS, 
                "removeRegistration", 
                new Object[] {regID, reg, Boolean.valueOf(initializing)});
        }
@@ -2063,24 +1735,24 @@ class MailboxImpl implements MailboxBack
        NotifyTask task = (NotifyTask)activeReg.remove(regID);
        if (task != null) { // cancel active task, if any
            task.cancel(false);
-           if(deliveryLogger.isLoggable(Level.FINEST)) {
-                deliveryLogger.log(Level.FINEST, 
+           if(DELIVERY_LOGGER.isLoggable(Level.FINEST)) {
+                DELIVERY_LOGGER.log(Level.FINEST, 
                    "Cancelling active notification task for {0}", regID);
            }
        }
 
        // Delete any associated resources
        try {
-           if(persistenceLogger.isLoggable(Level.FINEST)) {
-                persistenceLogger.log(Level.FINEST, 
+           if(PERSISTENCE_LOGGER.isLoggable(Level.FINEST)) {
+                PERSISTENCE_LOGGER.log(Level.FINEST, 
                    "Removing logs for {0}", reg);
             }
            EventLogIterator iter = reg.iterator();
            if (iter != null) // iter is null when recovering state
                iter.destroy();
        } catch (IOException ioe) {
-           if(persistenceLogger.isLoggable(Levels.HANDLED)) {
-                persistenceLogger.log(Levels.HANDLED, 
+           if(PERSISTENCE_LOGGER.isLoggable(Levels.HANDLED)) {
+                PERSISTENCE_LOGGER.log(Levels.HANDLED, 
                    "Trouble removing logs", ioe);
            }
            // Did the best we could ... continue.
@@ -2089,15 +1761,15 @@ class MailboxImpl implements MailboxBack
 
        // Sanity check
        if (exists && task != null) {
-           if(leaseLogger.isLoggable(Level.SEVERE)) {
-                leaseLogger.log(Level.SEVERE, 
+           if(LEASE_LOGGER.isLoggable(Level.SEVERE)) {
+                LEASE_LOGGER.log(Level.SEVERE, 
                    "ERROR: Registration was found "
                    + "on both the active and pending lists");
            }
 // TODO (FCS)- throw assertion error
        }
-        if (operationsLogger.isLoggable(Level.FINER)) {
-           operationsLogger.exiting(mailboxSourceClass, 
+        if (OPERATIONS_LOGGER.isLoggable(Level.FINER)) {

[... 2054 lines stripped ...]

Reply via email to