changeset 5546:8a37a928eff8

RT-30793 Load packaging bundlers via ServiceLoader [mhowe] Contributed-by: Danno Ferrin <danno.ferrin@shemnon.com>
author mhowe
date Fri, 25 Oct 2013 10:31:22 -0700
parents 46b5f4358826
children d340373b2198
files modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/bundlers/Bundler.java modules/fxpackager/src/main/resources/META-INF/services/com.sun.javafx.tools.packager.bundlers.Bundler
diffstat 2 files changed, 11 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/bundlers/Bundler.java	Fri Oct 25 09:21:51 2013 -0700
+++ b/modules/fxpackager/src/main/java/com/sun/javafx/tools/packager/bundlers/Bundler.java	Fri Oct 25 10:31:22 2013 -0700
@@ -34,6 +34,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.ServiceLoader;
 import java.util.Set;
 
 public abstract class Bundler {
@@ -77,18 +78,7 @@
         }
     };
 
-    private static final List<Bundler> knownBundlers = new LinkedList<Bundler>();
-
-    static {
-        knownBundlers.add(new WinAppBundler());
-        knownBundlers.add(new MacAppBundler());
-        knownBundlers.add(new WinMsiBundler());
-        knownBundlers.add(new WinExeBundler());
-        knownBundlers.add(new MacDMGBundler());
-        knownBundlers.add(new LinuxAppBundler());
-        knownBundlers.add(new LinuxRPMBundler());
-        knownBundlers.add(new LinuxDebBundler());
-    }
+   private static ServiceLoader<Bundler> bundlerLoader = ServiceLoader.load(Bundler.class);
 
     protected void setBuildRoot(File dir) {
         buildRoot = dir;
@@ -107,7 +97,7 @@
 
         Log.verbose("Looking for bundlers for type=" + p.type.toString()
                 + " format=" + (p.bundleFormat.isEmpty() ? "any" : p.bundleFormat.toString()));
-        for (Bundler b: knownBundlers) {
+        for (Bundler b: bundlerLoader) {
             if (verbose) {
                 b.setVerbose(true);
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/fxpackager/src/main/resources/META-INF/services/com.sun.javafx.tools.packager.bundlers.Bundler	Fri Oct 25 10:31:22 2013 -0700
@@ -0,0 +1,8 @@
+com.sun.javafx.tools.packager.bundlers.LinuxAppBundler
+com.sun.javafx.tools.packager.bundlers.LinuxDebBundler
+com.sun.javafx.tools.packager.bundlers.LinuxRPMBundler
+com.sun.javafx.tools.packager.bundlers.MacAppBundler
+com.sun.javafx.tools.packager.bundlers.MacDMGBundler
+com.sun.javafx.tools.packager.bundlers.WinAppBundler
+com.sun.javafx.tools.packager.bundlers.WinExeBundler
+com.sun.javafx.tools.packager.bundlers.WinMsiBundler
\ No newline at end of file