Java 类org.mozilla.javascript.LazilyLoadedCtor 实例源码

项目:ef-orm    文件:RhinoTopLevel.java   
RhinoTopLevel(Context cx, RhinoScriptEngine engine) {
    super(cx);
    this.engine = engine;


    // initialize JSAdapter lazily. Reduces footprint & startup time.
    new LazilyLoadedCtor(this, "JSAdapter",
            "com.sun.script.javascript.JSAdapter",
            false);

    /*
     * initialize JavaAdapter. We can't lazy initialize this because
     * lazy initializer attempts to define a new property. But, JavaAdapter
     * is an exisiting property that we overwrite.
     */
    JavaAdapter.init(cx, this, false);

    // add top level functions
    String names[] = { "bindings", "scope", "sync"  };
    defineFunctionProperties(names, RhinoTopLevel.class,
            ScriptableObject.DONTENUM);

    // define built-in variables
    cx.evaluateString(this, builtinVariables, "<builtin>", 1, null);
}
项目:RhinoScriptEngine    文件:RhinoTopLevel.java   
RhinoTopLevel(Context cx, RhinoScriptEngine engine) {
    // second boolean parameter to super constructor tells whether
    // to seal standard JavaScript objects or not. If security manager
    // is present, we seal the standard objects.
    super(cx, System.getSecurityManager() != null);
    this.engine = engine;


    // initialize JSAdapter lazily. Reduces footprint & startup time.
    new LazilyLoadedCtor(this, "JSAdapter",
            "com.sun.script.javascript.JSAdapter",
            false);

    /*
     * initialize JavaAdapter. We can't lazy initialize this because
     * lazy initializer attempts to define a new property. But, JavaAdapter
     * is an exisiting property that we overwrite.
     */
    JavaAdapter.init(cx, this, false);

    // add top level functions
    String names[] = { "bindings", "scope", "sync"  };
    defineFunctionProperties(names, RhinoTopLevel.class,
            ScriptableObject.DONTENUM);

    // define built-in variables
    cx.evaluateString(this, builtinVariables, "<builtin>", 1, null);
}
项目:birt    文件:JavascriptEngine.java   
public JavascriptEngine( JavascriptEngineFactory factory,
        ScriptableObject root ) throws BirtException
{
    this.factory = factory;
    try
    {
        this.context = Context.enter( );
        this.global = new ImporterTopLevel( );
        this.root = root;
        if ( root != null )
        {
            // can not put this object to root, because this object will
            // cache package and classloader information.
            // so we need rewrite this property.
            new LazilyLoadedCtor( global, "Packages",
                    "org.mozilla.javascript.NativeJavaTopPackage", false );
            global.exportAsJSClass( 3, global, false );
            global.delete( "constructor" );
            global.setPrototype( root );
        }
        else
        {
            global.initStandardObjects( context, true );
        }
        if ( global
                .get(
                        org.eclipse.birt.core.script.functionservice.IScriptFunctionContext.FUNCTION_BEAN_NAME,
                        global ) == org.mozilla.javascript.UniqueTag.NOT_FOUND )
        {
            IScriptFunctionContext functionContext = new IScriptFunctionContext( ) {

                public Object findProperty( String name )
                {
                    return propertyMap.get( name );
                }
            };

            Object sObj = Context.javaToJS( functionContext, global );
            global
                    .put(
                            org.eclipse.birt.core.script.functionservice.IScriptFunctionContext.FUNCTION_BEAN_NAME,
                            global, sObj );
        }
        initWrapFactory( );
    }
    catch ( Exception ex )
    {
        Context.exit( );
        throw new BirtException( );
    }
}