Search in sources :

Example 1 with SystemTimeChangeListener

use of com.swiftmq.swiftlet.timer.event.SystemTimeChangeListener in project swiftmq-ce by iitsoftware.

the class TimerSwiftletImpl method reorder.

private void reorder(long delta) {
    if (traceSpace.enabled)
        traceSpace.trace(getName(), "reorder, delta=" + delta + " ...");
    logSwiftlet.logInformation(getName(), "System time has changed (delta=" + delta + "), reordering timer task queue");
    List backup = (List) ((GapList) taskQueue).clone();
    taskQueue.clear();
    for (Iterator iter = backup.iterator(); iter.hasNext(); ) {
        TimeTask t = (TimeTask) iter.next();
        if (!t.doNotApplySystemTimeChanges) {
            if (traceSpace.enabled)
                traceSpace.trace(getName(), "reorder, before, t=" + t);
            t.recalc(delta);
            if (traceSpace.enabled)
                traceSpace.trace(getName(), "reorder, after, t=" + t);
        }
        enqueue(t);
    }
    for (int i = 0; i < sysTimeChangeListeners.size(); i++) {
        SystemTimeChangeListener l = null;
        try {
            l = (SystemTimeChangeListener) sysTimeChangeListeners.get(i);
            l.systemTimeChangeDetected(delta);
        } catch (Exception e) {
            logSwiftlet.logInformation(getName(), "Exception calling SystemTimeChangeListener '" + l + "': " + e);
            if (traceSpace.enabled)
                traceSpace.trace(getName(), "Exception calling SystemTimeChangeListener '" + l + "': " + e);
        }
    }
    if (traceSpace.enabled)
        traceSpace.trace(getName(), "reorder, delta=" + delta + " done");
}
Also used : GapList(org.magicwerk.brownies.collections.GapList) SwiftletException(com.swiftmq.swiftlet.SwiftletException) PropertyChangeException(com.swiftmq.mgmt.PropertyChangeException) SystemTimeChangeListener(com.swiftmq.swiftlet.timer.event.SystemTimeChangeListener)

Aggregations

PropertyChangeException (com.swiftmq.mgmt.PropertyChangeException)1 SwiftletException (com.swiftmq.swiftlet.SwiftletException)1 SystemTimeChangeListener (com.swiftmq.swiftlet.timer.event.SystemTimeChangeListener)1 GapList (org.magicwerk.brownies.collections.GapList)1