public abstract class

AbstractClientContext

extends AbstractContext
implements IClientContext
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.events.EventSource
     ↳ com.pnfsoftware.jeb.client.AbstractContext
       ↳ com.pnfsoftware.jeb.client.AbstractClientContext
Known Direct Subclasses

Class Overview

Base context for official JEB clients. It is used by the RCP client context (GUI), the Controller (floating) context, as well as the headless runner.

On top of the abstract methods, which must be implemented, client code that override the following method must call the super-class method:
- initialize(String[])
- start()
- stop()

Summary

Constants
String CLIENT_RUNNING_FILENAME_PREFIX
String INSTALLER_LOCK_FILENAME
String defaultClientConfigPath
String defaultEnginesConfigPath
String defaultPluginsFolderName
String defaultScriptsFolderName
String defaultTelemetryDatabasePath
[Expand]
Inherited Constants
From class com.pnfsoftware.jeb.client.AbstractContext
Fields
protected String[] args
protected boolean basicChecksPassed
protected CoreOptions coreOptions A reference to core options that will be used when the JEB core context is instantiated in start().
protected String inputpath
protected String scriptpath
protected String ugerrstr
[Expand]
Inherited Fields
From class com.pnfsoftware.jeb.client.AbstractContext
From class com.pnfsoftware.jeb.util.events.EventSource
Protected Constructors
AbstractClientContext()
Public Methods
boolean checkRunningInstaller()
abstract boolean checkUpdate()
Not called locally: it is entirely up to the client to implement and decide who calls this method.
boolean closeMainProject()
Convenience method used to close the main project (if any), that is, the first project of the first engines context managed by the JEB back-end.
final boolean closeOpenedProject()
abstract void displayDemoInformation(String demoInfo)
Called from start().
abstract boolean displayEula(String eula)
Called from start().
final void dumpUpdateToDisk(byte[] data, String password)
static String formatMemoryUsage()
static String formatProcessInfo(boolean inclPid, boolean inclMeminfo, boolean inclTimes, boolean inclCmdline)
Format various process information bits.
final static String generateLicenseInformation()
String[] getArguments()
Get the input arguments provided to this client context.
Configuration getConfiguration()
String getControllerInterface()
String getControllerMessage()
int getControllerPort()
int getControllerProtocol()
final ICoreContext getCoreContext()
Get the JEB core instance.
final IEnginesContext getEnginesContext()
Get the JEB engines instance.
String getInputpath()
final int getLastPublicAnnouncementId()
final Version getLatestAvailableUpdate()
int getLogLevel()
IRuntimeProject getMainProject()
long getMaxMemory()
Get the theoretical maximum amount of memory that JEB can allocate and use.
Net getNetworkUtility()
final IRuntimeProject getOpenedProject()
Retrieve the current project, if any.
final String getPreferredLanguage()
long getProcessId()
Retrieve the process id of the Java VM executing JEB.
IPropertyDefinitionManager getPropertyDefinitionManager()
IPropertyManager getPropertyManager()
final String getProxyString()
String getScriptpath()
final String getScriptsDirectory()
Retrieve the JEB scripts directory path.
final File getScriptsDirfile()
Retrieve and if necessary create the JEB scripts directory.
ITelemetryDatabase getTelemetry()
Map<Object, Object> getTransientStore()
Retrieve a reference to the transient store provided by this context.
final int getUpdateChannel()
long getUsedMemory()
Get the amount of memory currently used by JEB.
final long getUuid()
final boolean hasOpenedProject()
void initialize(String[] argv)
boolean isDevelopmentMode()
boolean isHeadless()
final void logMemoryUsage()
abstract void notifyFloatingClient(ControllerNotification notification)
May be called from anywhere, any thread.
abstract void notifySupportExpired()
Called from start().
abstract void onUpdatedSoftware(String changelist, Version oldVersion)
Notify a concrete client that a new version of JEB is being run for the first time.
IUnit open(String path)
Convenience method used to create a JEB project (or retrieve the current project if one is opened), load a file artifact into the project, process it, and return the resulting top-level unit.
final int ping(int downloadOrder, int clientChannel, SoftwareBuildInfo sbi, IProgressCallback progressCallback, boolean verbose)
Ping the JEB update server, and optionally download a JEB update on a compatible update channel.
final PublicAnnouncement retrieveLatestPublicAnnouncement()
abstract String retrieveLicenseKey(String licdata)
Called from start().
void setControllerInterface(String iface)
void setControllerPort(int port)
void setControllerProtocol(int protocol)
void setDevelopmentMode(boolean enabled)
final void setLastPublicAnnouncementId(int id)
final void setLatestAvailableUpdate(Version version)
void setLogLevel(int level)
final void setPreferredLanguage(String language)
final void setProxyString(String strProxyinfo)
final void setScriptsDirectory(String folder)
final void setUpdateChannel(int channel)
abstract boolean setupController()
Called from start().
final boolean shouldCheckPublicAnnouncements()
final boolean shouldCheckUpdates()
void start()
Install update, if any.
void stop()
Protected Methods
void assignCommandlineArguments(String[] argv)
Initialize the |configpath| and |inputpath|attributes.
final void initializeEngines()
Initialize the core context and an engines context.
[Expand]
Inherited Methods
From class com.pnfsoftware.jeb.client.AbstractContext
From class com.pnfsoftware.jeb.util.events.EventSource
From class java.lang.Object
From interface com.pnfsoftware.jeb.client.api.IClientContext
From interface com.pnfsoftware.jeb.util.events.IEventSource

