Skip to content

The Unified and Autonomous Development Platform

Remove Launcher as it turns out that slow starting is caused by anti-virus software.

robin shineeb2468574ff8
diff --git a/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/Bootstrap.java b/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/Bootstrap.java
index 3058051f30..c365d2621f 100644
--- a/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/Bootstrap.java
+++ b/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/Bootstrap.java
@@ -36,6 +36,44 @@ public class Bootstrap {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
+ File sandboxDir = new File("target/sandbox");
+ if (sandboxDir.exists()) {
+ Map<String, File> systemClasspath = (Map<String, File>) BootstrapUtils
+ .readObject(new File(sandboxDir, "bin/system.classpath"));
+ Set<String> bootstrapKeys = (Set<String>) BootstrapUtils
+ .readObject(new File(sandboxDir, "bin/bootstrap.keys"));
+
+ List<URL> urls = new ArrayList<URL>();
+ for (String key: bootstrapKeys) {
+ File file = systemClasspath.get(key);
+ if (file == null)
+ throw new RuntimeException("Unable to find bootstrap file for '" + key + "'.");
+ try {
+ urls.add(file.toURI().toURL());
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ URLClassLoader bootClassLoader = new URLClassLoader(
+ urls.toArray(new URL[0]),
+ Bootstrap.class.getClassLoader().getParent());
+ Thread.currentThread().setContextClassLoader(bootClassLoader);
+
+ try {
+ Class<?> bootstrapClass = bootClassLoader.loadClass(Bootstrap.class.getName());
+ bootstrapClass.getMethod("boot", String[].class).invoke(null, new Object[]{args});
+ } catch (Exception e) {
+ throw BootstrapUtils.unchecked(e);
+ }
+
+ } else {
+ boot(args);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static void boot(String[] args) {
File loadedFrom = new File(Bootstrap.class.getProtectionDomain()
.getCodeSource().getLocation().getFile());
diff --git a/commons.product/src/main/java/com/pmease/commons/product/Launcher.java b/commons.product/src/main/java/com/pmease/commons/product/Launcher.java
deleted file mode 100644
index 923d3def56..0000000000
--- a/commons.product/src/main/java/com/pmease/commons/product/Launcher.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.pmease.commons.product;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * This class should only be used to launch the application from within IDE.
- * To launch from command line, call Bootstrap instead.
- * @author robin
- *
- */
-public class Launcher {
-
- private static Object readObject(File file) {
- ObjectInputStream ois = null;
- try {
- ois = new ObjectInputStream(new FileInputStream(file));
- return ois.readObject();
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- } finally {
- if (ois != null) {
- try {
- ois.close();
- } catch (IOException e) {
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public static void main(String[] args) {
- File sandboxDir = new File("target/sandbox");
- if (sandboxDir.exists()) {
- Map<String, File> systemClasspath = (Map<String, File>) readObject(
- new File(sandboxDir, "bin/system.classpath"));
- Set<String> bootstrapKeys = (Set<String>) readObject(
- new File(sandboxDir, "bin/bootstrap.keys"));
-
- List<URL> urls = new ArrayList<URL>();
- for (String key: bootstrapKeys) {
- File file = systemClasspath.get(key);
- if (file == null)
- throw new RuntimeException("Unable to find bootstrap file for '" + key + "'.");
- try {
- urls.add(file.toURI().toURL());
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- }
-
- URLClassLoader bootClassLoader = new URLClassLoader(
- urls.toArray(new URL[0]),
- Launcher.class.getClassLoader().getParent());
- Thread.currentThread().setContextClassLoader(bootClassLoader);
-
- try {
- Class<?> bootstrapClass = bootClassLoader.loadClass("com.pmease.commons.bootstrap.Bootstrap");
- bootstrapClass.getMethod("main", String[].class).invoke(null, new Object[]{args});
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- } catch (IllegalArgumentException e) {
- throw new RuntimeException(e);
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
-
- } else {
- throw new RuntimeException("Unable to find sandbox directory: " + sandboxDir);
- }
- }
-
-}