List of usage examples for java.lang Shutdown Shutdown
Shutdown
From source file:memedb.httpd.MemeDBHandler.java
public MemeDBHandler(MemeDB memeDB) { this.memeDB = memeDB; baseRequestHandlers.add(new Admin()); baseRequestHandlers.add(new GetDocument()); baseRequestHandlers.add(new FulltextQuery()); baseRequestHandlers.add(new AdHocView()); baseRequestHandlers.add(new GetView()); baseRequestHandlers.add(new Auth()); baseRequestHandlers.add(new InvalidateAuth()); baseRequestHandlers.add(new GetDatabaseNames()); baseRequestHandlers.add(new GetDBStats()); baseRequestHandlers.add(new AddDB()); baseRequestHandlers.add(new UpdateDocument()); baseRequestHandlers.add(new Sessions()); baseRequestHandlers.add(new Shutdown()); baseRequestHandlers.add(new DeleteDocument()); baseRequestHandlers.add(new DeleteDB()); baseRequestHandlers.add(new UserAdd()); for (BaseRequestHandler handler : baseRequestHandlers) { handler.setMemeDB(memeDB);/* w w w .ja va 2 s . c om*/ } this.allowAnonymous = memeDB.getProperty("auth.anonymous", "false").toLowerCase().equals("true"); this.allowAnonymousAsSa = memeDB.getProperty("auth.anonymous.sa", "false").toLowerCase().equals("true"); this.realm = memeDB.getProperty("auth.realm", "MemeDB"); this.timeout = Integer.parseInt(memeDB.getProperty("auth.timeout.seconds", "300")); this.allowHtml = memeDB.getProperty("server.www.allow", "true").toLowerCase().equalsIgnoreCase("true"); }
From source file:com.octo.captcha.engine.bufferedengine.BufferedEngineContainer.java
/** * Construct an BufferedEngineContainer with and Captcha engine, a memory buffer, a diskBuffer and a * ContainerConfiguration./*from ww w .j a v a 2s .c om*/ * * @param engine engine to generate captcha for buffers * @param volatileBuffer the memory buffer, which store captcha and provide a fast access to them * @param persistentBuffer the disk buffer which store captchas not in a volatil and memory consuming way * @param containerConfiguration the container configuration */ public BufferedEngineContainer(CaptchaEngine engine, CaptchaBuffer volatileBuffer, CaptchaBuffer persistentBuffer, ContainerConfiguration containerConfiguration) { this.engine = engine; if (engine == null) { throw new CaptchaEngineException("impossible to build a BufferedEngineContainer with a null engine"); } this.volatileBuffer = volatileBuffer; if (persistentBuffer == null) { throw new CaptchaEngineException( "impossible to build a BufferedEngineContainer with a null volatileBuffer"); } this.persistentBuffer = persistentBuffer; if (persistentBuffer == null) { throw new CaptchaEngineException( "impossible to build a BufferedEngineContainer with a null persistentBuffer"); } this.config = containerConfiguration; if (config == null) { throw new CaptchaEngineException( "impossible to build a BufferedEngineContainer with a null configuration"); } //define hook when JVM is shutdown Shutdown sh = new Shutdown(); Runtime.getRuntime().addShutdownHook(sh); }
From source file:com.sm.replica.DefaultReplicaServer.java
public void hookShutdown() { Runtime.getRuntime().addShutdownHook(new Thread(new Shutdown())); }
From source file:org.kepler.Kepler.java
public static void main(String[] args) { //System.out.println("java.library.path = " + System.getProperty("java.library.path")); // log4j uses the first log4j.properties file found on the classpath. // since kepler's classpath is complicated, it is not always obvious // which log4j.properties is used; it may be hidden in a jar file. // this prints the log4j.properties file found on the classpath. File log4jFile = FileUtilities.nameToFile("$CLASSPATH/log4j.properties", null); if (log4jFile == null) { System.out.println("log4j.properties not found in CLASSPATH."); } else {/* w w w . j ava 2 s . c om*/ System.out.println("log4j.properties found in CLASSPATH: " + log4jFile); } // Save the args in case they are needed later. // long startTime = System.currentTimeMillis(); _args = args; CommandLineArgs.store(args); List<String> argList = Arrays.asList(args); // parse the command line arguments if (!parseArgs(args)) { // an error occurred, so exit. return; } RepositoryLocations.setReleaseLocation(org.kepler.modulemanager.RepositoryLocations.getReleaseLocation()); ModuleTree.init(); // if we are executing a workflow from the command line, check now for // patches. if (_action == Action.RunKAR || _action == Action.RunWf) { // if we are running headless, do not display a dialog if patches // are available if (!_runWithGui || _displayRedirectOutputPath != null) { PatchChecker.check(true); } else { PatchChecker.check(false); } // show the splash if the Kepler UI is starting } else if (_action == Action.Kepler && _showSplash) { _showSplash(); } System.gc(); ShutdownNotifier.addShutdownListener(new Shutdown()); try { setJavaPropertiesAndCopyModuleDirectories(); // System.out.println("os: " + System.getProperty("os.name")); String OSName = System.getProperty("os.name"); // Hashtable properties = getProject().getProperties(); ModuleTree moduleTree = ModuleTree.instance(); String classpath = System.getProperty("java.class.path"); String[] classpathItems = classpath.split(File.pathSeparator); for (Module module : moduleTree) { // XXX since Module dir variables can be wrong, utilizing classpath // to determine module location on disk. Use below line instead when // that's fixed. //File osextension = new File(module.getModuleInfoDir() + File.separator + "osextension.txt"); File osextension = null; String sought = File.separator + module.getName() + File.separator; for (String path : classpathItems) { // must check each match since parent path could possibly have a module name // in it (don't break on first): if (path.contains(sought)) { int lastIndex = path.lastIndexOf(sought); String p = path.substring(0, lastIndex); p = p.concat(sought + "module-info" + File.separator + "osextension.txt"); osextension = new File(p); if (osextension.exists()) { break; } } } if (osextension == null || !osextension.exists()) { continue; } System.out.println("Found OS Extension file: " + osextension.getAbsolutePath()); Hashtable<String, String> properties = readOSExtensionFile(osextension); Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { String extClass = keys.nextElement(); String os = properties.get(extClass); if (OSName.trim().equals(os.trim())) { // if we're in an OS that an extension // needs to be loaded for attempt to load // the OSExtension via reflection // and run the addOSExtension method Class<?> c = Class.forName(extClass); try { OSExtension extension = (OSExtension) c.newInstance(); extension.addOSExtensions(); System.out.println("loading OS extensions for OS " + os + " with class " + extClass); } catch (ClassCastException cce) { // System.out.println(extClass + // " is not an instance of OSExtension"); } } } } Project project = new Project(); File projDir = ProjectLocator.getProjectDir(); project.setBaseDir(projDir); setOntologyIndexFile(); if (!argList.contains("-runwf")) { // Allow developers to turn off MakeKars by creating // a file called "skipMakeKars" in the project root File skipMakeKars = new File(projDir, "skipMakeKars"); if (!skipMakeKars.exists()) { MakeKars kar = new MakeKars(); kar.setProject(project); kar.init(); kar.run(); } } PermissionManager.makeNativeLibsExecutable(); // CreateIntroFileTask createIntroFileTask = new // CreateIntroFileTask(); // createIntroFileTask.execute(); } catch (URISyntaxException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } runApplication(); // System.exit(0); // long endTime = System.currentTimeMillis(); // System.out.println( (endTime-startTime)/1000.0 ); }
From source file:ru.calypso.ogar.server.OgarServer.java
public void handleCommand(String line) { line = line.trim();//from w ww .j a va 2 s.c o m if (line.isEmpty()) return; String command = line.split("\\s+")[0]; String args = line.substring(command.length()).trim(); StringTokenizer st = new StringTokenizer(args); switch (command.toLowerCase()) { case "help": _log.info("=[Commands Help]================================="); _log.info("\"help\" - show this text"); _log.info("\"cancel/restart\" - cancel restart/shutdown"); _log.info("\"shutdown\" - schedule shutdown"); _log.info("\"shutdown n*\" - schedule shutdown after n seconds"); _log.info("\"restart\" - schedule restart"); _log.info("\"restart n*\" - schedule restart after n seconds"); _log.info("================================================="); break; case "abort": case "cancel": Shutdown.getInstance().cancel(); break; case "restart": if (st.hasMoreTokens()) Shutdown.getInstance().schedule(NumberUtils.toInt(st.nextToken(), -1), Shutdown.RESTART); else Shutdown.getInstance().schedule(1, Shutdown.RESTART); break; case "shutdown": if (st.hasMoreTokens()) Shutdown.getInstance().schedule(NumberUtils.toInt(st.nextToken(), -1), Shutdown.SHUTDOWN); else Shutdown.getInstance().schedule(1, Shutdown.SHUTDOWN); break; case "kick": try { Player player = getPlayerList().getPlayerByName(st.nextToken()); if (player != null) { player.getConnection().getChannel().disconnect(); _log.info("Kick success!"); } else _log.info("Player with this name not found!"); } catch (Exception e) { _log.info("Command syntax: kick playername"); } break; default: _log.info("Unknown command, use \"help\" for help."); break; } }