![]() |
![]() |
wms-winstone-1.0.5-boot16:54:37.792 INFO jd.cli.Main - Decompiling wms-winstone-1.0.5-boot.jar package org.intelligentsia.keystone.boot; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; public class Arguments { public static Map<String, String> loadArguments(String[] argv) { Map<String, String> result = new HashMap(); if (argv != null) { for (int i = 0; i < argv.length; i++) { String option = argv[i]; if (option.startsWith("--")) { int equalPos = option.indexOf('='); String paramName = option.substring(2, equalPos == -1 ? option.length() : equalPos); if (equalPos != -1) { result.put(paramName, option.substring(equalPos + 1)); } else { result.put(paramName, Boolean.TRUE.toString()); } } else { result.put(option, option); } } } return result; } public static String[] argumentToArray(Map<String, String> arguments) { List<String> result = new ArrayList(); for (Map.Entry<String, String> entry : arguments.entrySet()) { if (((String)entry.getKey()).equals(entry.getValue())) { result.add(entry.getKey()); } else if (((String)entry.getValue()).equals(Boolean.TRUE.toString())) { result.add("--" + (String)entry.getKey()); } else { result.add("--" + (String)entry.getKey() + "=" + (String)entry.getValue()); } } return (String[])result.toArray(new String[0]); } public static Map<String, String> loadArguments(String[] argv, String name) throws IOException { Map<String, String> arguments = loadArguments(argv); loadPropsFrom("file:" + name, arguments); loadPropsFrom("META-INF/" + name, arguments); loadPropsFrom("/" + name, arguments); loadPropsFrom(name, arguments); return arguments; } public static Boolean getBooleanArgument(Map<String, String> args, String name, Boolean defaultTrue) { String value = (String)args.get(name); if ((defaultTrue != null) && (defaultTrue.booleanValue())) { return Boolean.valueOf((value == null) || (value.equalsIgnoreCase("true")) || (value.equalsIgnoreCase("yes"))); } return Boolean.valueOf((value != null) && ((value.equalsIgnoreCase("true")) || (value.equalsIgnoreCase("yes")))); } public static String getStringArgument(Map<String, String> args, String name, String defaultValue) { return args.get(name) == null ? defaultValue : (String)args.get(name); } public static Integer getIntegerArgument(Map<String, String> args, String name, Integer defaultValue) { try { return Integer.valueOf(Integer.parseInt(getStringArgument(args, name, Integer.toString(defaultValue.intValue())))); } catch (NumberFormatException exception) {} return defaultValue; } private static void loadPropsFrom(String name, Map<String, String> args) throws IOException { InputStream is = null; try { is = BootStrap.class.getClassLoader().getResourceAsStream(name); if (is != null) { Properties properties = new Properties(); properties.load(is); for (Iterator<Object> i = properties.keySet().iterator(); i.hasNext();) { String key = ((String)i.next()).trim(); if (!args.containsKey(key)) { args.put(key, properties.getProperty(key)); } } properties.clear(); } return; } finally { if (is != null) { try { is.close(); } catch (IOException exception) { Console.VERBOSE("Closing Error", exception); } } } } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.Arguments * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; import java.io.File; import java.net.URL; import java.net.URLClassLoader; final class BootStrap$1 extends URLClassLoader { BootStrap$1(URL[] x0, ClassLoader x1, File paramFile) { super(x0, x1); } protected String findLibrary(String libname) { String libPath = JniLoader.findLibrary(new File(val$home, "lib"), libname); if (libPath == null) { libPath = JniLoader.findLibraryInClassPath(libname, new File(val$home, "lib-natives")); if (libPath == null) { return super.findLibrary(libname); } } return libPath; } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.BootStrap.1 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; import java.io.File; final class BootStrap$2 implements Runnable { BootStrap$2(File paramFile) {} public void run() { ExtractionManager.cleanUp(val$home, Boolean.TRUE); } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.BootStrap.2 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; class BootStrap$3 {} /* Location: * Qualified Name: org.intelligentsia.keystone.boot.BootStrap.3 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; import java.net.URLClassLoader; import java.net.URLDecoder; import java.security.CodeSource; import java.security.ProtectionDomain; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.jar.Attributes.Name; public final class BootStrap { private static final String HOME_VAR = "#[home]"; public static void main(String[] args) throws IOException { Map<String, String> arguments = Arguments.loadArguments(args, "keystone.properties"); Boolean consoleLocationNeedHome = initializeConsoleLevel(arguments); if (!consoleLocationNeedHome.booleanValue()) { initializeConsoleLogLocation(arguments, null); } Console.VERBOSE("Arguments " + arguments); ExtractionManager.initialize(arguments); String location = getCodeSourceLocation(); if ((location == null) || ("".equals(location))) { Console.WARNING("Cannot Find Code Source location"); return; } final File home; try { home = getHomeDirectory(arguments, location); } catch (IllegalStateException e) { Console.WARNING(e.getMessage(), e); return; } Console.INFO("Home Directory=" + home.getPath()); if (consoleLocationNeedHome.booleanValue()) { initializeConsoleLogLocation(arguments, home); } 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; } List<URL> urls = null; try { urls = computeClassPath(home, arguments); } catch (IllegalStateException ise) { return; } ClassLoader classloader = new URLClassLoader((URL[])urls.toArray(new URL[urls.size()]), Arguments.getBooleanArgument(arguments, "BootStrap.includeSystemClassLoader", Boolean.FALSE).booleanValue() ? ClassLoader.getSystemClassLoader() : ClassLoader.getSystemClassLoader().getParent()) { protected String findLibrary(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")); invokeMain(classloader, mainClassName, args, home); if (Arguments.getBooleanArgument(arguments, "BootStrap.cleanUpBeforeShutdown", Boolean.FALSE).booleanValue()) { ExtractionManager.cleanUp(home, Boolean.TRUE); } Console.INFO("Exit"); } private static Boolean initializeConsoleLevel(Map<String, String> arguments) { Boolean needHome = Boolean.FALSE; String logfileName = Arguments.getStringArgument(arguments, "BootStrap.logFile", null); if (logfileName != null) { needHome = Boolean.valueOf(logfileName.indexOf("#[home]") >= 0); } Console.setInfo(Arguments.getBooleanArgument(arguments, "BootStrap.info", Boolean.TRUE)); Console.setVerbose(Arguments.getBooleanArgument(arguments, "BootStrap.verbose", Boolean.FALSE)); return needHome; } private static void initializeConsoleLogLocation(Map<String, String> arguments, File home) { String logfileName = Arguments.getStringArgument(arguments, "BootStrap.logFile", null); if (logfileName != null) { File log = null; int index = logfileName.indexOf("#[home]"); if (index >= 0) { log = new File(home, logfileName.substring("#[home]".length())); } else { log = new File(logfileName); } Console.setLogFile(log); } } private static List<URL> computeClassPath(File home, Map<String, String> arguments) throws IllegalStateException { Boolean includeJavaHomeLib = Arguments.getBooleanArgument(arguments, "BootStrap.includeJavaHomeLib", Boolean.TRUE); String javaHome = System.getProperty("java.home", null); List<URL> urls = new ArrayList(); if (includeJavaHomeLib.booleanValue()) { Console.VERBOSE("Including Java Home Libraries"); try { if (javaHome != null) { urls.addAll(computeFromDirectory(new File(javaHome, "lib"))); } else { Console.WARNING("Java Home property is not set"); } } catch (MalformedURLException ex) { Console.WARNING("error when including JavaHomeLib :" + ex.getMessage()); throw new IllegalStateException("error when including JavaHomeLib", ex); } } try { urls.addAll(computeFromDirectory(new File(home, "lib"))); } catch (MalformedURLException ex) { Console.WARNING("error when including './lib' :" + ex.getMessage()); throw new IllegalStateException("error when including './lib'", ex); } String extraLibrariesFolderPath = Arguments.getStringArgument(arguments, "BootStrap.extraLibrariesFolderPath", null); if (extraLibrariesFolderPath != null) { try { File extra = new File(extraLibrariesFolderPath); if (!extra.exists()) { extra = new File(home, extraLibrariesFolderPath); } urls.addAll(computeFromDirectory(extra)); } catch (MalformedURLException e) { Console.WARNING("error when including '" + extraLibrariesFolderPath + "' :" + e.getMessage()); throw new IllegalStateException("error when including '" + extraLibrariesFolderPath + "'", e); } } Console.VERBOSE("ClassPath: " + urls.toString()); return urls; } private static void invokeMain(ClassLoader classloader, String mainClassName, String[] arguments, File home) throws SecurityException { Class<?> mainClass = null; try { Thread.currentThread().setContextClassLoader(classloader); mainClass = classloader.loadClass(mainClassName); } catch (ClassNotFoundException ex) { Console.WARNING("class '" + mainClassName + "' not found: " + ex.getMessage()); } if (mainClass != null) { Method main = null; try { main = mainClass.getMethod("main", new Class[] { String[].class }); } catch (NoSuchMethodException ex) { Console.WARNING("class '" + mainClassName + "' did not have a method 'main': " + ex.getMessage()); } catch (SecurityException ex) { Console.WARNING("class '" + mainClassName + "', can not access to 'main' method : " + ex.getMessage()); } if (main != null) { main.setAccessible(true); Console.VERBOSE("Entering main"); try { main.invoke(null, new Object[] { arguments }); Console.VERBOSE("Exiting main"); } catch (KeystoneException e) { switch (e.getOperation()) { case CLEAN: Console.VERBOSE("Cleanning before shutdown"); ExtractionManager.cleanUp(home); break; case RESTART: Console.VERBOSE("Restarting"); restart(new Runnable() { public void run() { ExtractionManager.cleanUp(val$home, Boolean.TRUE); } }); break; case NONE: Console.WARNING("KeystoneException without operation: " + e.getMessage(), e); break; default: Console.WARNING("KeystoneException operation not supported '" + e.getOperation() + "': " + e.getMessage(), e); } } catch (IllegalAccessException ex) { Console.WARNING("class '" + mainClassName + "', can not access to 'main' method : " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { Console.WARNING("class '" + mainClassName + "', problem with argument of 'main' method : " + ex.getMessage(), ex); } catch (InvocationTargetException ex) { Console.WARNING("class '" + mainClassName + "', exception occur when invoking 'main' method : " + ex.getMessage(), ex); } catch (Throwable ex) { Console.WARNING("class '" + mainClassName + "', exception occur : " + ex.getMessage(), ex); } } else { Console.WARNING("The main() method in class '" + mainClassName + "' not found."); } } } private static List<URL> computeFromDirectory(File directory) throws MalformedURLException { List<URL> urls = new ArrayList(); if ((directory.exists()) && (directory.isDirectory())) { for (File child : directory.listFiles()) { if (child.isDirectory()) { urls.addAll(computeFromDirectory(new File(child.getPath()))); } else if (child.getName().endsWith(".jar")) { urls.add(child.toURI().toURL()); } } } return urls; } private static String getCodeSourceLocation() { String root = null; ProtectionDomain protectionDomain = BootStrap.class.getProtectionDomain(); CodeSource codeSource = protectionDomain.getCodeSource(); URL rootUrl = codeSource.getLocation(); try { root = URLDecoder.decode(rootUrl.getFile(), "UTF-8"); } catch (UnsupportedEncodingException ex) { Console.WARNING("Unable to decode '" + rootUrl.getFile() + "' " + ex.getMessage(), ex); } return root; } private static File getHomeDirectory(Map<String, String> arguments, String location) throws IllegalStateException { String path = Arguments.getStringArgument(arguments, "BootStrap.explodeDirectory", location != null ? new File(location).getParentFile().getAbsolutePath() : null); try { File home = path != null ? new File(path) : ExtractionManager.createTempDir(); if (!home.canWrite()) { Console.WARNING("Home Directory is not Writable, using a temp directory."); try { home = ExtractionManager.createTempDir(); } catch (IOException e) { throw new IllegalStateException("Unable to create home temp directory.", e); } } if (!home.isDirectory()) { throw new IllegalStateException(home.getPath() + " is not a directory"); } return home; } catch (IOException e) { throw new IllegalStateException("Unable to create home temp directory.", e); } } public static void restart(Runnable runnable) { Console.VERBOSE("(Restart with '" + System.getProperty("BootStrap.location") + "'"); Restarter.restartWith(runnable, new String[] { "-jar ", System.getProperty("BootStrap.location") }); } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.BootStrap * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Console { private static Boolean info = Boolean.TRUE; private static Boolean verbose = Boolean.FALSE; public static void setInfo(Boolean info) { info = info; } public static void setVerbose(Boolean verbose) { verbose = verbose; } public static void setLogFile(File logFile) { if (logFile != null) { if ((!logFile.getParentFile().exists()) && (!logFile.getParentFile().mkdirs())) { WARNING("Unable to create path for log file " + logFile.getPath()); return; } BufferedOutputStream log = null; try { log = new BufferedOutputStream(new FileOutputStream(logFile, true)); System.setOut(new PrintStream(log, true)); System.setErr(new PrintStream(log, true)); } catch (FileNotFoundException ex) {} } } public static void VERBOSE(String message) { VERBOSE(message, null); } public static void VERBOSE(String message, Throwable throwable) { if (verbose.booleanValue()) { System.out.println(getGmtDate(new Date()) + ", BootStrap: " + message); if (throwable != null) { throwable.printStackTrace(System.err); } } } public static void WARNING(String message, Throwable throwable) { System.err.println(getGmtDate(new Date()) + ", BootStrap Warning: " + message); if (throwable != null) { throwable.printStackTrace(System.err); } } public static void WARNING(String message) { WARNING(message, null); } public static void INFO(String message) { if (info.booleanValue()) { System.out.println(getGmtDate(new Date()) + ", BootStrap Info: " + message); } } private static String getGmtDate(Date when) { SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss S", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat.format(when) + " GMT"; } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.Console * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; import java.io.Closeable; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URLDecoder; import java.util.Collections; import java.util.Map; import java.util.UUID; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.zip.ZipException; public class ExtractionManager { private static Boolean cleanUpLib = Boolean.TRUE; public static void initialize(Map<String, String> arguments) { cleanUpLib = Arguments.getBooleanArgument(arguments, "BootStrap.cleanUpLib", Boolean.TRUE); } public static boolean explode(String location, File home) { cleanUp(home); try { if (location != null) { explode(new File(home, "lib"), "META-INF/lib/", location, Boolean.FALSE); explode(new File(home, "lib"), "lib/", location, Boolean.FALSE); } else { Console.WARNING("Error when exploding : Location is null"); } } catch (Throwable t) { Console.WARNING("Error when exploding : " + t.getMessage(), t); return false; } return true; } public static void cleanUp(File home) { cleanUp(home, Boolean.FALSE); } public static void cleanUp(File home, Boolean force) { if ((cleanUpLib.booleanValue()) || (force.booleanValue())) { Console.VERBOSE("Clean up lib"); File lib = new File(home, "lib"); if ((lib.exists()) && (!delete(lib))) { Console.WARNING("Unable to Clean up lib folder"); } } } public static File createTempDir() throws IOException { File sysTempDir = new File(System.getProperty("java.io.tmpdir")); int maxAttempts = 9; int attemptCount = 0; File newTempDir; do { attemptCount++; if (attemptCount > 9) { throw new IOException("The highly improbable has occurred! Failed to create a unique temporary directory after 9 attempts."); } String dirName = UUID.randomUUID().toString(); newTempDir = new File(sysTempDir, dirName); } while (newTempDir.exists()); if (newTempDir.mkdirs()) { return newTempDir; } throw new IOException("Failed to create temp dir named " + newTempDir.getAbsolutePath()); } public static void close(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (IOException exception) { Console.VERBOSE("Closing Error", exception); } } } public static boolean delete(File from) { if ((from != null) && (from.exists())) { if (from.isDirectory()) { for (File child : from.listFiles()) { delete(child); } } return from.delete(); } return false; } private static void explode(File home, String fromPath, String jarPath, Boolean override) throws IOException, ZipException { File check = new File(jarPath); JarFile jar; if ((check.exists()) && (!check.isDirectory())) { jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8")); for (JarEntry entry : Collections.list(jar.entries())) { String name = entry.getName(); if (name.startsWith(fromPath)) { Console.VERBOSE("Exploding: " + name); String targetName = name.substring(fromPath.length()).trim(); if (!"".equals(targetName)) { File localFile = new File(home, targetName); if ((override.booleanValue()) && (localFile.exists())) { localFile.delete(); } if (!localFile.exists()) { explodeEntry(targetName, localFile, jar, name); } } } } } } private static void explodeEntry(String targetName, File localFile, JarFile jar, String name) throws IOException { if (targetName.endsWith("/")) { if (!localFile.mkdirs()) { throw new IOException("Unable to create directory '" + localFile.getPath() + "'"); } } else if (!localFile.exists()) { File parent = localFile.getParentFile(); if ((parent != null) && (!parent.exists()) && (!parent.mkdirs())) { throw new IOException("Parent File Of '" + localFile.getPath() + "' could not be created"); } if (!localFile.createNewFile()) { throw new IOException("Unable to create file " + localFile.getPath()); } InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = jar.getInputStream(jar.getEntry(name)); if (inputStream == null) { throw new IOException("Unable to access resource '" + name + "'"); } outputStream = new FileOutputStream(localFile); byte[] buf = new byte['?']; int len = 0; while ((len = inputStream.read(buf)) > 0) { outputStream.write(buf, 0, len); } } catch (IOException exception) { Console.VERBOSE("Error when exploding Entry: " + name, exception); delete(localFile); } finally { close(inputStream); close(outputStream); } } } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.ExtractionManager * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.StringTokenizer; public class JniLoader { public static String findLibrary(File directory, String libname) { String systemLibName = System.mapLibraryName(libname); File lib = new File(directory, systemLibName); if (!lib.exists()) { return null; } Console.VERBOSE("Library '" + libname + "' found ('" + lib.getAbsolutePath() + "')"); return lib.getAbsolutePath(); } public static String findLibraryInClassPath(String libname, File destination) { String systemLibName = System.mapLibraryName(libname); File lib = new File(destination, systemLibName); if (lib.exists()) { return lib.getAbsolutePath(); } lib.getParentFile().mkdirs(); InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(systemLibName); byte[] buf; if (inputStream != null) { outputStream = new FileOutputStream(lib); buf = new byte['?']; len = 0; while ((len = inputStream.read(buf)) > 0) { outputStream.write(buf, 0, len); } Console.VERBOSE("Library '" + libname + "' found in classpath resource"); return lib.getAbsolutePath(); } return null; } catch (IOException e) { int len; Console.VERBOSE("Error when copy native library : " + systemLibName, e); return null; } finally { ExtractionManager.close(inputStream); ExtractionManager.close(outputStream); } } public static Boolean loadLibraries(File directory, String libnames) { StringTokenizer tokenizer = new StringTokenizer(libnames, ","); Boolean result = Boolean.TRUE; while ((tokenizer.hasMoreTokens()) && (result.booleanValue())) { result = loadLibrary(directory, tokenizer.nextToken()); } return result; } public static Boolean loadLibrary(File directory, String libname) { String libPath = findLibrary(directory, libname); if (libPath == null) { Console.WARNING("Library '" + libname + "' has not be found ('" + libPath + "')"); return Boolean.FALSE; } try { Runtime.getRuntime().load(libPath); } catch (UnsatisfiedLinkError e) { Console.WARNING("Library '" + libname + "' not found ('" + libPath + "') or her dependencies not ever loaded", e); return Boolean.FALSE; } catch (Throwable e) { Console.WARNING("Loading Library '" + libname + "'", e); return Boolean.FALSE; } return Boolean.TRUE; } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.JniLoader * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; public enum KeystoneException$Operation { NONE, CLEAN, RESTART; private KeystoneException$Operation() {} } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.KeystoneException.Operation * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; public class KeystoneException extends RuntimeException { private static final long serialVersionUID = 5526337594737942947L; private final Operation operation; public static enum Operation { NONE, CLEAN, RESTART; private Operation() {} } public KeystoneException() { operation = Operation.NONE; } public KeystoneException(Operation operation) { this.operation = operation; } public KeystoneException(Operation operation, String message, Throwable cause) { super(message, cause); this.operation = operation; } public KeystoneException(Operation operation, String message) { super(message); this.operation = operation; } public KeystoneException(Operation operation, Throwable cause) { super(cause); this.operation = operation; } public final Operation getOperation() { return operation; } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.KeystoneException * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; public enum OSDetector$Name { LINUX, MAC, WINDOWS; private OSDetector$Name() {} } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.OSDetector.Name * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; import java.util.Locale; public class OSDetector { private static final Name name; public static enum Name { LINUX, MAC, WINDOWS; private Name() {} } static { String os = System.getProperty("os.name", "").toLowerCase(Locale.getDefault()); if ((os.startsWith("windows")) || (os.contains("nt"))) { name = Name.WINDOWS; } else if (os.startsWith("mac")) { name = Name.MAC; } else { name = Name.LINUX; } } public static boolean isLinux() { return Name.LINUX.equals(name); } public static boolean isWindows() { return Name.WINDOWS.equals(name); } public static boolean isMac() { return Name.MAC.equals(name); } public static Name getName() { return name; } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.OSDetector * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; import java.io.IOException; final class Restarter$1 extends Thread { Restarter$1(String paramString) {} public void run() { try { Runtime.getRuntime().exec(val$cmd); } catch (IOException e) { e.printStackTrace(); } } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.Restarter.1 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.intelligentsia.keystone.boot; import java.io.File; import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Restarter { private static final String SUN_JAVA_COMMAND = "sun.java.command"; public static void autoRestart(Runnable runBeforeRestart) throws IllegalStateException { if (System.getProperty("sun.java.command") != null) { List<String> parameters = new ArrayList(); String[] mainCommand = System.getProperty("sun.java.command").split(" "); if (mainCommand[0].endsWith(".jar")) { parameters.add("-jar " + new File(mainCommand[0]).getPath()); } else { parameters.add(mainCommand[0]); } for (int i = 1; i < mainCommand.length; i++) { parameters.add(mainCommand[i]); } restartWith(runBeforeRestart, (String[])parameters.toArray(new String[0])); return; } throw new IllegalStateException("Unable to Autorestart"); } public static void restartWith(Runnable runBeforeRestart, String... parameters) { List<String> commands = new ArrayList(); commands.add(getJavaCommand()); commands.addAll(getJVMArgument()); commands.addAll(Arrays.asList(parameters)); StringBuilder builder = new StringBuilder(); for (String command : commands) { builder.append(command).append(' '); } String cmd = builder.toString(); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { Runtime.getRuntime().exec(val$cmd); } catch (IOException e) { e.printStackTrace(); } } }); if (runBeforeRestart != null) { runBeforeRestart.run(); } System.exit(0); } private static String getJavaCommand() { if (OSDetector.isMac()) { return "open"; } String path = System.getProperty("sun.boot.library.path"); if ((path == null) || ("".endsWith(path))) { path = System.getProperty("java.home") + File.separator + "bin"; } File root = new File(path); for (String name : Arrays.asList(new String[] { OSDetector.isLinux() ? "javaw" : "javaw.exe", OSDetector.isLinux() ? "java" : "java.exe" })) { File java = new File(root, name); if (java.exists()) { return java.getAbsolutePath(); } } return "java"; } private static List<String> getJVMArgument() { List<String> lst = ManagementFactory.getRuntimeMXBean().getInputArguments(); ArrayList<String> jvmArguments = new ArrayList(); boolean xmxset = false; boolean xmsset = false; boolean maxPermSize = false; boolean useconc = false; boolean minheap = false; boolean maxheap = false; boolean classpath = false; for (String h : lst) { if (!h.contains("-agentlib")) { if (h.contains("Xmx")) { xmxset = true; if (Runtime.getRuntime().maxMemory() < 533000000L) { jvmArguments.add("-Xmx512m"); } } else if (h.contains("Xms")) { xmsset = true; } else if (h.contains("XX:+useconc")) { useconc = true; } else if (h.contains("minheapfree")) { minheap = true; } else if (h.contains("maxheapfree")) { maxheap = true; } else if (h.contains("-XX:MaxPermSize")) { maxPermSize = true; } jvmArguments.add(h); } } if (!xmsset) { jvmArguments.add("-Xms64m"); } if (!xmxset) { jvmArguments.add("-Xmx512m"); } if (!maxPermSize) { jvmArguments.add("-XX:MaxPermSize=128M"); } if (!useconc) { jvmArguments.add("-XX:+UseConcMarkSweepGC"); } if (!minheap) { jvmArguments.add("-XX:MinHeapFreeRatio=0"); } if (!maxheap) { jvmArguments.add("-XX:MaxHeapFreeRatio=0"); } String cp = System.getProperty("java.class.path"); if ((cp != null) && (!"".equals(cp))) { jvmArguments.add("-cp \"" + System.getProperty("java.class.path") + "\""); } return jvmArguments; } } /* Location: * Qualified Name: org.intelligentsia.keystone.boot.Restarter * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ Further reading...For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.New!JAR listings
|