Package java.util

Examples of java.util.Timer


    // This is where we instanciate a java.util.Timer
    // for scheduling recurring checks of email accounts.
    // it is a daemon thread, that will not prolong the life of the application.
    // This means we don't need to explicitly clean it up at the end.
    // It will just die it's meaningless death.
    Timer supportEmailTimer = new Timer(true);

    // schedule a job to check support email every x minutes
    int supportInterval = 0;
    try {
      SupportHelperHome supportHome = (SupportHelperHome)CVUtility.getHomeObject("com.centraview.support.helper.SupportHelperHome", "SupportHelper");
      SupportHelper supportRemote = supportHome.create();
      supportRemote.setDataSource(dataSource);
      supportInterval = supportRemote.getSupportEmailCheckInterval();
    } catch (Exception e) { }

    if (supportInterval > 0) {
      // minutes to seconds, then seconds to miliseconds...
      Integer interval = new Integer(supportInterval * 60 * 1000);
      // 600000L = 10 minutes * 60 seconds/minute * 1000 miliseconds/second
      // delay the first check for 10 minutes after the startup.
      // Just to give things time to settle down.
      TimerTask supportEmailTask = new SupportEmailCheck(dataSource);
      supportEmailTimer.schedule(supportEmailTask, 600000L, interval.longValue());
      siteInfo.setSupportEmailTask(supportEmailTask);
    }

    // now stick the Timer into the Settings Singleton so that
    // it can be accessed by anything in the Tomcat4 webapp classloader.
View Full Code Here


    } catch(IllegalStateException ise) {
      // kill this job because the session is not
      // valid, so the user must not be logged in
      logger.debug("[run] Session is invalid, user must have logged out.  Remove the mail check timer.");
      SiteInfo siteInfo = Settings.getInstance().getSiteInfo(host);
      Timer currentTimer = siteInfo.getUserTimer(this.individualId);
      if (currentTimer != null)
      {
        logger.debug("[run] Calling cancel on the timer.");
        currentTimer.cancel();
      }
    }
  }   // end run() method
View Full Code Here

        wrkMgr = wm;
 
    }
   
    public Timer createTimer() throws UnavailableException {
        return new Timer(true);
    }
View Full Code Here

   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    System.out.println(new Date(System.currentTimeMillis()) + " : Cron test wait (1 minute) ...");
    Timer timer = new Timer();
   Scheduler scheduler = new Scheduler(timer);
   //<minutes> <hours> <days of month> <months> <days of week>
   String cronDate = "* * * * *"; // all minutes.
   scheduler.scheduleEvent(new CronEvent("cron_test", cronDate), new CronTestTask());
   System.in.read();
View Full Code Here

    }
    return _instance;
  }

  private TomcatUtils() {
    _tomcatWatchdog = new Timer("Tomcat Watchdog");
    _tomcatWatchdog.schedule(_tomcatWatchdogTask, 0, 500 * 1);
  }
 
View Full Code Here

   
  }
 
  public void initialize(Properties info) {
    PropertiesUtils.setBeanProperties(this, info, "org.teiid.sockets"); //$NON-NLS-1$
    this.pingTimer = new Timer("SocketPing", true); //$NON-NLS-1$
    this.pingTimer.schedule(new TimerTask() {
     
      @Override
      public void run() {
        Set<Map.Entry<HostInfo, Set<SessionToken>>> sessionEntries = null;
View Full Code Here

        }
        SettingsInterface settings = Settings.getInstance();
        // re-schedule JOB because it is currently running and
        // we have changed the interval at which it executes
        TimerTask supportEmailTask = settings.getSupportEmailTask();
        Timer supportEmailTimer = settings.getSupportEmailTimer();
        // cancel the existing timer.
        if (supportEmailTask != null) {
          supportEmailTask.cancel();
        }
        if (supportEmailTimer != null) {
          supportEmailTimer.cancel();
        }
        // only re-schedule the job if the interval is greater than zero
        // a zero value means do not check support email ever
        if (formInterval.intValue() > 0) {
          // minutes to seconds, seconds to miliseconds
          Integer interval = new Integer(formInterval.intValue() * 60 * 1000);
          // then create a new Timer.
          Timer newSupportEmailTimer = new Timer(true);
          // wait a full two minutes for the next execution.
          TimerTask newSupportEmailTask = new SupportEmailCheck(dataSource);
          newSupportEmailTimer.schedule(newSupportEmailTask, 120000L, interval.longValue());
          // And store our reference.
          settings.setSupportEmailTimer(newSupportEmailTimer);
          settings.setSupportEmailTask(newSupportEmailTask);
        }
      } // end of "emailCheckInterval" setting
View Full Code Here

    /**
     * Constructs a new task engine.
     */
    private TaskEngine() {
        timer = new Timer("timer-whack", true);
        executor = Executors.newCachedThreadPool(new ThreadFactory() {

            final AtomicInteger threadNumber = new AtomicInteger(1);

            public Thread newThread(Runnable runnable) {
View Full Code Here

    final CacheProvider cacheProvider = CacheProviderRegister.getInstance()
        .getCacheProvider("memcached");
    cacheProvider.setCacheServers("192.168.16.123:11211");
    cacheProvider.setExpiryTime(1000 * 10);
    cacheProvider.put("name", "www.cnoss.org");
    final Timer timer = new Timer();
    timer.schedule(new TimerTask() {
      @Override
      public void run() {
        Object name = cacheProvider.get("name");
        if (name == null)
          timer.cancel();
        else
          System.out.println(name + "   " + (++index));
      }
    }, 0, 1000);
  }
View Full Code Here

    });

    shell.setSize(550, 350);
    shell.open();

    Timer timer = new Timer(true);
    timer.schedule(task, 0, 2000);
  }
View Full Code Here

TOP

Related Classes of java.util.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.