Constants

public static final String CLIENT_RUNNING_FILENAME_PREFIX

Constant Value: ".jebc_ts"

public static final String INSTALLER_LOCK_FILENAME

Constant Value: ".jebi_lock"

public static final String defaultClientConfigPath

Constant Value: "jeb-client.cfg"

public static final String defaultEnginesConfigPath

Constant Value: "jeb-engines.cfg"

public static final String defaultPluginsFolderName

Constant Value: "coreplugins"

public static final String defaultScriptsFolderName

Constant Value: "scripts"

public static final String defaultTelemetryDatabasePath

Constant Value: "jt.db"

Fields

protected String[] args

protected boolean basicChecksPassed

protected CoreOptions coreOptions

A reference to core options that will be used when the JEB core context is instantiated in start(). Clients which decide to provide non-standard options should set this field before calling start().

protected String inputpath

protected String scriptpath

protected String ugerrstr

Protected Constructors

protected AbstractClientContext ()

Public Methods

public boolean checkRunningInstaller ()

public abstract boolean checkUpdate ()

Not called locally: it is entirely up to the client to implement and decide who calls this method.

public boolean closeMainProject ()

Convenience method used to close the main project (if any), that is, the first project of the first engines context managed by the JEB back-end. If no project is opened, this method will return false.

Returns
  • success indicator

public final boolean closeOpenedProject ()

public abstract void displayDemoInformation (String demoInfo)

Called from start().

public abstract boolean displayEula (String eula)

Called from start().

public final void dumpUpdateToDisk (byte[] data, String password)

Throws
IOException

public static String formatMemoryUsage ()

public static String formatProcessInfo (boolean inclPid, boolean inclMeminfo, boolean inclTimes, boolean inclCmdline)

Format various process information bits. Each bit is formatted on a single line.

public static final String generateLicenseInformation ()

public String[] getArguments ()

Get the input arguments provided to this client context. The returned array depends on how the context was instantiated and called.

Returns
  • an array (possibly empty) or null if arguments are irrelevant in the current context

public Configuration getConfiguration ()

public String getControllerInterface ()

public String getControllerMessage ()

public int getControllerPort ()

public int getControllerProtocol ()

public final ICoreContext getCoreContext ()

Get the JEB core instance. Should never be null unless an error happened in start() or the context is one of a floating controller.

public final IEnginesContext getEnginesContext ()

Get the JEB engines instance. Should never be null unless an error happened in start() or the context is one of a floating controller.

Returns
  • the primary engines context, possibly null if none was initialized

public String getInputpath ()

public final int getLastPublicAnnouncementId ()

public final Version getLatestAvailableUpdate ()

public int getLogLevel ()

public IRuntimeProject getMainProject ()

Returns
  • the main project or null

public long getMaxMemory ()

Get the theoretical maximum amount of memory that JEB can allocate and use.

Returns
  • total theoretical memory that JEB could use, in bytes

public Net getNetworkUtility ()

public final IRuntimeProject getOpenedProject ()

Retrieve the current project, if any. Same as getMainProject().

Returns
  • may be null

public final String getPreferredLanguage ()

public long getProcessId ()

Retrieve the process id of the Java VM executing JEB.

Returns
  • JEB's PID

public IPropertyDefinitionManager getPropertyDefinitionManager ()

