/** * Initializes the timer for sending refresh notifications. */ static void createRefreshTimer() { try { refreshTimer = new javax.management.timer.Timer(); mbeanServer.registerMBean(refreshTimer, refreshTimerObjectName); refreshTimer.start(); } catch (JMException e) { logStackTrace(Level.WARN, e, "Failed to create/register/start refresh timer."); } catch (JMRuntimeException e) { logStackTrace(Level.WARN, e, "Failed to create/register/start refresh timer."); } catch (Exception e) { logStackTrace(Level.WARN, e, "Failed to create/register/start refresh timer."); } }
/** * Initializes the timer for sending refresh notifications. */ static void stopRefreshTimer() { try { if (refreshTimer != null && mbeanServer != null) { mbeanServer.unregisterMBean(refreshTimerObjectName); refreshTimer.stop(); } } catch (JMException e) { logStackTrace(Level.WARN, e); } catch (JMRuntimeException e) { logStackTrace(Level.WARN, e); } catch (Exception e) { logStackTrace(Level.DEBUG, e, "Failed to stop refresh timer for MBeanUtil"); } }
try { refreshTimer.removeNotification(timerNotificationId); } catch (InstanceNotFoundException xptn) {
private synchronized void manageTimer() { if (!timer.isActive()) { if ((perfTimerStarted && perfTimerListeners > 0) || (structuralTimerStarted && structuralTimerListeners > 0)) timer.start(); } else { if ((!perfTimerStarted || perfTimerListeners == 0) && (!structuralTimerStarted || structuralTimerListeners == 0)) timer.stop(); } }
public synchronized void stopUpdates() { if (timerStarted) { try { timer.removeNotifications("tickTimer"); this.timerStarted = false; } catch (InstanceNotFoundException ex) { } timer.stop(); } }
try { refreshTimer.removeNotification(timerNotificationId); } catch (InstanceNotFoundException e) { timerNotificationId = refreshTimer.addNotification(type.getType(), // type
public synchronized void addPerfNotificationListener(NotificationListener listener, Object handback) { timer.addNotificationListener(listener, new NotificationFilter() { @Override public boolean isNotificationEnabled(Notification notification) { return "perfTimer".equals(notification.getType()); } }, handback); perfTimerListeners++; manageTimer(); }
@Override public synchronized void stopStructuralUpdates() { if (structuralTimerStarted) { try { timer.removeNotifications("structTimer"); this.structuralTimerStarted = false; } catch (InstanceNotFoundException ex) { } } manageTimer(); }
/** * @see javax.management.timer.Timer#start() */ public void start() { this.reset(); super.start(); }
protected void onSerialize(SerializationContext context, Notification notification) throws IOException { super.onSerialize(context, notification); TimerNotification serverNotification = (TimerNotification)notification; context.serialize(NOTIFICATION_ID_QNAME, null, serverNotification.getNotificationID()); }
protected Object createObject() throws SAXException { TimerNotification notification = new TimerNotification(getType(), getSource(), getSequenceNumber(), getTimeStamp(), getMessage(), notificationID); return notification; }
private synchronized void manageTimer() { if (!timer.isActive()) { if ((perfTimerStarted && perfTimerListeners > 0) || (structuralTimerStarted && structuralTimerListeners > 0)) timer.start(); } else { if ((!perfTimerStarted || perfTimerListeners == 0) && (!structuralTimerStarted || structuralTimerListeners == 0)) timer.stop(); } }
public synchronized void addStructuralNotificationListener(NotificationListener listener, Object handback) { timer.addNotificationListener(listener, new NotificationFilter() { @Override public boolean isNotificationEnabled(Notification notification) { return "structTimer".equals(notification.getType()); } }, handback); structuralTimerListeners++; manageTimer(); }
@Override public synchronized void stopStructuralUpdates() { if (structuralTimerStarted) { try { timer.removeNotifications("structTimer"); this.structuralTimerStarted = false; } catch (InstanceNotFoundException ex) { } } manageTimer(); }
public synchronized void addStructuralNotificationListener(NotificationListener listener, Object handback) { timer.addNotificationListener(listener, new NotificationFilter() { @Override public boolean isNotificationEnabled(Notification notification) { return "structTimer".equals(notification.getType()); } }, handback); structuralTimerListeners++; manageTimer(); }
@Override public synchronized void stopPerformanceUpdates() { if (perfTimerStarted) { try { timer.removeNotifications("perfTimer"); this.perfTimerStarted = false; } catch (InstanceNotFoundException ex) { } } manageTimer(); }
public synchronized void addPerfNotificationListener(NotificationListener listener, Object handback) { timer.addNotificationListener(listener, new NotificationFilter() { @Override public boolean isNotificationEnabled(Notification notification) { return "perfTimer".equals(notification.getType()); } }, handback); perfTimerListeners++; manageTimer(); }
@Override public synchronized void stopPerformanceUpdates() { if (perfTimerStarted) { try { timer.removeNotifications("perfTimer"); this.perfTimerStarted = false; } catch (InstanceNotFoundException ex) { } } manageTimer(); }