com.martiansoftware.nailgun
public class NGContext extends Object
Provides quite a bit of potentially useful information to classes specifically written for NailGun. The NailGun server itself, its AliasManager, the remote client's environment variables, and other information is available via this class. For all intents and purposes, the NGContext represents a single connection from a NailGun client.
If a class is written with a
public static void nailMain(NGContext context)
method, that method will be called by NailGun instead of the traditional
main(String[])
method normally used for programs. A fully populated NGContext
object will then be provided to nailMain()
.
Field Summary | |
---|---|
PrintStream | err
The client's stderr |
InputStream | in
The client's stdin |
PrintStream | out
The client's stdout |
Method Summary | |
---|---|
void | assertLocalClient()
Throws a java.lang.SecurityException if the client is not
connected from the local machine. |
void | assertLoopbackClient()
Throws a java.lang.SecurityException if the client is not
connected via the loopback address. |
void | exit(int exitCode)
Sends an exit command with the specified exit code to
the client. |
String[] | getArgs()
Returns the command line arguments for the command
implementation (nail) on the server. |
String | getCommand()
Returns the command that was issued by the client (either an alias or the name of a class).
|
Properties | getEnv()
Returns a java.util.Properties object containing a copy
of the client's environment variables |
String | getFileSeparator()
Returns the file separator ('/' or '\\') used by the client's os. |
InetAddress | getInetAddress()
Returns the address of the client at the other side of this connection. |
NGServer | getNGServer()
Returns the NGServer that accepted this connection |
String | getPathSeparator()
Returns the path separator (':' or ';') used by the client's os. |
int | getPort()
Returns the port on the client connected to the NailGun
server. |
String | getWorkingDirectory()
Returns the current working directory of the client, as reported by the client.
|
java.lang.SecurityException
if the client is not
connected from the local machine.java.lang.SecurityException
if the client is not
connected via the loopback address.Parameters: exitCode the exit code with which the client should exit
Returns: the command line arguments for the command implementation (nail) on the server.
Returns: the command issued by the client
java.util.Properties
object containing a copy
of the client's environment variablesReturns: a java.util.Properties
object containing a copy
of the client's environment variables
See Also: java.util.Properties
Returns: the file separator ('/' or '\\') used by the client's os.
Returns: the address of the client at the other side of this connection.
Returns: the NGServer that accepted this connection
Returns: the path separator (':' or ';') used by the client's os.
Returns: the port on the client connected to the NailGun server.
File.separator
('/' or '\'),
which may differ from the separator on the server.Returns: the current working directory of the client