Package io.permazen.cli.jshell
Class PermazenJShellShellSession
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
io.permazen.cli.jshell.PermazenJShellShellSession
- All Implemented Interfaces:
HasPermazenSession
,org.dellroad.jct.core.ConsoleSession<org.dellroad.jct.core.Shell,
,org.dellroad.jct.core.ShellRequest> org.dellroad.jct.core.ShellSession
public class PermazenJShellShellSession
extends org.dellroad.jct.jshell.JShellShellSession
implements HasPermazenSession
A version of the JCT
JShellShellSession
that is Permazen aware.
Instances are created by PermazenJShellShell
.
-
Field Summary
Fields inherited from class org.dellroad.jct.jshell.JShellShellSession
localContextClassLoader
Fields inherited from class org.dellroad.jct.core.AbstractShellSession
exitValue, in, out
Fields inherited from class org.dellroad.jct.core.AbstractConsoleSession
owner, request
-
Constructor Summary
ConstructorDescriptionPermazenJShellShellSession
(PermazenJShellShell shell, PermazenShellRequest request) -
Method Summary
Modifier and TypeMethodDescriptionvoid
begin()
Convert the current snippet transaction into an extended transaction.void
branch()
Commit the current snippet transaction and create a new branched extended transaction.void
Commit the current snippet transaction and create a new branched extended transaction with options.void
commit()
Commit the current snippet transaction and open a new non-extended transaction.protected int
static PermazenJShellShellSession
Get the instance associated with the current thread.Get the PermazenSession
associated with this instance.protected void
Invoked byPermazenExecutionControl.enterContext()
to create or join a snippet transaction.protected void
leaveTransaction
(boolean success) Invoked byPermazenExecutionControl.leaveContext(boolean)
to commit or leave the snippet transaction.modifyJShellParams
(List<String> params) static File
resourceToFile
(String resource) Make a classpath resource available as aFile
.void
rollback()
Abort the current snippet transaction and open a new non-extended transaction.void
setRunStandardStartup
(boolean runStandardStartup) Set whether to run the standard Permazen jshell startup script.Methods inherited from class org.dellroad.jct.jshell.JShellShellSession
buildOutputStream, createBuilder, getOwner, setLocalContextClassLoader
Methods inherited from class org.dellroad.jct.core.AbstractShellSession
buildInputStream, getExitValue, getInputStream, getOutputStream, setExitValue
Methods inherited from class org.dellroad.jct.core.AbstractConsoleSession
doInterrupt, execute, getRequest, interrupt
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.dellroad.jct.core.ConsoleSession
execute, getRequest, interrupt
Methods inherited from interface org.dellroad.jct.core.ShellSession
getErrorStream
-
Field Details
-
RESOURCE_TEMPORARY_FILE_PREFIX
- See Also:
-
-
Constructor Details
-
PermazenJShellShellSession
-
-
Method Details
-
setRunStandardStartup
public void setRunStandardStartup(boolean runStandardStartup) Set whether to run the standard Permazen jshell startup script. -
getCurrent
Get the instance associated with the current thread.This method just returns the result from
JShellShellSession.getCurrent()
cast to aPermazenJShellShellSession
.- Returns:
- the instance of this class associated with the current thread, or null if none found
- See Also:
-
JShellShellSession.getCurrent()
-
modifyJShellParams
- Overrides:
modifyJShellParams
in classorg.dellroad.jct.jshell.JShellShellSession
-
doExecute
- Overrides:
doExecute
in classorg.dellroad.jct.jshell.JShellShellSession
- Throws:
InterruptedException
-
getPermazenSession
Description copied from interface:HasPermazenSession
Get the PermazenSession
associated with this instance.- Specified by:
getPermazenSession
in interfaceHasPermazenSession
-
commit
public void commit()Commit the current snippet transaction and open a new non-extended transaction.This method is only intended to be invoked from JShell snippets.
- Throws:
IllegalStateException
- if there is no current snippet transaction
-
rollback
public void rollback()Abort the current snippet transaction and open a new non-extended transaction.This method is only intended to be invoked from JShell snippets.
- Throws:
IllegalStateException
- if there is no current snippet transaction
-
begin
public void begin()Convert the current snippet transaction into an extended transaction.If the current transaction is already extended, nothing happens.
This method is only intended to be invoked from JShell snippets.
- Throws:
IllegalStateException
- if there is no current snippet transaction
-
branch
public void branch()Commit the current snippet transaction and create a new branched extended transaction.This method is only intended to be invoked from JShell snippets.
- Throws:
IllegalStateException
- if there is no current snippet transaction
-
branch
Commit the current snippet transaction and create a new branched extended transaction with options.This method is only intended to be invoked from JShell snippets.
- Parameters:
openOptions
-KVDatabase
-specific transaction options for the branch's opening transaction, or null for nonesyncOptions
-KVDatabase
-specific transaction options for the branch's commit transaction, or null for none- Throws:
IllegalStateException
- if there is no current snippet transaction
-
joinTransaction
protected void joinTransaction()Invoked byPermazenExecutionControl.enterContext()
to create or join a snippet transaction.- Throws:
IllegalStateException
- if there's not supposed to be an extended snippet transaction but there's isIllegalStateException
- if there's supposed to be an extended snippet transaction but there's not
-
leaveTransaction
protected void leaveTransaction(boolean success) Invoked byPermazenExecutionControl.leaveContext(boolean)
to commit or leave the snippet transaction.- Throws:
IllegalStateException
- if there is no current snippet transaction
-
resourceToFile
Make a classpath resource available as aFile
.If the resource is already a file, that file is returned. Otherwise, a temporary file is created and the file's name will begin with
RESOURCE_TEMPORARY_FILE_PREFIX
.- Parameters:
resource
- classpath resource- Returns:
File
containing the resource- Throws:
RuntimeException
- ifresource
is not found or inaccessibleIllegalArgumentException
- ifresource
is null
-