Example usage for org.apache.wicket.util.thread ICode ICode

List of usage examples for org.apache.wicket.util.thread ICode ICode

Introduction

In this page you can find the example usage for org.apache.wicket.util.thread ICode ICode.

Prototype

ICode

Source Link

Usage

From source file:com.servoy.j2db.server.headlessclient.ServoyModificationWatcher.java

License:Open Source License

/**
 * @see org.apache.wicket.util.watch.IModificationWatcher#start(org.apache.wicket.util.time.Duration)
 *//*w ww .j ava 2 s.c  o  m*/
public void start(final Duration pollFrequency) {
    // Construct task with the given polling frequency
    task = new Task("ModificationWatcher");

    task.run(pollFrequency, new ICode() {
        public void run(final Logger log) {
            // Iterate over a copy of the list of entries to avoid concurrent modification
            // problems without the associated liveness issues of holding a lock while
            // potentially polling file times!
            Iterator<Entry> iter = new ArrayList<Entry>(modifiableToEntry.values()).iterator();
            while (iter.hasNext()) {
                if (Thread.currentThread().isInterrupted())
                    return;

                final Entry entry = iter.next();

                // If the modifiable has been modified after the last known
                // modification time
                final Time modifiableLastModified = entry.modifiable.lastModifiedTime();
                if ((modifiableLastModified != null) && modifiableLastModified.after(entry.lastModifiedTime)) {
                    // Notify all listeners that the modifiable was modified
                    entry.listeners.notifyListeners();

                    // Update timestamp
                    entry.lastModifiedTime = modifiableLastModified;
                }
            }
        }
    });
}

From source file:org.wicketstuff.wicket7.util.watch.Nio2ModificationWatcher.java

License:Apache License

@Override
public void start(final Duration pollFrequency) {
    // Construct task with the given polling frequency
    task = new Task("Wicket-ModificationWatcher-NIO2");

    task.run(pollFrequency, new ICode() {
        @Override// w ww  .  java 2s  . c o  m
        public void run(final Logger log) {
            checkCreated();
            checkModified();
        }
    });
}