You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2022/04/25 04:47:13 UTC

[sling-org-apache-sling-feature-launcher] branch master updated: Refactory code for getting framework factory

This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git


The following commit(s) were added to refs/heads/master by this push:
     new e4b1a72  Refactory code for getting framework factory
e4b1a72 is described below

commit e4b1a726354dde6b54ec57fd98120778c26c84e4
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Apr 25 06:46:45 2022 +0200

    Refactory code for getting framework factory
---
 .../feature/launcher/impl/launchers/FrameworkRunner.java    | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkRunner.java b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkRunner.java
index fd77c01..a0d8654 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkRunner.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkRunner.java
@@ -52,7 +52,12 @@ public class FrameworkRunner extends AbstractRunner {
         this.bundlesMap = bundlesMap;
     }
     
-    public Integer call() throws Exception {
+    /**
+     * Get the framework factory
+     * @return Return the first factory found via service loaders
+     * @throws Exception If no factory can be found
+     */
+    protected FrameworkFactory getFrameworkFactory() throws Exception {
         final ServiceLoader<FrameworkFactory> loader = ServiceLoader.load(FrameworkFactory.class);
         FrameworkFactory factory = null;
         for(FrameworkFactory f : loader) {
@@ -62,6 +67,12 @@ public class FrameworkRunner extends AbstractRunner {
         if ( factory == null ) {
             throw new Exception("Unable to locate framework factory.");
         }
+        return factory;
+    }
+
+    public Integer call() throws Exception {
+        // get the framework factory
+        final FrameworkFactory factory = this.getFrameworkFactory();
 
         // create the framework
         final Framework framework = factory.newFramework(frameworkProperties);