Example usage for org.apache.wicket.util.watch IModifiable lastModifiedTime

List of usage examples for org.apache.wicket.util.watch IModifiable lastModifiedTime

Introduction

In this page you can find the example usage for org.apache.wicket.util.watch IModifiable lastModifiedTime.

Prototype

Time lastModifiedTime();

Source Link

Document

Gets the last time this modifiable thing changed.

Usage

From source file:com.kenai.wicketgae.web.watcher.GaeModificationWatcher.java

License:Apache License

/**
 * Adds an <code>IModifiable</code> object and an
 * <code>IChangeListener</code> object to call when the modifiable object is
 * modified./*from  w  w w.j av  a2s  . com*/
 * 
 * @param modifiable
 *            an <code>IModifiable</code> object to monitor
 * @param listener
 *            an <code>IChangeListener</code> to call if the
 *            <code>IModifiable</code> object is modified
 * @return <code>true</code> if the set did not already contain the
 *         specified element
 */
public final boolean add(final IModifiable modifiable, final IChangeListener listener) {
    // Look up entry for modifiable
    final Entry entry = modifiableToEntry.get(modifiable);

    // Found it?
    if (entry == null) {
        if (modifiable.lastModifiedTime() != null) {
            // Construct new entry
            final Entry newEntry = new Entry();

            newEntry.modifiable = modifiable;
            newEntry.lastModifiedTime = modifiable.lastModifiedTime();
            newEntry.listeners.add(listener);

            // Put in map
            modifiableToEntry.put(modifiable, newEntry);
        } else {
            // The IModifiable is not returning a valid lastModifiedTime
            log.info("Cannot track modifications to resource " + modifiable);
        }

        return true;
    } else {
        // Add listener to existing entry
        return entry.listeners.add(listener);
    }
}

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

License:Open Source License

/**
 * @see org.apache.wicket.util.watch.IModificationWatcher#add(org.apache.wicket.util.watch.IModifiable, org.apache.wicket.util.listener.IChangeListener)
 *///w w w . ja  v a  2 s . c  om
public final boolean add(final IModifiable modifiable, final IChangeListener listener) {
    if (modifiable instanceof MarkupResourceStream) {
        if (WebForm.class
                .isAssignableFrom(((MarkupResourceStream) modifiable).getContainerInfo().getContainerClass())) {
            return false;
        }
    }
    // Look up entry for modifiable
    final Entry entry = modifiableToEntry.get(modifiable);

    // Found it?
    if (entry == null) {
        Time lastModifiedTime = modifiable.lastModifiedTime();
        if (lastModifiedTime != null) {
            // Construct new entry
            final Entry newEntry = new Entry();

            newEntry.modifiable = modifiable;
            newEntry.lastModifiedTime = lastModifiedTime;
            newEntry.listeners.add(listener);

            // Put in map
            modifiableToEntry.put(modifiable, newEntry);
        } else {
            // The IModifiable is not returning a valid lastModifiedTime
            log.info("Cannot track modifications to resource " + modifiable);
        }

        return true;
    } else {
        // Add listener to existing entry
        return entry.listeners.add(listener);
    }
}