java.lang.Object
org.dellroad.jct.core.AbstractConsoleSession<org.dellroad.jct.core.Shell,org.dellroad.jct.core.ShellRequest>
org.dellroad.jct.core.AbstractShellSession
org.dellroad.jct.jshell.JShellShellSession
- All Implemented Interfaces:
org.dellroad.jct.core.ConsoleSession<org.dellroad.jct.core.Shell,,org.dellroad.jct.core.ShellRequest> org.dellroad.jct.core.ShellSession
public class JShellShellSession
extends org.dellroad.jct.core.AbstractShellSession
A
ShellSession that builds and executes a JShell instance.
The associated JShell instance can be customized in two ways:
- Override
createBuilder()to customize theJavaShellToolBuilderused to create the JShell. - Override
modifyJShellParams()to customize the flags and parameters passed to JShell itself (these are the same as accepted by thejshell(1)command line tool). By default, the parameters passed are the the parameters given on the command line.
During execution, instances make themselves available to the current thread via getCurrent().
-
Field Summary
FieldsFields inherited from class org.dellroad.jct.core.AbstractShellSession
exitValue, in, outFields inherited from class org.dellroad.jct.core.AbstractConsoleSession
owner, request -
Constructor Summary
ConstructorsConstructorDescriptionJShellShellSession(JShellShell shell, org.dellroad.jct.core.ShellRequest request) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected PrintStreambuildOutputStream(org.jline.terminal.Terminal terminal) protected JavaShellToolBuilderCreate and configure the JShell builder for this new session.protected intstatic JShellShellSessionGet the instance associated with the current thread.getOwner()modifyJShellParams(List<String> params) Generate a list of command line flags and parameters to be passed to the JShell tool, given the arguments given on the shell command line for this command.voidConfigure a class loader to use withLocalContextExecutionControlProviderfor local execution.Methods inherited from class org.dellroad.jct.core.AbstractShellSession
buildInputStream, getExitValue, getInputStream, getOutputStream, setExitValueMethods inherited from class org.dellroad.jct.core.AbstractConsoleSession
doInterrupt, execute, getRequest, interruptMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.dellroad.jct.core.ConsoleSession
execute, getRequest, interruptMethods inherited from interface org.dellroad.jct.core.ShellSession
getErrorStream
-
Field Details
-
localContextClassLoader
-
-
Constructor Details
-
JShellShellSession
Constructor.- Parameters:
shell- owning shellrequest- shell request- Throws:
IllegalArgumentException- if any parameter is null
-
-
Method Details
-
getCurrent
Get the instance associated with the current thread.- Returns:
- session associated with the current thread, or null if not found
-
setLocalContextClassLoader
Configure a class loader to use withLocalContextExecutionControlProviderfor local execution.- Parameters:
loader- class loader, or null for none- See Also:
-
getOwner
- Specified by:
getOwnerin interfaceorg.dellroad.jct.core.ConsoleSession<org.dellroad.jct.core.Shell,org.dellroad.jct.core.ShellRequest> - Overrides:
getOwnerin classorg.dellroad.jct.core.AbstractConsoleSession<org.dellroad.jct.core.Shell,org.dellroad.jct.core.ShellRequest>
-
buildOutputStream
- Overrides:
buildOutputStreamin classorg.dellroad.jct.core.AbstractShellSession
-
doExecute
- Specified by:
doExecutein classorg.dellroad.jct.core.AbstractConsoleSession<org.dellroad.jct.core.Shell,org.dellroad.jct.core.ShellRequest> - Throws:
InterruptedException
-
createBuilder
Create and configure the JShell builder for this new session.- Returns:
- new builder
-
modifyJShellParams
Generate a list of command line flags and parameters to be passed to the JShell tool, given the arguments given on the shell command line for this command.If this method is overridden to add or change this command's flags and/or parameters, then the full constructor taking customized help detail should be used to describe the new usage.
The implementation in
JShellShellSessionjust returns the list unmodified unless a local context class loader has been configured, in which case the list is copied, modified byLocalContextExecutionControlProvider.modifyJShellFlags(java.lang.ClassLoader, java.util.List<java.lang.String>), and then returned.- Parameters:
params- parameters given to the shell command line- Returns:
- flags and parameters for JShell
- Throws:
IllegalArgumentException- ifcommandLineParamsis null- See Also:
-