Class AbstractClientContext
- All Implemented Interfaces:
IClientContext,IEventSource
- Direct Known Subclasses:
HeadlessClientContext
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()
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]Command-line arguments remaining after client option parsing.protected booleanTrue when startup checks completed successfully.static final StringPrefix used for lock files indicating that at least one JEB client is running.protected CoreOptionsA reference to core options that will be used when the JEB core context is instantiated instart().static final StringDefault client configuration filename.static final StringDefault engines configuration filename.static final StringDefault plugins directory name.static final StringDefault scripts directory name.static final StringDefault telemetry database filename.protected StringOptional input path parsed from command-line arguments.static final StringFilename used by the installer to prevent client startup during updates.protected StringOptional script path parsed from command-line arguments.protected StringLast user or license generation error string reported during startup.Fields inherited from class com.pnfsoftware.jeb.client.AbstractContext
app_company, app_dates, app_domain, app_email_licensing, app_email_support, app_email_updates, app_licensing_backup, app_name, app_uri, app_url_apidoc, app_url_changelog, app_url_chat, app_url_check_update, app_url_check_update_backup, app_url_devportal, app_url_donate, app_url_faq, app_url_faqmem, app_url_fileuploader, app_url_forum, app_url_genkey, app_url_genkey_backup, app_url_genlk, app_url_github, app_url_github_samples, app_url_github_samples_scripts, app_url_manual, app_url_motd, app_url_purchase, app_url_uploaderrorlog, app_ver, app_website, demo, integrity_failed, just_updatedFields inherited from class com.pnfsoftware.jeb.util.events.EventSource
onEventCallCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassignCommandlineArguments(String[] argv) booleanDetermine whether the installer appears to be running.abstract booleanNot called locally: it is entirely up to the client to implement and decide who calls this method.booleanSame ascloseOpenedProject().final booleanClose the currently opened project, if any.abstract voiddisplayDemoInformation(String demoInfo) Display information about demo restrictions.abstract booleandisplayEula(String eula) Display the end-user license agreement.protected booleandumpProgramError(String str) Replace the program error log content.final voiddumpUpdateToDisk(byte[] data, String password) Persist a downloaded update archive and its optional password to disk.static StringFormat the current process memory usage.static StringformatProcessInfo(boolean inclPid, boolean inclMeminfo, boolean inclTimes, boolean inclCmdline) Format various process information bits.static final StringFormat the current license information for display.String[]Get the input arguments provided to this client context.org.apache.commons.configuration2.ConfigurationGet the raw client configuration object.Get the floating-controller interface or hostname.Get the optional floating-controller message configured for this client.intGet the floating-controller port.intGet the floating-controller protocol identifier.final ICoreContextGet the JEB core instance.final IEnginesContextGet the JEB engines instance.Get the current input path parsed from the command line, if any.final intGet the identifier of the last seen public announcement.final VersionGet the latest available update recorded in the client settings.intGet the configured global log level.Same asgetOpenedProject().longGet the theoretical maximum amount of memory that JEB can allocate and use.Get the shared network helper used by this client context.final IRuntimeProjectRetrieve the current project, if any.final StringGet the preferred UI language code.longRetrieve the process id of the Java VM executing JEB.Get the property definition manager.Get the property manager.final StringGet the configured network proxy string.Get the script path parsed from the command line, if any.final StringRetrieve the JEB scripts directory path.final FileRetrieve and if necessary create the JEB scripts directory.com.pnfsoftware.jeb.client.telemetry.ITelemetryDatabaseGet the telemetry database handle.Retrieve a reference to the transient store provided by this context.final intGet the configured update channel.longGet the amount of memory currently used by JEB.final longgetUuid()Get the generated UUID associated with this client installation.final booleanDetermine whether a project is currently open.voidinitialize(String[] argv) Initialize the client context from command-line arguments and configuration files.protected final voidInitialize the core context and an engines context.booleanDetermine whether development mode is enabled.booleanDetermine whether this client context is headless.final voidLog the current process memory usage.abstract voidnotifyFloatingClient(ControllerNotification notification) Notify the client of a floating-controller event.abstract voidNotify the client that support or subscription benefits expired.abstract voidonUpdatedSoftware(String changelist, Version oldVersion) Notify a concrete client that a new version of JEB is being run for the first time.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 intping(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 com.pnfsoftware.jeb.client.PublicAnnouncementRetrieve the latest public announcement from the JEB server.abstract StringretrieveLicenseKey(String licdata) Retrieve a license key from the user.voidsetControllerInterface(String iface) Set the floating-controller interface or hostname.voidsetControllerPort(int port) Set the floating-controller port.voidsetControllerProtocol(int protocol) Set the floating-controller protocol identifier.voidsetDevelopmentMode(boolean enabled) Enable or disable development mode.final voidsetLastPublicAnnouncementId(int id) Set the identifier of the last seen public announcement.final voidsetLatestAvailableUpdate(Version version) Record the latest available update version in the client settings.voidsetLogLevel(int level) Set the configured global log level.final voidsetPreferredLanguage(String langcode) Set the preferred UI language code.final voidsetProxyString(String strProxyinfo) Set the network proxy string.final voidsetScriptsDirectory(String folder) Set the JEB scripts directory path.abstract booleanAsk the client to configure floating-controller settings if needed.final voidsetUpdateChannel(int channel) Set the accepted update channel.final booleanDetermine whether public announcement checks should be performed.final booleanDetermine whether automatic update checks should be performed.voidstart()Install update, if any.voidstop()Stop the client context and release telemetry and core resources.Methods inherited from class com.pnfsoftware.jeb.client.AbstractContext
getAppDirectory, getBaseDirectory, getChannelName, getCurrentDirectory, getJebClassesLocation, getProgramDirectory, getSoftwareVersion, getStartTimestamp, handleUncaughtException, initNetworkUtility, isPreRelease, terminateMethods inherited from class com.pnfsoftware.jeb.util.events.EventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, notifyListeners, notifyListeners, relay, removeListener, setParentSourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.pnfsoftware.jeb.client.api.IClientContext
getBaseDirectory, getProgramDirectory, getSoftwareVersion
-
Field Details
-
defaultClientConfigPath
Default client configuration filename.- See Also:
-
defaultEnginesConfigPath
Default engines configuration filename.- See Also:
-
defaultTelemetryDatabasePath
Default telemetry database filename.- See Also:
-
defaultScriptsFolderName
Default scripts directory name.- See Also:
-
defaultPluginsFolderName
Default plugins directory name.- See Also:
-
coreOptions
-
args
Command-line arguments remaining after client option parsing. -
scriptpath
Optional script path parsed from command-line arguments. -
inputpath
Optional input path parsed from command-line arguments. -
basicChecksPassed
protected boolean basicChecksPassedTrue when startup checks completed successfully. -
ugerrstr
Last user or license generation error string reported during startup. -
CLIENT_RUNNING_FILENAME_PREFIX
Prefix used for lock files indicating that at least one JEB client is running.- See Also:
-
INSTALLER_LOCK_FILENAME
Filename used by the installer to prevent client startup during updates.- See Also:
-
-
Constructor Details
-
AbstractClientContext
protected AbstractClientContext()Create a base client context.
-
-
Method Details
-
dumpProgramError
Replace the program error log content.- Parameters:
str- content to write- Returns:
- true if the error log was written successfully
-
checkRunningInstaller
public boolean checkRunningInstaller()Determine whether the installer appears to be running.- Returns:
- true if the installer lock is present and recent
-
initialize
Initialize the client context from command-line arguments and configuration files.- Parameters:
argv- command-line arguments
-
start
Install update, if any. Allow the display of client-specific material such as: EULA, changelog, etc. If floating, initialize the floating client. Performs a license check for release builds. If not a controller, initialize a JEBcoreandengines.- Throws:
JebException- on initialization or licensing error
-
stop
public void stop()Stop the client context and release telemetry and core resources. -
assignCommandlineArguments
- Parameters:
argv- command-line arguments
-
getArguments
Description copied from interface:IClientContextGet the input arguments provided to this client context. The returned array depends on how the context was instantiated and called.- Specified by:
getArgumentsin interfaceIClientContext- Returns:
- an array (possibly empty) or null if arguments are irrelevant in the current context
-
getInputpath
Get the current input path parsed from the command line, if any.- Returns:
- the input path, or null if none was provided
-
getScriptpath
Get the script path parsed from the command line, if any.- Returns:
- the script path, or null if none was provided
-
getNetworkUtility
Get the shared network helper used by this client context.- Returns:
- network helper
-
getPropertyDefinitionManager
Get the property definition manager.- Returns:
- property definition manager
-
getPropertyManager
Get the property manager.- Returns:
- property manager
-
getConfiguration
public org.apache.commons.configuration2.Configuration getConfiguration()Get the raw client configuration object.- Returns:
- configuration object
-
getTelemetry
public com.pnfsoftware.jeb.client.telemetry.ITelemetryDatabase getTelemetry()Get the telemetry database handle.- Returns:
- telemetry database handle
-
isDevelopmentMode
public boolean isDevelopmentMode()Determine whether development mode is enabled.- Returns:
- true if development mode is enabled
-
setDevelopmentMode
public void setDevelopmentMode(boolean enabled) Enable or disable development mode.- Parameters:
enabled- true to enable development mode
-
getLogLevel
public int getLogLevel()Get the configured global log level.- Returns:
- log level
-
setLogLevel
public void setLogLevel(int level) Set the configured global log level.- Parameters:
level- log level
-
getUuid
public final long getUuid()Get the generated UUID associated with this client installation.- Returns:
- UUID value, or 0 if unavailable
-
getPreferredLanguage
Get the preferred UI language code.- Returns:
- preferred language code
-
setPreferredLanguage
Set the preferred UI language code.- Parameters:
langcode- language code
-
shouldCheckUpdates
public final boolean shouldCheckUpdates()Determine whether automatic update checks should be performed.- Returns:
- true if update checks are enabled
-
getUpdateChannel
public final int getUpdateChannel()Get the configured update channel.- Returns:
- update channel
-
setUpdateChannel
public final void setUpdateChannel(int channel) Set the accepted update channel.- Parameters:
channel- update channel
-
getLatestAvailableUpdate
Get the latest available update recorded in the client settings.- Returns:
- latest available version, or null if none is recorded
-
setLatestAvailableUpdate
Record the latest available update version in the client settings.- Parameters:
version- latest available version
-
shouldCheckPublicAnnouncements
public final boolean shouldCheckPublicAnnouncements()Determine whether public announcement checks should be performed.- Returns:
- true if announcement checks are enabled
-
getProxyString
Get the configured network proxy string.- Returns:
- proxy settings string
-
setProxyString
Set the network proxy string.- Parameters:
strProxyinfo- proxy settings string
-
getLastPublicAnnouncementId
public final int getLastPublicAnnouncementId()Get the identifier of the last seen public announcement.- Returns:
- last announcement id
-
setLastPublicAnnouncementId
public final void setLastPublicAnnouncementId(int id) Set the identifier of the last seen public announcement.- Parameters:
id- last announcement id
-
isHeadless
public boolean isHeadless()Determine whether this client context is headless.- Returns:
- true if this context is headless
-
checkUpdate
public abstract boolean checkUpdate()Not called locally: it is entirely up to the client to implement and decide who calls this method.- Returns:
- true if an update was downloaded and should be applied
-
displayEula
Display the end-user license agreement.Called from
start().- Parameters:
eula- EULA text- Returns:
- true if the user accepted the EULA
-
displayDemoInformation
Display information about demo restrictions.Called from
start().- Parameters:
demoInfo- demo information text
-
onUpdatedSoftware
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 logoldVersion- the last version of JEB that was run (note: the current version is always available as astatic public field)
-
retrieveLicenseKey
Retrieve a license key from the user.Called from
start().- Parameters:
licdata- license data blob- Returns:
- the license key entered by the user
-
notifySupportExpired
public abstract void notifySupportExpired()Notify the client that support or subscription benefits expired.Called from
start(). -
setupController
public abstract boolean setupController()Ask the client to configure floating-controller settings if needed.Called from
start().- Returns:
- true if the controller was configured successfully
-
notifyFloatingClient
Notify the client of a floating-controller event.May be called from any thread.
- Parameters:
notification- controller notification
-
generateLicenseInformation
Format the current license information for display.- Returns:
- formatted license information
-
ping
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; seeVersionfor a list of available channelssbi- optional information about the updateprogressCallback- optional callback, used if the update package is to be downloadedverbose- 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
- 3: 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
-
dumpUpdateToDisk
Persist a downloaded update archive and its optional password to disk.- Parameters:
data- update archive datapassword- optional archive password- Throws:
IOException- on write error
-
retrieveLatestPublicAnnouncement
public final com.pnfsoftware.jeb.client.PublicAnnouncement retrieveLatestPublicAnnouncement()Retrieve the latest public announcement from the JEB server.- Returns:
- the latest announcement object, or null on failure
-
getScriptsDirectory
Retrieve the JEB scripts directory path.- Returns:
- never null, however, the path returned may not reference an existing directory
-
getScriptsDirfile
Retrieve and if necessary create the JEB scripts directory.- Returns:
- the script directory
-
setScriptsDirectory
Set the JEB scripts directory path.- Parameters:
folder- scripts directory path
-
getUsedMemory
public long getUsedMemory()Description copied from interface:IClientContextGet the amount of memory currently used by JEB.- Specified by:
getUsedMemoryin interfaceIClientContext- Returns:
- used memory in bytes
-
getMaxMemory
public long getMaxMemory()Description copied from interface:IClientContextGet the theoretical maximum amount of memory that JEB can allocate and use.- Specified by:
getMaxMemoryin interfaceIClientContext- Returns:
- total theoretical memory that JEB could use, in bytes
-
getProcessId
public long getProcessId()Description copied from interface:IClientContextRetrieve the process id of the Java VM executing JEB.- Specified by:
getProcessIdin interfaceIClientContext- Returns:
- JEB's PID
-
logMemoryUsage
public final void logMemoryUsage()Log the current process memory usage. -
formatMemoryUsage
Format the current process memory usage.- Returns:
- formatted memory usage string
-
formatProcessInfo
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.- Parameters:
inclPid- true to include process identifier informationinclMeminfo- true to include memory usage informationinclTimes- true to include start time and CPU time informationinclCmdline- true to include the full command line- Returns:
- formatted process information
-
initializeEngines
Initialize the core context and an engines context.- Throws:
JebException- on core or engines initialization error
-
getCoreContext
Get the JEB core instance. Should never be null unless an error happened instart()or the context is one of a floating controller.- Returns:
- the core context, or null if unavailable
-
getEnginesContext
Get the JEB engines instance. Should never be null unless an error happened instart()or the context is one of a floating controller.- Specified by:
getEnginesContextin interfaceIClientContext- Returns:
- the engines context, or null if unavailable
-
hasOpenedProject
public final boolean hasOpenedProject()Determine whether a project is currently open.- Returns:
- true if a project is open
-
getOpenedProject
Retrieve the current project, if any. Same asgetMainProject().- Returns:
- may be null
-
closeOpenedProject
public final boolean closeOpenedProject()Close the currently opened project, if any.- Returns:
- true if a project was open and closed
-
getMainProject
Same asgetOpenedProject().- Specified by:
getMainProjectin interfaceIClientContext- Returns:
- the main project, or null if none is open
-
closeMainProject
public boolean closeMainProject()Same ascloseOpenedProject().- Specified by:
closeMainProjectin interfaceIClientContext- Returns:
- true if a project was open and closed
-
open
Description copied from interface:IClientContextConvenience 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
IllegalStateExceptionif a project is already opened.- Specified by:
openin interfaceIClientContext- 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- on IO error
-
getTransientStore
Description copied from interface:IClientContextRetrieve 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- Specified by:
getTransientStorein interfaceIClientContext- Returns:
- a non-null read-write map
-
getControllerInterface
Get the floating-controller interface or hostname.- Returns:
- controller interface or hostname
-
setControllerInterface
Set the floating-controller interface or hostname.- Parameters:
iface- controller interface or hostname
-
getControllerPort
public int getControllerPort()Get the floating-controller port.- Returns:
- controller port
-
setControllerPort
public void setControllerPort(int port) Set the floating-controller port.- Parameters:
port- controller port
-
getControllerProtocol
public int getControllerProtocol()Get the floating-controller protocol identifier.- Returns:
- controller protocol identifier
-
setControllerProtocol
public void setControllerProtocol(int protocol) Set the floating-controller protocol identifier.- Parameters:
protocol- controller protocol identifier
-
getControllerMessage
Get the optional floating-controller message configured for this client.- Returns:
- controller message
-