Class JavaxPacScriptParser
java.lang.Object
com.github.markusbernhardt.proxy.selector.pac.JavaxPacScriptParser
- All Implemented Interfaces:
PacScriptParser
PAC parser using the Rhino JavaScript engine bundled with Java 1.6
More information about PAC can be found there:
Proxy_auto-config
web-browser-auto-proxy-configuration
More information about PAC can be found there:
Proxy_auto-config
web-browser-auto-proxy-configuration
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final delight.rhinosandox.RhinoSandbox
(package private) static final String
private final PacScriptSource
(package private) static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
buildFunctionCallCode
(String functionName, int args) Builds a JavaScript code snippet to call a function that we bind.Evaluates the given URL and host against the PAC script.Gets the source of the PAC script used by this parser.private delight.rhinosandox.RhinoSandbox
Initializes the JavaScript engine and adds aliases for the functions defined in ScriptMethods.
-
Field Details
-
SCRIPT_METHODS_OBJECT
- See Also:
-
SOURCE_NAME
-
source
-
engine
private final delight.rhinosandox.RhinoSandbox engine
-
-
Constructor Details
-
JavaxPacScriptParser
Constructor- Parameters:
source
- the source for the PAC script.- Throws:
ProxyEvaluationException
- on error.
-
-
Method Details
-
setupEngine
Initializes the JavaScript engine and adds aliases for the functions defined in ScriptMethods.- Throws:
ProxyEvaluationException
- on error.
-
buildFunctionCallCode
Builds a JavaScript code snippet to call a function that we bind.- Parameters:
functionName
- of the bound functionargs
- of the bound function- Returns:
- the JS code to invoke the method.
-
getScriptSource
Gets the source of the PAC script used by this parser.- Specified by:
getScriptSource
in interfacePacScriptParser
- Returns:
- a PacScriptSource.
-
evaluate
Evaluates the given URL and host against the PAC script.- Specified by:
evaluate
in interfacePacScriptParser
- Parameters:
url
- the URL to evaluate.host
- the host name part of the URL.- Returns:
- the script result.
- Throws:
ProxyEvaluationException
- on execution error.
-