org.mozilla.javascript

Class Synchronizer

Implemented Interfaces:
Callable, Function, Scriptable

public class Synchronizer
extends org.mozilla.javascript.Delegator

This class provides support for implementing Java-style synchronized methods in Javascript. Synchronized functions are created from ordinary Javascript functions by the Synchronizer constructor, e.g. new Packages.org.mozilla.javascript.Synchronizer(fun). The resulting object is a function that establishes an exclusive lock on the this object of its invocation. The Rhino shell provides a short-cut for the creation of synchronized methods: sync(fun) has the same effect as calling the above constructor.

Author:
Matthias Radestock

See Also:
org.mozilla.javascript.Delegator

Nested Class Summary

Fields inherited from interface org.mozilla.javascript.Scriptable

NOT_FOUND

Constructor Summary

Synchronizer(Scriptable obj)
Create a new synchronized function from an existing one.

Method Summary

Object
call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args)

Methods inherited from class org.mozilla.javascript.Delegator

call, construct, delete, delete, get, get, getClassName, getDefaultValue, getDelegee, getIds, getParentScope, getPrototype, has, has, hasInstance, put, put, setDelegee, setParentScope, setPrototype

Constructor Details

Synchronizer

public Synchronizer(Scriptable obj)
Create a new synchronized function from an existing one.

Parameters:
obj - the existing function

Method Details

call

public Object call(Context cx,
                   Scriptable scope,
                   Scriptable thisObj,
                   Object[] args)
            throws JavaScriptException
Specified by:
call in interface Function
call in interface Callable
Overrides:
call in interface org.mozilla.javascript.Delegator

See Also:
Function.call(Context,Scriptable,Scriptable,Object[])