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
    Modifier and Type
    Field
    Description
    static final String
     

    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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Convert the current snippet transaction into an extended transaction.
    void
    Commit the current snippet transaction and create a new branched extended transaction.
    void
    branch(Map<String,?> openOptions, Map<String,?> syncOptions)
    Commit the current snippet transaction and create a new branched extended transaction with options.
    void
    Commit the current snippet transaction and open a new non-extended transaction.
    protected int
     
    Get the instance associated with the current thread.
    Get the Permazen Session associated with this instance.
    protected void
    Invoked by PermazenExecutionControl.enterContext() to create or join a snippet transaction.
    protected void
    leaveTransaction(boolean success)
    Invoked by PermazenExecutionControl.leaveContext(boolean) to commit or leave the snippet transaction.
    protected List<String>
     
    static File
    Make a classpath resource available as a File.
    void
    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

  • Constructor Details

  • Method Details

    • setRunStandardStartup

      public void setRunStandardStartup(boolean runStandardStartup)
      Set whether to run the standard Permazen jshell startup script.
    • getCurrent

      public static PermazenJShellShellSession getCurrent()
      Get the instance associated with the current thread.

      This method just returns the result from JShellShellSession.getCurrent() cast to a PermazenJShellShellSession.

      Returns:
      the instance of this class associated with the current thread, or null if none found
      See Also:
      • JShellShellSession.getCurrent()
    • modifyJShellParams

      protected List<String> modifyJShellParams(List<String> params)
      Overrides:
      modifyJShellParams in class org.dellroad.jct.jshell.JShellShellSession
    • doExecute

      protected int doExecute() throws InterruptedException
      Overrides:
      doExecute in class org.dellroad.jct.jshell.JShellShellSession
      Throws:
      InterruptedException
    • getPermazenSession

      public Session getPermazenSession()
      Description copied from interface: HasPermazenSession
      Get the Permazen Session associated with this instance.
      Specified by:
      getPermazenSession in interface HasPermazenSession
    • 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

      public void branch(Map<String,?> openOptions, Map<String,?> syncOptions)
      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 none
      syncOptions - 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 by PermazenExecutionControl.enterContext() to create or join a snippet transaction.
      Throws:
      IllegalStateException - if there's not supposed to be an extended snippet transaction but there's is
      IllegalStateException - if there's supposed to be an extended snippet transaction but there's not
    • leaveTransaction

      protected void leaveTransaction(boolean success)
      Invoked by PermazenExecutionControl.leaveContext(boolean) to commit or leave the snippet transaction.
      Throws:
      IllegalStateException - if there is no current snippet transaction
    • resourceToFile

      public static File resourceToFile(String resource)
      Make a classpath resource available as a File.

      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 - if resource is not found or inaccessible
      IllegalArgumentException - if resource is null