Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context$WrapHandlerProxy


    if (getProperty(Constants.OPTION_FILE_IN_MEMORY) != "") {
      Constants.fileInMemory = Boolean.valueOf(getProperty(Constants.OPTION_FILE_IN_MEMORY));
    }

    final Context cx = Context.enter();
    cx.setOptimizationLevel(-1);
    final ScriptableObject scope = cx.initStandardObjects();

    putFunctions(cx, scope);
    putConf(cx, scope);

    final String mainFile = getProperty(Constants.JS_PATH) + File.separator + getProperty(Constants.JS_MAIN_FILE);
View Full Code Here


* Date: 2013-07-17
* Time: 11:20
*/
public final class Main {
    public static void main(String[] args) throws Exception {
        final Context context = Context.enter();
        try {
            final ScriptableObject global = context.initStandardObjects();
            final Module module = new Module("global", new File(System.getProperty("user.dir")));
            module.init(context, global);
        } finally {
            Context.exit();
        }
View Full Code Here

        rhinoClassLoader = new RhinoClassLoader(documentURL,
                                                getClass().getClassLoader());
        Context.setCachingEnabled(false); // reset the cache
        Context.setCachingEnabled(true)// enable caching again
        // entering a context
        Context ctx = enterContext();
        try {
            try {
                Scriptable scriptable = ctx.initStandardObjects(null, false);
                ScriptableObject.defineClass(scriptable, WindowWrapper.class);
            } catch (Exception e) {
                // cannot happen
            }
            // we now have the window object as the global object from the
View Full Code Here

    /**
     * Implementation helper. Makes sure the proper security is set
     * on the context.
     */
    public Context enterContext(){
        Context ctx = Context.enter();
        if (ctx != defaultContext){
            // Set the SecurityController the Context should
            // use.
            if (!contexts.contains(ctx)) {
                ctx.setWrapFactory(wrapFactory);
                ctx.setSecurityController(securityController);
                contexts.add(ctx);

                // Hopefully, we are not switching threads too
                // often ....
                defaultContext = ctx;
View Full Code Here

     */
    public Object evaluate(Reader scriptreader, String description)
        throws InterpreterException, IOException {

        Object rv = null;
        final Context ctx = enterContext();

        try {
          rv = ctx.evaluateReader(globalObject,
                                  scriptreader,
                                  description,
                                  1, rhinoClassLoader);
        } catch (JavaScriptException e) {
            // exception from JavaScript (possibly wrapping a Java Ex)
View Full Code Here

     * value of the last expression evaluated in the script.
     */
    public Object evaluate(final String scriptstr)
        throws InterpreterException {

        final Context ctx = enterContext();

        Script script = null;
        Entry et = null;
        Iterator it = compiledScripts.iterator();
        // between nlog(n) and log(n) because it is
        // an AbstractSequentialList
        while (it.hasNext()) {
            if ((et = (Entry)(it.next())).str.equals(scriptstr)) {
                // if it is not at the end, remove it because
                // it will change from place (it is faster
                // to remove it now)
                script = et.script;
                it.remove();
                break;
            }
        }

        if (script == null) {
            // this script has not been compiled yet or has been forgotten
            // since the compilation:
            // compile it and store it for future use.

            script = (Script)AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() {
                        try {
                            return ctx.compileReader(globalObject,
                                                     new StringReader(scriptstr),
                                                     SOURCE_NAME_SVG,
                                                     1, rhinoClassLoader);
                        } catch (IOException io) {
                            // Should never happen: we are using a string
View Full Code Here

     * the environment of the interpreter.
     * @param name the name of the script object to create
     * @param object the Java object
     */
    public void bindObject(String name, Object object) {
        Context ctx = enterContext();

        try {
            if (name.equals(BIND_NAME_WINDOW) && object instanceof Window) {
                ((WindowWrapper)globalObject).window = (Window)object;
            } else {
View Full Code Here

     * To be used by <code>EventTargetWrapper</code>.
     */
    void callHandler(Function handler,
                     Object arg)
        throws JavaScriptException {
        Context ctx = enterContext();

        try {
            arg = Context.toObject(arg, globalObject);
            Object[] args = {arg};
            handler.call(ctx, globalObject, globalObject, args);
View Full Code Here

     */
    void callMethod(ScriptableObject obj,
                    String methodName,
                    ArgumentsBuilder ab)
        throws JavaScriptException {
        Context ctx = enterContext();

        try {
            ScriptableObject.callMethod(obj, methodName, ab.buildArguments());
        } finally {
            Context.exit();
View Full Code Here

     * To be used by <code>WindowWrapper</code>.
     */
    void callHandler(Function handler,
                     Object[] args)
        throws JavaScriptException {
        Context ctx = enterContext();

        try {
            handler.call(ctx, globalObject, globalObject, args);
        } finally {
            Context.exit();
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Context$WrapHandlerProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.