SLING-10624: Callback when SlingRepository init fails
diff --git a/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepositoryManager.java b/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepositoryManager.java
index 9d64d0c..2d440c4 100644
--- a/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepositoryManager.java
+++ b/src/main/java/org/apache/sling/jcr/base/AbstractSlingRepositoryManager.java
@@ -71,6 +71,10 @@
  * Earlier versions of this class had an additional <code>setup</code> method,
  * whatever code was there can be moved to the <code>create</code> method.
  * <p>
+ * If starting the repository fails, the method {@link #initializeAndRegisterRepositoryServiceFailed(Throwable)}
+ * will be called. By default the exception is logged as an error, but this can
+ * be customized by overwriting the method.
+ * <p>
  * To stop the repository instance, the implementation calls the {@link #stop()}
  * method which goes through the setps of unregistering the OSGi service,
  * tearing all special settings down and finally shutting down the repository:
@@ -339,6 +343,18 @@
      */
     protected abstract void disposeRepository(Repository repository);
 
+    /**
+     * Called when the repository service cannot be initialized or registered
+     * because an exception occurred.
+     * <p>
+     * This default implementation logs the exception as an error.
+     *
+     * @param t the exception.
+     */
+    protected void initializeAndRegisterRepositoryServiceFailed(Throwable t) {
+        log.error("start: Uncaught Throwable trying to access Repository, calling stop()", t);
+    }
+
     // --------- SCR integration -----------------------------------------------
 
     /**
@@ -570,7 +586,7 @@
             }
         } catch (Throwable e) {
             // consider an uncaught problem an error
-            log.error("start: Uncaught Throwable trying to access Repository, calling stop()", e);
+            initializeAndRegisterRepositoryServiceFailed(e);
             stop();
         }
     }
diff --git a/src/main/java/org/apache/sling/jcr/base/package-info.java b/src/main/java/org/apache/sling/jcr/base/package-info.java
index 17931fe..7aec8e7 100644
--- a/src/main/java/org/apache/sling/jcr/base/package-info.java
+++ b/src/main/java/org/apache/sling/jcr/base/package-info.java
@@ -25,7 +25,7 @@
  * {@link org.apache.sling.jcr.base.AbstractSlingRepository2} being the
  * basis for the repository service instance handed to using bundles.
  */
-@org.osgi.annotation.versioning.Version("3.4.0")
+@org.osgi.annotation.versioning.Version("3.5.0")
 package org.apache.sling.jcr.base;