com.google.caja.util
Class RhinoExecutor

java.lang.Object
  extended by com.google.caja.util.RhinoExecutor
All Implemented Interfaces:
Executor

public final class RhinoExecutor
extends java.lang.Object
implements Executor

Do not instantiate directly. Use Executor.Factory instead. This will be obsoleted once a JDK ships with built-in scripting language support and proper sand-boxing.

Author:
mikesamuel@gmail.com

Nested Class Summary
static class RhinoExecutor.Connection
           
static class RhinoExecutor.ScriptPowerBox
           
static class RhinoExecutor.Timer
           
 
Nested classes/interfaces inherited from interface com.google.caja.util.Executor
Executor.AbnormalExitException, Executor.Factory, Executor.Input, Executor.MalformedSourceException
 
Field Summary
private static java.util.Set<java.lang.String> CLASS_WHITELIST
           
private static java.util.concurrent.ScheduledExecutorService executorService
           
private static java.util.Set<java.lang.String> OBJECT_CLASS_MEMBERS
           
private static org.mozilla.javascript.ContextFactory SANDBOXINGFACTORY
           
private  Executor.Input[] srcs
           
private static java.lang.Object[] ZERO_ARGS
           
 
Constructor Summary
RhinoExecutor(Executor.Input[] srcs)
           
 
Method Summary
private static java.lang.String drain(java.io.Reader r)
           
static void enableContentUrls()
          Allow parsing of content: URLs which can be useful for browser mocks since it allows us to specify HTML in a URL which can be passed to env.js.
<T> T
run(java.util.Map<java.lang.String,?> actuals, java.lang.Class<T> expectedResultType)
          Execute in the context of the given bindings and coerce the result to the given type.
private
<T> T
runInContext(org.mozilla.javascript.Context context, java.util.Map<java.lang.String,?> actuals, java.lang.Class<T> expectedResultType)
           
private static java.lang.String withLineNums(java.lang.String source)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

srcs

private final Executor.Input[] srcs

OBJECT_CLASS_MEMBERS

private static final java.util.Set<java.lang.String> OBJECT_CLASS_MEMBERS

CLASS_WHITELIST

private static final java.util.Set<java.lang.String> CLASS_WHITELIST

SANDBOXINGFACTORY

private static final org.mozilla.javascript.ContextFactory SANDBOXINGFACTORY

executorService

private static final java.util.concurrent.ScheduledExecutorService executorService

ZERO_ARGS

private static final java.lang.Object[] ZERO_ARGS
Constructor Detail

RhinoExecutor

public RhinoExecutor(Executor.Input[] srcs)
Method Detail

run

public <T> T run(java.util.Map<java.lang.String,?> actuals,
                 java.lang.Class<T> expectedResultType)
      throws Executor.AbnormalExitException
Description copied from interface: Executor
Execute in the context of the given bindings and coerce the result to the given type.

Specified by:
run in interface Executor
Throws:
Executor.AbnormalExitException - if the script could not produce a result.

runInContext

private <T> T runInContext(org.mozilla.javascript.Context context,
                           java.util.Map<java.lang.String,?> actuals,
                           java.lang.Class<T> expectedResultType)
                throws Executor.AbnormalExitException
Throws:
Executor.AbnormalExitException

drain

private static final java.lang.String drain(java.io.Reader r)
                                     throws java.io.IOException
Throws:
java.io.IOException

withLineNums

private static final java.lang.String withLineNums(java.lang.String source)

enableContentUrls

public static void enableContentUrls()
Allow parsing of content: URLs which can be useful for browser mocks since it allows us to specify HTML in a URL which can be passed to env.js.

This registers a handler for the content protocol so that content:foo-bar when loaded via java.net.URL will yield an InputStream containing the UTF-8 encoding of the string "foo-bar".



Copyright (C) 2008 Google Inc.
Licensed under the Apache License, Version 2.0