public class NGContext extends Object
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()
.Modifier and Type | Field and Description |
---|---|
PrintStream |
err
The client's stderr
|
InputStream |
in
The client's stdin
|
PrintStream |
out
The client's stdout
|
Constructor and Description |
---|
NGContext()
Creates a new, empty NGContext
|
Modifier and Type | Method and Description |
---|---|
void |
addClientListener(NGClientListener listener) |
void |
addHeartbeatListener(NGHeartbeatListener listener) |
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).
|
NGCommunicator |
getCommunicator() |
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.
|
boolean |
isClientConnected() |
void |
removeAllClientListeners()
Do not notify about client exit
|
void |
removeClientListener(NGClientListener listener) |
void |
removeHeartbeatListener(NGHeartbeatListener listener) |
void |
setArgs(String[] args) |
void |
setCommand(String command) |
void |
setCommunicator(NGCommunicator comm) |
void |
setErr(PrintStream err)
Sets the current
PrintStream for standard error for the current nail. |
void |
setIn(InputStream in)
Sets the current
InputStream for standard input for the current nail. |
void |
setOut(PrintStream out)
Sets the current
PrintStream for standard output for the current nail. |
void |
setPort(int remotePort) |
public InputStream in
public PrintStream out
public PrintStream err
public void setCommunicator(NGCommunicator comm)
public NGCommunicator getCommunicator()
public void setPort(int remotePort)
public void setCommand(String command)
public String getCommand()
public String getWorkingDirectory()
File.separator
('/' or '\'), which may differ
from the separator on the server.public void setIn(InputStream in)
InputStream
for standard input for the current nail.in
- The InputStream
to use as stdin for the current nail. This should be an
InputStream that ultimately reads from NGInputStream
.public void setOut(PrintStream out)
PrintStream
for standard output for the current nail.out
- The PrintStream
to use as stdout for the current nail. This should be a
PrintStream that ultimately writes to NGOutputStream
.public void setErr(PrintStream err)
PrintStream
for standard error for the current nail.err
- The PrintStream
to use as stderr for the current nail. This should be a
PrintStream that ultimately writes to NGOutputStream
.public void setArgs(String[] args)
public Properties getEnv()
java.util.Properties
object containing a copy of the client's
environment variablesjava.util.Properties
object containing a copy of the client's
environment variablesProperties
public String getFileSeparator()
public String getPathSeparator()
public InetAddress getInetAddress()
public String[] getArgs()
public NGServer getNGServer()
public void exit(int exitCode)
exitCode
- the exit code with which the client should exitpublic int getPort()
public void assertLoopbackClient()
java.lang.SecurityException
if the client is not connected via the
loopback address.public void assertLocalClient()
java.lang.SecurityException
if the client is not connected from the local
machine.public boolean isClientConnected()
public void addClientListener(NGClientListener listener)
listener
- the NGClientListener
to be notified of client events.public void removeClientListener(NGClientListener listener)
listener
- the NGClientListener
to no longer be notified of client events.public void removeAllClientListeners()
public void addHeartbeatListener(NGHeartbeatListener listener)
listener
- the NGHeartbeatListener
to be notified of client events.public void removeHeartbeatListener(NGHeartbeatListener listener)
listener
- the NGHeartbeatListener
to no longer be notified of client events.Copyright © 2024. All rights reserved.