From 8ed24d57f423f11acc2a5c0ccdea5d3e685d8189 Mon Sep 17 00:00:00 2001
From: Fabio Pistolesi <fabio.pistolesi@forgerock.com>
Date: Tue, 24 Mar 2015 15:41:13 +0000
Subject: [PATCH] OPENDJ-1884 CR-6447 Revise {configure,initialize,finalize}Backend calls.

---
 opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java |   48 ++++++++++++++++++++++++++++--------------------
 1 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java b/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
index c36885c..6f13f57 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
@@ -113,8 +113,9 @@
       new ConcurrentLinkedQueue<PersistentSearch>();
 
   /**
-   * Configure this backend based on the information in the provided
-   * configuration.
+   * Configure this backend based on the information in the provided configuration.
+   * When the method returns, the backend will have been configured (ready to be opened) but still unable
+   * to process operations.
    *
    * @param  cfg          The configuration of this backend.
    * @param  serverContext The server context for this instance
@@ -155,44 +156,51 @@
   }
 
   /**
-   * Initializes this backend based on the information provided
-   * when the backend was configured.
+   * Opens this backend based on the information provided when the backend was configured.
+   * It also should open any underlying storage and register all suffixes with the server.
    *
    * @see #configureBackend
    *
-   * @throws  ConfigException  If an unrecoverable problem arises in
-   *                           the process of performing the
-   *                           initialization.
+   * @throws  ConfigException  If an unrecoverable problem arises while opening the backend.
    *
-   * @throws  InitializationException  If a problem occurs during
-   *                                   initialization that is not
-   *                                   related to the server
-   *                                   configuration.
+   * @throws  InitializationException  If a problem occurs during opening that is not
+   *                                   related to the server configuration.
    */
-  public abstract void initializeBackend() throws ConfigException, InitializationException;
+  public abstract void openBackend() throws ConfigException, InitializationException;
 
   /**
-   * Performs any necessary work to finalize this backend, including
-   * closing any underlying databases or connections and deregistering
-   * any suffixes that it manages with the Directory Server. This may
-   * be called during the Directory Server shutdown process or if a
-   * backend is disabled with the server online.
+   * Performs any necessary work to finalize this backend. The backend must be an opened backend,
+   * so do not use this method on backends where only <code>configureBackend()</code> has been called.
+   * This may be called during the Directory Server shutdown process or if a backend is disabled
+   * with the server online.
    * It must not return until the backend is closed.
    * <p>
    * This method may not throw any exceptions. If any problems are encountered,
    * then they may be logged but the closure should progress as completely as
    * possible.
    * <p>
-   * This method must be called by all overriding methods with
-   * <code>super.finalizeBackend()</code>.
    */
-  public void finalizeBackend()
+  public final void finalizeBackend()
   {
     for (PersistentSearch psearch : persistentSearches)
     {
       psearch.cancel();
     }
     persistentSearches.clear();
+    closeBackend();
+  }
+
+  /**
+   * Performs any necessary work to finally close this backend, particularly
+   * closing any underlying databases or connections and deregistering
+   * any suffixes that it manages with the Directory Server.
+   * <p>
+   * It will be called as final step of <code>finalizeBackend()</code>,
+   * so subclasses might override it.
+   * </p>
+   */
+  public void closeBackend()
+  {
   }
 
   /**

--
Gitblit v1.10.0