Package de.uni_kiel.rz.fdr.repl
Class REPL
java.lang.Object
de.uni_kiel.rz.fdr.repl.REPL
This class represents a single REPL interface with an associated SSH service.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The default name of the work subdirectory containing the REPL's persistent state.static boolean
Does this build of cau-repl contain GPL licensed code?static boolean
Are we running in a JVM whith MyCoRe?static boolean
Are we running in a JVM with MyCoRe's MODS module?static final String
Threads of cau-repl have a name that starts with this prefixstatic final org.apache.sshd.common.AttributeRepository.AttributeKey<String>
The user name used for login will be accessible from each SSH Session using this key.static final String
cau-repl's version -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a startup script from our .jar to be executed in the REPL each time a user has connected.void
addSessionListener
(org.apache.sshd.common.session.SessionListener sessionListener) Respond to SSH events by installing your own listener.void
addStartupCommand
(String cmd) Adds a command to be executed inside the REPL each time a user has connected.void
addStartupScript
(String path) Add a startup script to be executed in the REPL each time a user has connected.static void
discoverEnvironment
(ClassLoader classLoader) Update the variousHAVE_*
fields.org.apache.sshd.server.auth.password.PasswordAuthenticator
Gets the authenticator in use for the SSH session.static ClassLoader
Gets the ClassLoader that will be used for the REPL.Gets the IP that the SSH service will bind to.int
getPort()
Gets the port that the SSH service will listen on.List<org.apache.sshd.common.session.SessionListener>
Gets the session listeners that were configured for the SSH service.Get the startup commands that were configured for the REPL.Get the startup scripts that were configured for the REPL.int
Get the timeout for idle SSH connections.static String
Generates a textual representation of cau-repl's versionstatic File
Get the REPL's work directoryvoid
setAuthenticator
(org.apache.sshd.server.auth.password.PasswordAuthenticator authenticator) Sets a custom authenticator for the SSH service.static void
setWorkDir
(File workDir) Allows you to initialize the global work directory before creating a REPL instance.void
start()
Start listening for incoming SSH connections.
-
Field Details
-
VERSION
cau-repl's version- See Also:
-
USER_KEY
The user name used for login will be accessible from each SSH Session using this key. -
DEFAULT_WORK_SUBDIR
The default name of the work subdirectory containing the REPL's persistent state.- See Also:
-
THREAD_PREFIX
Threads of cau-repl have a name that starts with this prefix- See Also:
-
HAVE_GPL
public static boolean HAVE_GPLDoes this build of cau-repl contain GPL licensed code? -
HAVE_MYCORE
public static boolean HAVE_MYCOREAre we running in a JVM whith MyCoRe? -
HAVE_MYCORE_MODS
public static boolean HAVE_MYCORE_MODSAre we running in a JVM with MyCoRe's MODS module?
-
-
Constructor Details
-
REPL
public REPL(String listenAddr, Integer port, Integer timeoutSecs, File workDir, ClassLoader groovyClassLoader) throws IOException Creates the REPL. You should only have one instance of this per VM.- Parameters:
listenAddr
- IP address that the SSH service will bind to (default 127.0.0.1)port
- Port that the SSH service will bind to (default 8512)timeoutSecs
- Terminate idle SSH connections after this many seconds (default 12h)workDir
- The directory that will contain the REPL's perisistent state. It will be created if it does not exists. (defaultcau-repl
in the cwd)groovyClassLoader
- The ClassLoader to use for the REPL (defaults to a new private ClassLoader)- Throws:
IOException
- A file could not be accessed.
-
-
Method Details
-
start
Start listening for incoming SSH connections.- Throws:
IOException
- The server could not be started.
-
getListenAddr
Gets the IP that the SSH service will bind to.- Returns:
- The IP that the SSH service will bind to.
-
getPort
public int getPort()Gets the port that the SSH service will listen on.- Returns:
- The port that the SSH service will listen on.
-
getTimeoutSecs
public int getTimeoutSecs()Get the timeout for idle SSH connections.- Returns:
- The timeout for idle SSH connections.
-
getAuthenticator
public org.apache.sshd.server.auth.password.PasswordAuthenticator getAuthenticator()Gets the authenticator in use for the SSH session.- Returns:
- The authenticator in use for the SSH session.
-
setAuthenticator
public void setAuthenticator(org.apache.sshd.server.auth.password.PasswordAuthenticator authenticator) Sets a custom authenticator for the SSH service. Must be called beforestart()
.- Parameters:
authenticator
- The authenticator to use
-
addStartupScript
Add a startup script to be executed in the REPL each time a user has connected. Must be called beforestart()
.- Parameters:
path
- Location of the script
-
getStartupScripts
Get the startup scripts that were configured for the REPL.- Returns:
- The startup scripts that were configured for the REPL.
-
addInternalStartupScript
Add a startup script from our .jar to be executed in the REPL each time a user has connected. Must be called beforestart()
.- Parameters:
path
- Location of the script inside our .jar
-
getStartupCommands
Get the startup commands that were configured for the REPL.- Returns:
- The startup commands that were configured for the REPL.
-
addStartupCommand
Adds a command to be executed inside the REPL each time a user has connected. Must be called beforestart()
.- Parameters:
cmd
- The command to execute.
-
getSessionListeners
Gets the session listeners that were configured for the SSH service.- Returns:
- The session listeners that were configured for the SSH service.
-
addSessionListener
public void addSessionListener(org.apache.sshd.common.session.SessionListener sessionListener) Respond to SSH events by installing your own listener. Must be called beforestart()
.- Parameters:
sessionListener
- The listener to add
-
getWorkDir
Get the REPL's work directory- Returns:
- the REPL's work directory
-
getGroovyClassLoader
Gets the ClassLoader that will be used for the REPL.- Returns:
- The ClassLoader that will be used for the REPL.
-
setWorkDir
Allows you to initialize the global work directory before creating a REPL instance. This might be neccessary when you precompile Groovy sources). You can only set this directory once.- Parameters:
workDir
- The work directory to use- Throws:
IOException
- The directory could not be accessed.
-
discoverEnvironment
Update the variousHAVE_*
fields.- Parameters:
classLoader
- The ClassLoader to use as a reference
-
getVersionString
Generates a textual representation of cau-repl's version- Returns:
- cau-repl's version string.
-