Class AbstractContext

java.lang.Object
com.pnfsoftware.jeb.util.events.EventSource
com.pnfsoftware.jeb.client.AbstractContext
All Implemented Interfaces:
IEventSource
Direct Known Subclasses:
AbstractClientContext

public abstract class AbstractContext extends EventSource
Base context for client contexts and core contexts. Basic variables are set up (eg, paths). This class is not configuration-aware.
  • Field Details

  • Constructor Details

    • AbstractContext

      public AbstractContext()
  • Method Details

    • handleUncaughtException

      protected static String handleUncaughtException(Thread t, Throwable e)
      This method is used by all JEB contexts (including client contexts) to handle exceptions reaching the global uncaught exception handler.

      Custom client may set a handler of their own, as such:

       
       static {
           Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
               var msg = handleUncaughtException(t, e);  // call the AbstractContext handler
               if(msg == null) {
                   return;
               }
               // custom handling goes here
               // ...
            });
            ...
       
       
      Parameters:
      t - thread
      e - exception
      Returns:
      a non-null message if the exception is deemed relevant and its stacktrace was sent to the logger; null otherwise (it is recommended clients ignore the exception)
    • isPreRelease

      public static boolean isPreRelease()
    • getChannelName

      public static String getChannelName()
    • getStartTimestamp

      public final int getStartTimestamp()
      Get the program start date in seconds.
      Returns:
      a Unix timestamp
    • getJebClassesLocation

      public final File getJebClassesLocation()
      Get the location of JEB classes.
      Returns:
      a jar file (jeb.jar), or a bin/ folder containing classfiles
    • getCurrentDirectory

      public final String getCurrentDirectory()
      Get the current directory.
      Returns:
    • getBaseDirectory

      public final String getBaseDirectory()
      Get the JEB base directory.
      Returns:
    • getProgramDirectory

      public final String getProgramDirectory()
      Get the JEB program directory, typically $JEB/bin/.
      Returns:
    • getAppDirectory

      public final String getAppDirectory()
      Get the JEB app directory, typically $JEB/bin/app.
      Returns:
    • getSoftwareVersion

      public final Version getSoftwareVersion()
      Retrieve the global software version.
      Returns:
    • terminate

      public static final void terminate()
      Terminate the program.
    • initNetworkUtility

      protected static Net initNetworkUtility(String proxyString)
      The global proxy settings will be updated/erased.