BootStrap { public static void main(final String[] args) throws IOException { final Map<String, String> arguments = Arguments.loadArguments(args, "keystone.properties"); final Boolean consoleLocationNeedHome = BootStrap.initializeConsoleLevel(arguments); if (!consoleLocationNeedHome) { BootStrap.initializeConsoleLogLocation(arguments, null); } Console.VERBOSE("Arguments " + arguments); ExtractionManager.initialize(arguments); String minimalJvmVersion = Arguments.getStringArgument(arguments, "BootStrap.minimalJvmVersion", null); if (minimalJvmVersion != null) { if (!SimpleVersion.isCompatible(minimalJvmVersion)) { Console.WARNING("JVM Specification Version " + SimpleVersion.getCurrentJavaVirtualMachineSpecificationVersion() + " is not compatible with specified requirement : '" + minimalJvmVersion + "'"); return; } } final String location = BootStrap.getCodeSourceLocation(); if ((location == null) || "".equals(location)) { Console.WARNING("Cannot Find Code Source location"); return; } final File home; try { home = BootStrap.getHomeDirectory(arguments, location); } catch (final IllegalStateException e) { Console.WARNING(e.getMessage(), e); return; } Console.INFO("Home Directory=" + home.getPath()); if (consoleLocationNeedHome) { BootStrap.initializeConsoleLogLocation(arguments, home); } final String mainClassName = Arguments.getStringArgument(arguments, Attributes.Name.MAIN_CLASS.toString(), null); if (mainClassName == null) { Console.WARNING("No Main-Class Found"); return; } Console.INFO("Main-Class=" + mainClassName); if (!ExtractionManager.explode(location, home)) { return; } if (Arguments.getBooleanArgument(arguments, "BootStrap.cleanUpBeforeShutdown", Boolean.TRUE)) { ExtractionManager.cleanUpHook(home); } List<URL> urls = null; try { urls = BootStrap.computeClassPath(home, arguments); } catch (final IllegalStateException ise) { return; } final ClassLoader classloader = new URLClassLoader(urls.toArray(new URL[urls.size()]), ClassLoader.getSystemClassLoader()) { @Override protected String findLibrary(final String libname) { String libPath = JniLoader.findLibrary(new File(home, "lib"), libname); if (libPath == null) { libPath = JniLoader.findLibraryInClassPath(libname, new File(home, "lib-natives")); if (libPath == null) { return super.findLibrary(libname); } } return libPath; } }; System.getProperties().put("BootStrap.location", location); System.getProperties().put("BootStrap.home", home.getPath()); System.getProperties().put("BootStrap.keystone.version", Arguments.getStringArgument(arguments, "BootStrap.keystone.version", "unknown")); System.getProperties().put("BootStrap.project.version", Arguments.getStringArgument(arguments, "BootStrap.project.version", "unknown")); BootStrap.invokeMain(classloader, mainClassName, args, home); Console.INFO("Exit"); }  static void main(final String[] args); static void processKeystoneException(final File home, final Throwable exception); static Throwable findRootCause(final Throwable throwable); static void restart(final Runnable runnable);  }
@Test public void testLaunch() throws Exception { BootStrap.main(new String[] { Main.class.getName() }); }
@Test public void testLaunchFromDefault() throws Exception { BootStrap.main(new String[] {}); }
@Test public void testLaunchWithExternal() throws Exception { BootStrap.main(new String[] { "--Main-Class=" + MainExternalCheck.class.getName(), "--BootStrap.explodeDirectory=." + File.separator + "target" + File.separator + "test-home", "--BootStrap.extraLibrariesFolderPath=src" + File.separator + "external-resources-test" }); }