public class ScriptURLStreamHandler extends URLStreamHandler
script protocol/schema and evaluates expressions using Java Scripting framework.
Expression language extension is passed as authority and expression is passed as path, e.g. script://java/myObject.toString().
Evaluation result is converted to input stream in the following way:
a) If it is input stream then it is returned as is.
b) If it is Reader then it is wrapped into input stream.
c) If it is null, then null is returned.
d) Result is converted to String with toString() method and string bytes are returned as input stream.| Modifier and Type | Field and Description |
|---|---|
static String |
SCRIPT_PROTOCOL |
| Constructor and Description |
|---|
ScriptURLStreamHandler(ClassLoader classLoader,
Map<String,Object> bindings) |
ScriptURLStreamHandler(Map<String,Object> bindings) |
| Modifier and Type | Method and Description |
|---|---|
static void |
main(String[] args) |
protected URLConnection |
openConnection(URL u) |
equals, getDefaultPort, getHostAddress, hashCode, hostsEqual, openConnection, parseURL, sameFile, setURL, setURL, toExternalFormpublic static final String SCRIPT_PROTOCOL
public ScriptURLStreamHandler(ClassLoader classLoader, Map<String,Object> bindings)
classLoader - ClassLoader to use to load script engines and other classes.bindings - Bindings for evaluating script expression.public ScriptURLStreamHandler(Map<String,Object> bindings)
bindings - Bindings for evaluating script expression.protected URLConnection openConnection(URL u) throws IOException
openConnection in class URLStreamHandlerIOException