Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context.initStandardObjects()


        String resultStr = "";

        Context cx = Context.enter();
        try {

            Scriptable scope = cx.initStandardObjects(null);

            // Set up some objects for the script to play with
            scope.put("log", scope, log); //$NON-NLS-1$
            scope.put("ctx", scope, jmctx); //$NON-NLS-1$
            scope.put("vars", scope, vars); //$NON-NLS-1$
View Full Code Here


        boolean result = false;

        // now evaluate the condition using JavaScript
        Context cx = Context.enter();
        try {
            Scriptable scope = cx.initStandardObjects(null);
            Object cxResultObject = cx.evaluateString(scope, cond
            /** * conditionString ** */
            , "<cmd>", 1, null);
            resultStr = Context.toString(cxResultObject);

View Full Code Here

     */
    public static ScriptableObject getGlobalScope() {
      if (globalScope == null) {
      Context cx= PersevereContextFactory.getContext();
      // create the global object
      globalScope = (ScriptableObject) cx.initStandardObjects(new ProtectedGlobal());
      final Scriptable objectPrototype = ScriptableObject.getObjectPrototype(globalScope);
      final Scriptable arrayPrototype = ScriptableObject.getClassPrototype(globalScope,"Array");
      final Scriptable functionPrototype = ScriptableObject.getClassPrototype(globalScope,"Function");
      // create our own Object that creates persistable objects
/*      Scriptable persistableObject = new PersistableConstructor(objectPrototype, "Object") {
View Full Code Here

      Context cx = Context.enter();
      logger.debug("Using implementation version: " + cx.getImplementationVersion());
      cx.setOptimizationLevel(9);
      Global global = new Global();
      global.init(cx);
      scope = cx.initStandardObjects(global);
      cx.evaluateReader(scope, new InputStreamReader(env.openConnection().getInputStream()), env.getFile(), 1, null);
      Scriptable lessEnv = (Scriptable) scope.get("lessenv", scope);
      lessEnv.put("charset", lessEnv, options.getCharset());
      lessEnv.put("css", lessEnv, options.isCss());
      lessEnv.put("loader", lessEnv, Context.javaToJS(loader, scope));
View Full Code Here

    Context cx = Context.enter();
    try {
      // Initialize the standard objects (Object, Function, etc.)
      // This must be done before scripts can be executed. Returns
      // a scope object that we use in later calls.
      Scriptable scope = cx.initStandardObjects();
      cx.setErrorReporter(new ErrorReporter() {

        @Override
        public void warning(String arg0, String arg1, int arg2,
            String arg3, int arg4) {
View Full Code Here

                throw new MojoExecutionException("Cant' load jslint.js", e);
            }
        } else {
            try {
                Context cx = contextFactory.enter();
                ScriptableObject scope = cx.initStandardObjects();
                Reader r = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(JSLINT_FILE), UTF8);
                cx.evaluateReader(scope, r, "jslint.js", 1, null);
                return new JSLint(contextFactory, scope);
            } catch (IOException ioe) {
                throw new MojoExecutionException("Cant' load jslint.js", ioe);
View Full Code Here

    URL cssmin = getClass().getClassLoader().getResource("META-INF/cssmin.js");
    Context cx = Context.enter();
    cx.setOptimizationLevel(9);
    Global global = new Global();
    global.init(cx);
    Scriptable scope = cx.initStandardObjects(global);
    cx.evaluateString(scope, "var exports = {};", "exports", 1, null);
    cx.evaluateReader(scope, new InputStreamReader(cssmin.openConnection().getInputStream()), cssmin.getFile(), 1, null);
    Scriptable exports = (Scriptable) scope.get("exports", scope);
    Scriptable compressor = (Scriptable) exports.get("compressor", exports);
    Function fn = (Function) compressor.get("cssmin", compressor);
View Full Code Here

   
    try {
              // Initialize the standard objects (Object, Function, etc.)
              // This must be done before scripts can be executed. Returns
              // a scope object that we use in later calls.
              Scriptable scope = context.initStandardObjects();
             
              // Secure Context
              this.secureContext(context);
 
              // Collect the arguments into a single string.
View Full Code Here

            Context cx = Context.enter();
            logger.debug("Using implementation version: " + cx.getImplementationVersion());
            cx.setOptimizationLevel(9);
            Global global = new Global();
            global.init(cx);
            scope = cx.initStandardObjects(global);
            cx.evaluateReader(scope, new InputStreamReader(env.openConnection().getInputStream()), env.getFile(), 1, null);
            cx.evaluateString(scope, "lessenv.charset = '" + CHARSET + "';", "charset", 1, null);
            cx.evaluateString(scope, "lessenv.css = " + "true" + ";", "css", 1, null);
            cx.evaluateReader(scope, new InputStreamReader(less.openConnection().getInputStream()), less.getFile(), 1, null);
            cx.evaluateReader(scope, new InputStreamReader(engine.openConnection().getInputStream()), engine.getFile(), 1, null);
View Full Code Here

        String scriptStr = sb.toString();

        Context cx = Context.enter();
        boolean providerFound = false;
        try {
            Scriptable scriptScope = cx.initStandardObjects(null, true);
            Object[] ids = compileScript(cx, scriptStr, scriptScope, f);
            if (ids.length > 0) {
                Service.Mode mode = Service.Mode.PAYLOAD;
                for (Object idObj : ids) {
                    if (!(idObj instanceof String)) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.