This document provides technical details about GroovyServ, a Groovy script server. It describes how GroovyServ works as a server that listens on port 1961 for client connections using a RequestWorker. The client can send script code which is executed by the server and results returned. Details are given about the request and response formats, handling the current working directory, and using Maven to build and test GroovyServ.
39. InvocationRequest
'Cwd:' <cwd> LF
'Arg:' <argn> LF
'Arg:' <arg1> LF
'Arg:' <arg2> LF
'Cp:' <classpath> LF
'Cookie:' <cookie> LF
LF
where:
<cwd> is current working directory.
<arg1><arg2>.. are commandline arguments(optional).
<classpath>.. is the value of environment variable
CLASSPATH(optional).
<cookie> is authentication value which certify client is
the user who invoked the server.
LF is line feed (0x0a, 'n').
40. StreamRequest
'Size:' <size> LF
LF
<data from STDIN>
where:
<size> is the size of data to send to server. <size>==-1
means client exited.
<data from STDIN> is byte sequence from standard input.
41. StreamResponse
'Status:' <status> LF
'Channel:' <id> LF
'Size:' <size> LF
LF
<data for STDERR/STDOUT>
where:
<status> is exit status of invoked groovy script.
<id> is 'out' or 'err', where 'out' means standard output
of the program. 'err' means standard error of the program.
<size> is the size of chunk.
<data from STDERR/STDOUT> is byte sequence from standard
output/error.
47. CWD(Current Working Directory)
Java
GroovyServ CWD
CWD
$ cd /tmp
$ groovyserver -r
$ cd /home/kobo
$ cat > hoge.txt
HOGE!!
^C
$ groovyclient -e ‘println(new File(“hoge.txt”).text)’
Caught: java.io.FileNotFoundException: hoge.txt (No such file or directory)
...SNIP...
48. “user.dir”
File#getAbsolutePath()
“"user.dir", which is initialized during jvm
startup, should be used as an informative/readonly
system property” posted 2008-08-18
http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4117557
JNA JVM CWD
“user.dir”
FileInputStream
CWD
Groovy