All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.directwebremoting.dwrp.NotifyOnlyScriptConduit Maven / Gradle / Ivy

Go to download

DWR is easy Ajax for Java. It makes it simple to call Java code directly from Javascript. It gets rid of almost all the boiler plate code between the web browser and your Java code.

There is a newer version: 3.0.2-RELEASE
Show newest version
package org.directwebremoting.dwrp;

import org.directwebremoting.ScriptBuffer;
import org.directwebremoting.extend.ScriptConduit;
import org.directwebremoting.util.Logger;

/**
 * Implementation of ScriptConduit that simply calls notifyAll()
 * if a script is added.
 * No actual script adding is done here.
 * Useful in conjunction with a streamWait()
 */
public class NotifyOnlyScriptConduit extends ScriptConduit
{
    /**
     * @param lock Object to wait and notifyAll with
     */
    public NotifyOnlyScriptConduit(Object lock)
    {
        super(RANK_PROCEDURAL);
        this.lock = lock;
    }

    /* (non-Javadoc)
     * @see org.directwebremoting.ScriptConduit#addScript(org.directwebremoting.ScriptBuffer)
     */
    public boolean addScript(ScriptBuffer script)
    {
        try
        {
            synchronized (lock)
            {
                lock.notifyAll();
            }
        }
        catch (Exception ex)
        {
            log.warn("Failed to notify all ScriptSession users", ex);
        }

        // We have not done anything with the script, so
        return false;
    }

    /**
     * The object to notify lock holders on
     */
    private final Object lock;

    /**
     * The log stream
     */
    private static final Logger log = Logger.getLogger(NotifyOnlyScriptConduit.class);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy