List of usage examples for java.util Timer Timer
public Timer()
From source file:de.chludwig.websec.saml2sp.springconfig.SamlSpringSecurityConfig.java
@Bean @Qualifier("idp-ssocircle") public ExtendedMetadataDelegate ssoCircleExtendedMetadataProvider() throws MetadataProviderException, ResourceException { ClasspathResource idpMetadataResource = new ClasspathResource("/saml/ssocircle-idp-metadata.xml"); ResourceBackedMetadataProvider metadataProvider = new ResourceBackedMetadataProvider(new Timer(), idpMetadataResource);//from w ww.j ava 2s. c o m metadataProvider.setParserPool(parserPool()); ExtendedMetadataDelegate extendedMetadataDelegate = new ExtendedMetadataDelegate(metadataProvider, extendedMetadata()); extendedMetadataDelegate.setMetadataTrustCheck(false); extendedMetadataDelegate.setMetadataRequireSignature(false); return extendedMetadataDelegate; }
From source file:com.huofu.RestaurantOS.ui.splash.activate.java
/** * ?/*from w ww .j av a 2s. com*/ */ public void init() { MainApplication.setmActivity(this); rl_activate = (RelativeLayout) findViewById(R.id.rl_activate); rl_activate_input = (RelativeLayout) findViewById(R.id.rl_activate_code_input); rl_activate_qrscan_ready = (RelativeLayout) findViewById(R.id.rl_activate_qrcode_scan_ready); ctxt = getApplicationContext(); buttonActivate = (Button) findViewById(R.id.buttonActivate); buttonSwitchInputCode = (Button) findViewById(R.id.button_switch_acitvate_keyboard_way); buttonSwitchQrScan = (Button) findViewById(R.id.button_activate_switch_to_qrscan); textviewScanStauts = (TextView) findViewById(R.id.textview_activate_status); etActivteCode = (EditText) findViewById(R.id.editTextActivateCode); titanic = new Titanic(); ttv = new TitanicTextView(getApplicationContext()); bitmapUtils = new BitmapUtils(getApplicationContext(), pathAcitvateCache, 150 * 1024 * 1024, 150 * 1024 * 1024); bigPicDisplayConfig = new BitmapDisplayConfig(); bigPicDisplayConfig.setShowOriginal(true); // ,?, ???, OOM callback = new DefaultBitmapLoadCallBack<ImageView>() { public void onLoadCompleted(ImageView container, String uri, android.graphics.Bitmap bitmap, BitmapDisplayConfig config, com.lidroid.xutils.bitmap.callback.BitmapLoadFrom from) { CommonUtils.sendMsg("", HIDE_LOADING, mUiHandler); imageViewQrcode.setVisibility(View.VISIBLE); imageViewQrcode.setBackgroundDrawable(new BitmapDrawable(bitmap)); stopQrScanTimer(); timerQrcode = new Timer(); timerTaskQrcode = new TimerTask() { @Override public void run() { if (!flagActivate) { timerTaskQrcode.cancel(); timerQrcode.cancel(); return; } long qrcodeLastTime = System.currentTimeMillis() / 1000 - qrcodeCreateTime; CommonUtils.LogWuwei(tag, "qrcodeLastTime is " + qrcodeLastTime); if (qrcodeLastTime > 300) { timerTaskQrcode.cancel(); timerQrcode.cancel(); sendUIMessage(SHOW_QRCODE_REFRSH_AGAIN, ""); return; } // TODO Auto-generated method stub if (active) { ApisManager.ScanAuthQrcode(tokenQrcode, new ApiCallback() { @Override public void success(Object object) { sendUIMessage(HIDE_LOADING, ""); JSONObject oj = (JSONObject) object; if (Integer.parseInt(oj.getString("status")) != 1) { return; } String status = oj.getString("related_status"); if (status.equals("5") || status.equals("3") && activate.active)//? { if (activate.flagAuthSuccess) { return; } activate.flagAuthSuccess = true; if (activate.active) { CommonUtils.sendMsg(null, activate.STOP_SCAN_QRCODE_TIMER, mUiHandler); String master_key = oj.getString("master_key"); LocalDataDeal.writeToLocalMasterKey(master_key, ctxt); String client_id = oj.getString("client_id"); LocalDataDeal.writeToLocalClientId(client_id, ctxt); CommonUtils.sendMsg("", SCAN_QRCODE_SUCCESS, mUiHandler); } } else if (status.equals("1")) { CommonUtils.sendMsg("?", UPDATE_QRCODE_SCAN_STATUS, mUiHandler); } else if (status.equals("2")) { CommonUtils.sendMsg("", UPDATE_QRCODE_SCAN_STATUS, mUiHandler); } else if (status.equals("4")) { activate.flagWaitingCmd = true; CommonUtils.sendMsg("", UPDATE_QRCODE_SCAN_STATUS, mUiHandler); } else if (status.equals("6"))//????? { activate.flagWaitingCmd = false; activate.stopQrScanTimer(); CommonUtils.sendMsg("???", AUTH_FAILED, mUiHandler); } else if (status.equals("7")) { activate.flagWaitingCmd = false; activate.stopQrScanTimer(); CommonUtils.sendMsg("??", AUTH_FAILED, mUiHandler); } else if (status.equals("0")) { activate.flagWaitingCmd = false; activate.stopQrScanTimer(); CommonUtils.sendMsg("???", AUTH_FAILED, mUiHandler); } } @Override public void error(BaseApi.ApiResponse response) { sendUIMessage(HIDE_LOADING, ""); } }); } } }; timerQrcode.schedule(timerTaskQrcode, 0, 1000); } }; imageViewQrcode = (ImageView) findViewById(R.id.imageview_activate_qrcode_scan); PackageManager manager; PackageInfo info = null; manager = this.getPackageManager(); String versionName = null; try { info = manager.getPackageInfo(this.getPackageName(), 0); versionName = info.versionName; String version = CommonUtils.getSringAfterChar(versionName, 'V'); LocalDataDeal.writeToLocalVersionName(ctxt, version); } catch (NameNotFoundException e) { e.printStackTrace(); } }
From source file:com.willwinder.ugs.nbp.setupwizard.panels.WizardPanelConnection.java
private void startConnectTimer() { if (!finishedConnecting && finishedConnectingTimer == null) { finishedConnectingTimer = new Timer(); finishedConnectingTimer.schedule(new TimerTask() { @Override//from w w w. j av a2 s . c o m public void run() { finishedConnecting = true; finishedConnectingTimer = null; refreshComponents(); } }, CONNECT_TIME); } }
From source file:com.netspective.commons.report.tabular.AbstractTabularReportDataSource.java
protected void scheduleAutoCloseCheck() { if (log.isDebugEnabled()) log.debug("Setting " + this + " to auto close in " + autoCloseInactivityDuration + " milliseconds."); if (autoCloseTimer != null) { autoCloseTimer.cancel();/*w w w. j a v a 2s . c o m*/ autoCloseTimer = null; } if (autoCloseInactivityDuration > 0) { autoCloseTimer = new Timer(); autoCloseTimer.schedule(new AutoCloseTask(), autoCloseInactivityDuration); } }
From source file:com.leacox.pusherclient.PusherClient.java
private void resetActivityTimer() { if (activityTimer != null) { activityTimer.cancel();/*from w w w .ja v a2 s . c o m*/ } activityTimer = new Timer(); activityTimer.schedule(new TimerTask() { @Override public void run() { logger.debug("Sending PING"); send("pusher:ping", new JSONObject()); activityTimer.schedule(new TimerTask() { @Override public void run() { try { logger.debug("Did not receive PONG: Closing connection"); webSocket.close(); } catch (WebSocketException e) { logger.error("Error closing web socket connection", e); } } }, 30000); } }, 120000); }
From source file:com.yobidrive.diskmap.DiskMapStore.java
public void startPackThread() { // check pack data damon thread for each hour if (packInterval > 0) { logger.info("Start the pack data thread"); packTask = new PackThread(this, false); new Timer().schedule(packTask, packInterval * 1000, packInterval * 1000); }/*from w ww .ja va 2 s . c om*/ }
From source file:hspc.submissionsprogram.AppDisplay.java
AppDisplay() { this.setTitle("Dominion High School Programming Contest"); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.setResizable(false); WindowListener exitListener = new WindowAdapter() { @Override//ww w. ja va 2 s . c o m public void windowClosing(WindowEvent e) { System.exit(0); } }; this.addWindowListener(exitListener); JTabbedPane pane = new JTabbedPane(); this.add(pane); JPanel submitPanel = new JPanel(null); submitPanel.setPreferredSize(new Dimension(500, 500)); UIManager.put("FileChooser.readOnly", true); JFileChooser fileChooser = new JFileChooser(); fileChooser.setBounds(0, 0, 500, 350); fileChooser.setVisible(true); FileNameExtensionFilter javaFilter = new FileNameExtensionFilter("Java files (*.java)", "java"); fileChooser.setFileFilter(javaFilter); fileChooser.setAcceptAllFileFilterUsed(false); fileChooser.setControlButtonsAreShown(false); submitPanel.add(fileChooser); JSeparator separator1 = new JSeparator(); separator1.setBounds(12, 350, 476, 2); separator1.setForeground(new Color(122, 138, 152)); submitPanel.add(separator1); JLabel problemChooserLabel = new JLabel("Problem:"); problemChooserLabel.setBounds(12, 360, 74, 25); submitPanel.add(problemChooserLabel); String[] listOfProblems = Main.Configuration.get("problem_names") .split(Main.Configuration.get("name_delimiter")); JComboBox problems = new JComboBox<>(listOfProblems); problems.setBounds(96, 360, 393, 25); submitPanel.add(problems); JButton submit = new JButton("Submit"); submit.setBounds(170, 458, 160, 30); submit.addActionListener(e -> { try { File file = fileChooser.getSelectedFile(); try { CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost uploadFile = new HttpPost(Main.Configuration.get("submit_url")); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addTextBody("accountID", Main.accountID, ContentType.TEXT_PLAIN); builder.addTextBody("problem", String.valueOf(problems.getSelectedItem()), ContentType.TEXT_PLAIN); builder.addBinaryBody("submission", file, ContentType.APPLICATION_OCTET_STREAM, file.getName()); HttpEntity multipart = builder.build(); uploadFile.setEntity(multipart); CloseableHttpResponse response = httpClient.execute(uploadFile); HttpEntity responseEntity = response.getEntity(); String inputLine; BufferedReader br = new BufferedReader(new InputStreamReader(responseEntity.getContent())); try { if ((inputLine = br.readLine()) != null) { int rowIndex = Integer.parseInt(inputLine); new ResultWatcher(rowIndex); } br.close(); } catch (IOException ex) { ex.printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); } } catch (NullPointerException ex) { JOptionPane.showMessageDialog(this, "No file selected.\nPlease select a java file.", "Error", JOptionPane.WARNING_MESSAGE); } }); submitPanel.add(submit); JPanel clarificationsPanel = new JPanel(null); clarificationsPanel.setPreferredSize(new Dimension(500, 500)); cList = new JList<>(); cList.setBounds(12, 12, 476, 200); cList.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)), BorderFactory.createEmptyBorder(8, 8, 8, 8))); cList.setBackground(new Color(254, 254, 255)); clarificationsPanel.add(cList); JButton viewC = new JButton("View"); viewC.setBounds(12, 224, 232, 25); viewC.addActionListener(e -> { if (cList.getSelectedIndex() != -1) { int id = Integer.parseInt(cList.getSelectedValue().split("\\.")[0]); clarificationDatas.stream().filter(data -> data.getId() == id).forEach( data -> new ClarificationDisplay(data.getProblem(), data.getText(), data.getResponse())); } }); clarificationsPanel.add(viewC); JButton refreshC = new JButton("Refresh"); refreshC.setBounds(256, 224, 232, 25); refreshC.addActionListener(e -> updateCList(true)); clarificationsPanel.add(refreshC); JSeparator separator2 = new JSeparator(); separator2.setBounds(12, 261, 476, 2); separator2.setForeground(new Color(122, 138, 152)); clarificationsPanel.add(separator2); JLabel problemChooserLabelC = new JLabel("Problem:"); problemChooserLabelC.setBounds(12, 273, 74, 25); clarificationsPanel.add(problemChooserLabelC); JComboBox problemsC = new JComboBox<>(listOfProblems); problemsC.setBounds(96, 273, 393, 25); clarificationsPanel.add(problemsC); JTextArea textAreaC = new JTextArea(); textAreaC.setLineWrap(true); textAreaC.setWrapStyleWord(true); textAreaC.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)), BorderFactory.createEmptyBorder(8, 8, 8, 8))); textAreaC.setBackground(new Color(254, 254, 255)); JScrollPane areaScrollPane = new JScrollPane(textAreaC); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setBounds(12, 312, 477, 134); clarificationsPanel.add(areaScrollPane); JButton submitC = new JButton("Submit Clarification"); submitC.setBounds(170, 458, 160, 30); submitC.addActionListener(e -> { if (textAreaC.getText().length() > 2048) { JOptionPane.showMessageDialog(this, "Clarification body is too long.\nMaximum of 2048 characters allowed.", "Error", JOptionPane.WARNING_MESSAGE); } else if (textAreaC.getText().length() < 20) { JOptionPane.showMessageDialog(this, "Clarification body is too short.\nClarifications must be at least 20 characters, but no more than 2048.", "Error", JOptionPane.WARNING_MESSAGE); } else { Connection conn = null; PreparedStatement stmt = null; try { Class.forName(JDBC_DRIVER); conn = DriverManager.getConnection(Main.Configuration.get("jdbc_mysql_address"), Main.Configuration.get("mysql_user"), Main.Configuration.get("mysql_pass")); String sql = "INSERT INTO clarifications (team, problem, text) VALUES (?, ?, ?)"; stmt = conn.prepareStatement(sql); stmt.setInt(1, Integer.parseInt(String.valueOf(Main.accountID))); stmt.setString(2, String.valueOf(problemsC.getSelectedItem())); stmt.setString(3, String.valueOf(textAreaC.getText())); textAreaC.setText(""); stmt.executeUpdate(); stmt.close(); conn.close(); updateCList(false); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (stmt != null) { stmt.close(); } } catch (Exception ex2) { ex2.printStackTrace(); } try { if (conn != null) { conn.close(); } } catch (Exception ex2) { ex2.printStackTrace(); } } } }); clarificationsPanel.add(submitC); pane.addTab("Submit", submitPanel); pane.addTab("Clarifications", clarificationsPanel); Timer timer = new Timer(); TimerTask updateTask = new TimerTask() { @Override public void run() { updateCList(false); } }; timer.schedule(updateTask, 10000, 10000); updateCList(false); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); }
From source file:com.gizwits.framework.sdk.CmdCenter.java
/** * C switch on.//from w ww . ja v a 2 s . c o m * * @param xpgWifiDevice * the xpg wifi device * @param isOn * the is on */ public void cPowerOn(XPGWifiDevice xpgWifiDevice, boolean isOn) { cWrite(xpgWifiDevice, JsonKeys.ON_OFF, isOn); new Timer().schedule(new timer(xpgWifiDevice), 1000); }
From source file:it.unime.mobility4ckan.MainActivity.java
private void startTimer() { Timer sendTimer = new Timer(); sendTimer.schedule(new TimerTask() { @Override//w ww. j a va 2 s.c o m public void run() { sendTask(true); } }, 0, countdown); }
From source file:com.gizwits.framework.sdk.CmdCenter.java
/** * C timing on.//from w ww .j a v a 2s . c om * * @param xpgWifiDevice * the xpg wifi device * @param isOn * the is on */ public void cTimingOn(XPGWifiDevice xpgWifiDevice, boolean isOn) { cWrite(xpgWifiDevice, JsonKeys.TIME_ON_OFF, isOn); new Timer().schedule(new timer(xpgWifiDevice), 1000); }