public IPropertyManager getPropertyManager ()

public final String getProxyString ()

public String getScriptpath ()

public final String getScriptsDirectory ()

Retrieve the JEB scripts directory path.

Returns
  • never null, however, the path returned may not reference an existing directory

public final File getScriptsDirfile ()

Retrieve and if necessary create the JEB scripts directory.

Returns
  • the script directory

public ITelemetryDatabase getTelemetry ()

public Map<Object, Object> getTransientStore ()

Retrieve a reference to the transient store provided by this context. Clients may use this map to store context-level global objects. The store and its objects are not persisted with a project JDB2 database.

Interface specifications for implementations:
- Null keys are forbidden, null values are allowed
- Insertion, retrieval and deletion are thread-safe
- Iterating is not thread-safe
- The insertion order is not guaranteed during iteration

Returns
  • a non-null read-write map

public final int getUpdateChannel ()

public long getUsedMemory ()

Get the amount of memory currently used by JEB.

Returns
  • used memory in bytes

public final long getUuid ()

public final boolean hasOpenedProject ()

public void initialize (String[] argv)

public boolean isDevelopmentMode ()

public boolean isHeadless ()

public final void logMemoryUsage ()

public abstract void notifyFloatingClient (ControllerNotification notification)

May be called from anywhere, any thread.

public abstract void notifySupportExpired ()

Called from start().

public abstract void onUpdatedSoftware (String changelist, Version oldVersion)

Notify a concrete client that a new version of JEB is being run for the first time.

Called from start().

Parameters
changelist an optional change log
oldVersion the last version of JEB that was run (note: the current version is always available as a static public field)

public IUnit open (String path)

Convenience method used to create a JEB project (or retrieve the current project if one is opened), load a file artifact into the project, process it, and return the resulting top-level unit.

If the input file is a JDB2 saved project, that project is opened and returned. The method will throw IllegalStateException if a project is already opened.

Parameters
path input file to be analyzed, or an existing project saved as a JDB2 database (*.jdb2)
Returns
  • the top-level unit yielded from the analysis of the provided artifact; if the input path was a JDB2 project, the top-level unit of the first project's artifact is returned
Throws
IOException

public final int ping (int downloadOrder, int clientChannel, SoftwareBuildInfo sbi, IProgressCallback progressCallback, boolean verbose)

Ping the JEB update server, and optionally download a JEB update on a compatible update channel.

Parameters
downloadOrder orders:
  • 0= no download (pure ping)
  • 1=soft download (download only if not a major version bump; else a code 3 may be returned if an update is available; the client must call this method once more with downloadOrder=2 to download the files)
  • 2= always download
clientChannel current client channel, ie maximum allowed channel a build must confirm to; see Version for a list of available channels
sbi optional information about the update
progressCallback optional callback, used if the update package is to be downloaded
verbose if true, messages are logged; if false, only important messages are logged
Returns
  • return values are:
    • -2: error, corrupt update
    • -1: error, unknown
    • 0: up to date
    • 1: update available, but caller does not want to download
    • 2: update available and downloaded
    • 2: update available, not downloaded, (currently: the only reason is, it is a major update, eg v3 to v4) - use downloadOrder=2 to force the download and install

public final PublicAnnouncement retrieveLatestPublicAnnouncement ()

public abstract String retrieveLicenseKey (String licdata)

Called from start().

public void setControllerInterface (String iface)

public void setControllerPort (int port)

public void setControllerProtocol (int protocol)

public void setDevelopmentMode (boolean enabled)

public final void setLastPublicAnnouncementId (int id)

public final void setLatestAvailableUpdate (Version version)

public void setLogLevel (int level)

public final void setPreferredLanguage (String language)

public final void setProxyString (String strProxyinfo)

public final void setScriptsDirectory (String folder)

public final void setUpdateChannel (int channel)

public abstract boolean setupController ()

Called from start().

public final boolean shouldCheckPublicAnnouncements ()

public final boolean shouldCheckUpdates ()

public void start ()

Install update, if any. Allow the display of client-specific material such as: EULA, changelog, etc. If loating, initialize the floating client. Performs a license check for release builds. If not a controller, initialize a JEB #corectx core and #engctx engines.

Throws
JebException

public void stop ()

Protected Methods

protected void assignCommandlineArguments (String[] argv)

Initialize the |configpath| and |inputpath|attributes.

protected final void initializeEngines ()

Initialize the core context and an engines context.

Throws
JebException