List of usage examples for java.util Timer Timer
public Timer()
From source file:io.hawkcd.agent.Agent.java
private void startCheckForWorkTimer() { TimerTask checkForWorkTask = new TimerTask() { @Override//from www.j av a 2 s .c o m public void run() { Agent.this.checkForWork(); } }; this.checkForWorkTimer = new Timer(); this.checkForWorkTimer.schedule(checkForWorkTask, 2000, 4000); }
From source file:net.hardisonbrewing.signingserver.SigservPushApplication.java
private void startRegisterServTask() { cancelRegisterServTask();//from w w w. j a v a 2 s . c om Timer timer = new Timer(); registerServ = new RegisterServTimerTask(); timer.schedule(registerServ, 0, Dates.DAY); }
From source file:com.android.server.MaybeService.java
private void initializeTimerTask() { mDataDownloadTimer = new Timer(); mDataDownloaderTask = new TimerTask() { public void run() { Log.v(TAG, "Querying server"); if (mIsDeviceRegistered) { synchronized (sDownloadLock) { String deviceMeid = getDeviceMEID(); if (deviceMeid == null) { // TelephonyManager not initialized return; }/*from w ww . j ava 2 s . co m*/ String serverUrl = URL + "/" + deviceMeid; new JSONDownloaderTask().execute(serverUrl); try { sDownloadLock.wait(); parseData(mJSONDownloadData); } catch (InterruptedException e) { e.printStackTrace(); } } //end sync sDownloadLock } else { synchronized (sNetworkCallLock) { new DeviceRegisterTask().execute(URL); try { sNetworkCallLock.wait(); parseData(mJSONResponse); } catch (InterruptedException e) { e.printStackTrace(); } Log.d(TAG, "Received data from TASK: " + mJSONResponse); } //end sync sNetworkCallLock } } }; mDataDownloadTimer.schedule(mDataDownloaderTask, 30000, (mPollInterval * 1000)); }
From source file:com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerFragment.java
private void handleMediaAuthTask(final MediaAuthService authService) { mCastController.showLoading(true);/*from w ww. j av a 2s.c o m*/ if (authService == null) { return; } mCastController.setSubTitle(authService.getPendingMessage() != null ? authService.getPendingMessage() : ""); mAuthThread = new Thread(new Runnable() { @Override public void run() { authService.setMediaAuthListener(VideoCastControllerFragment.this); authService.startAuthorization(); } }); mAuthThread.start(); // start a timeout timer; we don't want authorization process to take too long mMediaAuthTimer = new Timer(); mMediaAuthTimer.schedule(new MediaAuthServiceTimerTask(mAuthThread), authService.getTimeout()); }
From source file:esg.node.components.metrics.ESGMetrics.java
private void startMetricsCollection() { log.trace("launching node metrics timer"); long delay = Long.parseLong(props.getProperty("metrics.initialDelay")); long period = Long.parseLong(props.getProperty("metrics.period")); log.trace("metrics delay: " + delay + " sec"); log.trace("metrics period: " + period + " sec"); Timer timer = new Timer(); timer.schedule(new TimerTask() { public final void run() { //log.trace("Checking for new datanode information... [busy? "+ESGMetrics.this.isBusy+"]"); if (!ESGMetrics.this.isBusy) { ESGMetrics.this.isBusy = true; if (fetchNodeStats()) { metricsDAO.markLastCompletionTime(); }/*from www .j a v a 2s. c o m*/ ESGMetrics.this.isBusy = false; } } }, delay * 1000, period * 1000); }
From source file:at.gv.egovernment.moa.id.demoOA.Configuration.java
private void initalPVP2Login() throws ConfigurationException { try {// www . j a v a 2 s . c o m //load IDP certificate to validate IDP metadata String metadataCert = getPVP2IDPMetadataCertificate(); if (MiscUtil.isEmpty(metadataCert)) { throw new ConfigurationException("NO IDP Certificate to verify IDP Metadata"); } InputStream certstream = new FileInputStream(metadataCert); X509Certificate cert = new X509Certificate(certstream); BasicX509Credential idpCredential = new BasicX509Credential(); idpCredential.setEntityCertificate(cert); String metadataurl = getPVP2IDPMetadataURL(); if (MiscUtil.isEmpty(metadataurl)) { throw new ConfigurationException("NO IDP Metadata URL."); } //load IDP metadata into metadataprovider idpMetadataProvider = new HTTPMetadataProvider(new Timer(), new HttpClient(), metadataurl); idpMetadataProvider.setRequireValidMetadata(true); idpMetadataProvider.setParserPool(new BasicParserPool()); idpMetadataProvider.setMetadataFilter(new MetaDataVerificationFilter(idpCredential)); idpMetadataProvider.setMaxRefreshDelay(1000 * 3600 * 12); //refresh Metadata every 12h idpMetadataProvider.initialize(); pvp2logininitialzied = true; log.info("Load IDP Metadata finished."); } catch (Exception e) { throw new ConfigurationException("PVP2 authentification can not be initialized.", e); } }
From source file:com.example.ecgfile.DeviceControlActivity.java
public void RTUploadTask() { if (mTimer2 == null) { mTimer2 = new Timer(); }/* w w w . ja v a 2s . co m*/ mTimerTask2 = new TimerTask() { @Override public void run() { if (!isRealTimeUp || !mButton_remoteUpload_enable.isChecked()) { cleanRTUploadTask(); } // getFile(CommonVar.ecgFilePathTemp); // if (files.size() >= 1) { new postFiles().execute(); } } }; mTimer2.schedule(mTimerTask2, 15 * 1000, 8 * 1000); //158 }
From source file:br.com.devfest.norte.wear.PagerActivity.java
/** * Renews the timer that causes pages to flip upon providing an answer. *///from w w w . j a v a2s . c o m private void renewTimer(final int targetPage) { clearTimer(); mTimerTask = new TimerTask() { @Override public void run() { mHandler.post(new Runnable() { @Override public void run() { mViewPager.setCurrentItem(targetPage); } }); } }; mTimer = new Timer(); mTimer.schedule(mTimerTask, PAGE_FLIP_DELAY_MS); }
From source file:de.thm.arsnova.services.QuestionService.java
@Override @PreAuthorize("isAuthenticated() and hasPermission(#questionId, 'question', 'owner')") public void startNewPiRoundDelayed(final String questionId, final int time) { final Timer timer = new Timer(); final Date date = new Date(); final Date endDate = new Date(date.getTime() + (time * 1000)); final IQuestionService questionService = this; final User user = userService.getCurrentUser(); final Question question = databaseDao.getQuestion(questionId); final Session session = databaseDao.getSessionFromKeyword(question.getSessionKeyword()); cancelDelayedPiRoundChange(questionId); timer.schedule(new TimerTask() { @Override// w w w . ja v a 2 s . com public void run() { questionService.startNewPiRound(questionId, user); } }, endDate); timerList.put(questionId, timer); question.setPiRoundActive(true); question.setPiRoundStartTime(date.getTime()); question.setPiRoundEndTime(endDate.getTime()); update(question); this.publisher.publishEvent(new PiRoundDelayedStartEvent(this, session, question)); }
From source file:fi.helsinki.opintoni.config.SAMLSecurityConfiguration.java
private MetadataProvider spMetadata(String alias) throws Exception { ResourceBackedMetadataProvider resourceBackedMetadataProvider = new ResourceBackedMetadataProvider( new Timer(), getSpMetadata(alias)); resourceBackedMetadataProvider.setParserPool(parserPool()); ExtendedMetadataDelegate extendedMetadataDelegate = new ExtendedMetadataDelegate( resourceBackedMetadataProvider, spExtendedMetadata(alias)); extendedMetadataDelegate.setMetadataTrustCheck(true); extendedMetadataDelegate.setMetadataRequireSignature(true); return extendedMetadataDelegate; }