List of usage examples for java.util Timer Timer
public Timer()
From source file:io.trivium.Central.java
public static void start() { //register activities Registry.INSTANCE.reload();//from ww w. j a v a 2 s.c o m try { //init ui handler Binding b = Registry.INSTANCE.getBinding(TypeRef.getInstance(WebUI.class.getCanonicalName())); b.startBinding(); //init web object handler b = Registry.INSTANCE.getBinding(TypeRef.getInstance(WebObjectHandler.class.getCanonicalName())); b.startBinding(); } catch (Exception ex) { logger.log(Level.SEVERE, "error initializing the builtin http handler", ex); } //start anystore server Thread td = new Thread(AnyServer.INSTANCE, "anystore"); td.setDaemon(true); td.start(); // init profiler Timer t = new Timer(); //one second after next time frame starts long start = TimeUtils.getTimeFrameStart(new Date().getTime() + 60000); t.schedule(Profiler.INSTANCE, new Date(start), 60000); logger.log(Level.INFO, "trivium is now running and accessible through the web interface on http://localhost:12345/ui/"); }
From source file:com.example.ecgfile.DeviceControlActivity.java
public void TimerTask() { if (mTimer == null) { mTimer = new Timer(); }/*from ww w .ja va2s . co m*/ mTimerTask = new TimerTask() { @Override public void run() { if (!mButton_remoteUpload_enable.isChecked()) { cleanTimerTask(); } SimpleDateFormat formatter = new SimpleDateFormat("/yyyy-MM-dd HH:mm:ss"); Date curDate = new Date(System.currentTimeMillis()); timeString = formatter.format(curDate); } }; mTimer.schedule(mTimerTask, 0, CommonVar.PERIOD_15); }
From source file:org.bwgz.quotation.activity.QuotationActivity.java
private void startLoadMessage() { new Timer().schedule(new LazyLoadMessage(lazyLoadMessageHandler), TimeUnit.SECONDS.toMillis(1)); }
From source file:com.mirth.connect.client.ui.TemplatePanel.java
private void updateText() { class UpdateTimer extends TimerTask { @Override//from w w w . ja va2 s . c o m public void run() { // If the current message and pasteBox are blank then a new // template tree is loading, so the treePanel should be cleared. if (currentMessage.equals("") && currentMessage.equals(pasteBox.getText())) { treePanel.clearMessage(); } else if (!currentMessage.equals(pasteBox.getText())) { final String workingId = PlatformUI.MIRTH_FRAME.startWorking("Parsing..."); lastWorkingId = workingId; String message = pasteBox.getText(); currentMessage = message; // Some invalid message templates cause this method to throw a NullPointer. // Catch it so that we can still stop the "Parsing..." working status. // TODO: Fix the possible null pointers inside of the setMessage method. try { treePanel.setMessage(dataProperties, (String) dataTypeComboBox.getSelectedItem(), message, DEFAULT_TEXT); } catch (Exception e) { e.printStackTrace(); } PlatformUI.MIRTH_FRAME.stopWorking(workingId); } } } if (timer == null) { timer = new Timer(); timer.schedule(new UpdateTimer(), 1000); } else { timer.cancel(); PlatformUI.MIRTH_FRAME.stopWorking(lastWorkingId); timer = new Timer(); timer.schedule(new UpdateTimer(), 1000); } // Change the message tab display when the outbound template is modified if (!inbound) { if (StringUtils.isBlank(pasteBox.getText())) { if (!parent.tabTemplatePanel.tabbedPane.getTitleAt(2).equals(MESSAGE_TEMPLATES)) { parent.tabTemplatePanel.tabbedPane.setTitleAt(2, MESSAGE_TEMPLATES); } } else if (!parent.tabTemplatePanel.tabbedPane.getTitleAt(2).equals(MESSAGE_TEMPLATES_BOLD)) { parent.tabTemplatePanel.tabbedPane.setTitleAt(2, MESSAGE_TEMPLATES_BOLD); } } }
From source file:net.hardisonbrewing.signingserver.SigservPushApplication.java
private void startNetworkRequiredTask() { cancelNetworkRequiredTask();//from w w w. j a v a 2s. c o m Timer timer = new Timer(); networkRequiredTimerTask = new NetworkRequiredTimerTask(); timer.schedule(networkRequiredTimerTask, 0, Dates.SECOND * 10); }
From source file:com.barchart.udt.AppServer.java
private void time() { final TimerTask tt = new TimerTask() { @Override/*w w w. j ava 2 s. co m*/ public void run() { final long cur = System.currentTimeMillis(); final long secs = (cur - start) / 1000; log.info("Received: " + count / 1024 + " SPEED: " + (count / 1024) / secs + "KB/s"); } }; final Timer t = new Timer(); t.schedule(tt, 2000, 2000); }
From source file:io.hawkcd.agent.Agent.java
private void startReportAgentTimer() { TimerTask reportAgentTask = new TimerTask() { @Override/*from w w w . j av a 2 s. c o m*/ public void run() { Agent.this.reportAgentToServer(); } }; this.reportAgentTimer = new Timer(); this.reportAgentTimer.schedule(reportAgentTask, 0, 4000); }
From source file:com.enjoyxstudy.selenium.autoexec.AutoExecServer.java
/** * server startup./*w ww .j ava2 s . c o m*/ * * @param properties * @throws Exception */ public void startup(Properties properties) throws Exception { configuration = new AutoExecServerConfiguration(properties); if (configuration.getProxyHost() != null) { System.setProperty("http.proxyHost", configuration.getProxyHost()); } if (configuration.getProxyPort() != null) { System.setProperty("http.proxyPort", configuration.getProxyPort()); } seleniumServer = new SeleniumServer(configuration); if (configuration.getUserExtensions() != null) { seleniumServer.addNewStaticContent(configuration.getUserExtensions().getParentFile()); } mailConfiguration = new MailConfiguration(properties); Server server = seleniumServer.getServer(); // add context HttpContext rootContext = new HttpContext(); rootContext.setContextPath(CONTEXT_PATH_ROOT); rootContext.setResourceBase(CONTENTS_DIR); rootContext.addHandler(new ResourceHandler()); server.addContext(rootContext); HttpContext commandContext = new HttpContext(); commandContext.setContextPath(CONTEXT_PATH_COMMAND); commandContext.addHandler(new CommandHandler(this)); server.addContext(commandContext); HttpContext resultContext = new HttpContext(); resultContext.setContextPath(CONTEXT_PATH_RESULT); resultContext.setResourceBase(configuration.getResultDir().getAbsolutePath()); resultContext.addHandler(new ResourceHandler()); server.addContext(resultContext); seleniumServer.start(); if (configuration.getAutoExecTime() != null) { // set auto exec timer String[] time = configuration.getAutoExecTime().split(":"); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(time[0])); calendar.set(Calendar.MINUTE, Integer.parseInt(time[1])); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); if (calendar.getTimeInMillis() < System.currentTimeMillis()) { calendar.add(Calendar.DAY_OF_MONTH, 1); } log.info("Auto exec first time: " + calendar.getTime()); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { try { log.info("Start auto exec."); process(); log.info("End auto exec."); } catch (Exception e) { log.error("Error auto exec."); } } }, calendar.getTime(), 1000 * 60 * 60 * 24); } log.info("Start Selenium Auto Exec Server."); }
From source file:org.red5.server.war.RootContextLoaderServlet.java
/** * Main entry point for the Red5 Server as a war *///w ww . j av a 2 s .c o m // Notification that the web application is ready to process requests @Override public void contextInitialized(ServletContextEvent sce) { if (null != servletContext) { return; } instance = this; System.setProperty("red5.deployment.type", "war"); myClassloader = getClass().getClassLoader(); servletContext = sce.getServletContext(); String prefix = servletContext.getRealPath("/"); servletContext.setAttribute("root.classloader", myClassloader); initRegistry(servletContext); long time = System.currentTimeMillis(); logger.info("RED5 Server (http://www.osflash.org/red5)"); logger.info("Root context loader"); logger.debug("Path: " + prefix); try { // instance the context loader ContextLoader loader = createContextLoader(); applicationContext = (ConfigurableWebApplicationContext) loader .initWebApplicationContext(servletContext); logger.debug("Root context path: " + applicationContext.getServletContext().getContextPath()); ConfigurableBeanFactory factory = applicationContext.getBeanFactory(); // register default factory.registerSingleton("default.context", applicationContext); // get the main factory parentFactory = (DefaultListableBeanFactory) factory.getParentBeanFactory(); // create a wrapper around our primary context BeanFactoryReference beanfactoryRef = new ContextBeanFactoryReference(applicationContext); // set it in the root servlet context servletContext.setAttribute("bean.factory.ref", beanfactoryRef); // set a remoting codec factory for AMF use servletContext.setAttribute("remoting.codec.factory", parentFactory.getBean("remotingCodecFactory")); server = (Server) parentFactory.getBean("red5.server"); clientRegistry = (ClientRegistry) factory.getBean("global.clientRegistry"); globalInvoker = (ServiceInvoker) factory.getBean("global.serviceInvoker"); globalStrategy = (MappingStrategy) factory.getBean("global.mappingStrategy"); global = (GlobalScope) factory.getBean("global.scope"); logger.debug("GlobalScope: " + global); global.setServer(server); global.register(); global.start(); globalResolver = new ScopeResolver(); globalResolver.setGlobalScope(global); logger.debug("About to grab Webcontext bean for Global"); Context globalContext = (Context) factory.getBean("global.context"); globalContext.setCoreBeanFactory(parentFactory); globalContext.setClientRegistry(clientRegistry); globalContext.setServiceInvoker(globalInvoker); globalContext.setScopeResolver(globalResolver); globalContext.setMappingStrategy(globalStrategy); logger.debug("About to grab Webcontext bean for ROOT"); Context webContext = (Context) factory.getBean("web.context"); webContext.setCoreBeanFactory(parentFactory); webContext.setClientRegistry(clientRegistry); webContext.setServiceInvoker(globalInvoker); webContext.setScopeResolver(globalResolver); webContext.setMappingStrategy(globalStrategy); WebScope scope = (WebScope) factory.getBean("web.scope"); scope.setServer(server); scope.setParent(global); scope.register(); scope.start(); // grab the scope list (other war/webapps) IRemotableList remote = (IRemotableList) Naming .lookup("rmi://localhost:" + rmiPort + "/subContextList"); logger.debug("Children: " + remote.numChildren()); if (remote.hasChildren()) { logger.debug("Children were detected"); for (int i = 0; i < remote.numChildren(); i++) { logger.debug("Enumerating children"); WebSettings settings = remote.getAt(i); registerSubContext(settings.getWebAppKey()); } logger.debug("End of children..."); } } catch (Throwable t) { logger.error(t); } finally { timer = new Timer(); checkScopeList = new CheckScopeListTask(); timer.scheduleAtFixedRate(checkScopeList, 1000, 30000); } long startupIn = System.currentTimeMillis() - time; logger.info("Startup done in: " + startupIn + " ms"); }
From source file:eu.smartenit.sdn.floodlight090.dtm.DTM.java
private DTM() { logger.debug("DTM() begin"); new Timer().scheduleAtFixedRate(new PortStatisticsPoller(), 0, PORT_STATISTICS_POLLING_INTERVAL); logger.debug("DTM() end"); }