Package com.pnfsoftware.jeb.client
Class AbstractClientContext
java.lang.Object
com.pnfsoftware.jeb.util.events.EventSource
com.pnfsoftware.jeb.client.AbstractContext
com.pnfsoftware.jeb.client.AbstractClientContext
- All Implemented Interfaces:
IClientContext,IEventSource
- Direct Known Subclasses:
HeadlessClientContext
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()
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]protected booleanstatic final Stringprotected CoreOptionsA reference to core options that will be used when the JEB core context is instantiated instart().static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringstatic final Stringprotected Stringprotected StringFields 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) booleanabstract booleanNot called locally: it is entirely up to the client to implement and decide who calls this method.booleanConvenience 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 booleanabstract voiddisplayDemoInformation(String demoInfo) Called fromstart().abstract booleandisplayEula(String eula) Called fromstart().protected booleandumpProgramError(String str) final voiddumpUpdateToDisk(byte[] data, String password) static Stringstatic StringformatProcessInfo(boolean inclPid, boolean inclMeminfo, boolean inclTimes, boolean inclCmdline) Format various process information bits.static final StringString[]Get the input arguments provided to this client context.org.apache.commons.configuration2.Configurationintintfinal ICoreContextGet the JEB core instance.final IEnginesContextGet the JEB engines instance.final intfinal VersionintSame asgetOpenedProject().longGet the theoretical maximum amount of memory that JEB can allocate and use.final IRuntimeProjectRetrieve the current project, if any.final StringlongRetrieve the process id of the Java VM executing JEB.final Stringfinal StringRetrieve the JEB scripts directory path.final FileRetrieve and if necessary create the JEB scripts directory.Retrieve a reference to the transient store provided by this context.final intlongGet the amount of memory currently used by JEB.final longgetUuid()final booleanvoidinitialize(String[] argv) protected final voidInitialize the core context and an engines context.booleanbooleanfinal voidabstract voidnotifyFloatingClient(ControllerNotification notification) May be called from anywhere, any thread.abstract voidCalled fromstart().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 PublicAnnouncementabstract StringretrieveLicenseKey(String licdata) Called fromstart().voidsetControllerInterface(String iface) voidsetControllerPort(int port) voidsetControllerProtocol(int protocol) voidsetDevelopmentMode(boolean enabled) final voidsetLastPublicAnnouncementId(int id) final voidsetLatestAvailableUpdate(Version version) voidsetLogLevel(int level) final voidsetPreferredLanguage(String langcode) final voidsetProxyString(String strProxyinfo) final voidsetScriptsDirectory(String folder) abstract booleanCalled fromstart().final voidsetUpdateChannel(int channel) final booleanfinal booleanvoidstart()Install update, if any.voidstop()Methods inherited from class com.pnfsoftware.jeb.client.AbstractContext
getAppDirectory, getBaseDirectory, getChannelName, getCurrentDirectory, getJebClassesLocation, getProgramDirectory, getSoftwareVersion, getStartTimestamp, 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
- See Also:
-
defaultEnginesConfigPath
- See Also:
-
defaultTelemetryDatabasePath
- See Also:
-
defaultScriptsFolderName
- See Also:
-
defaultPluginsFolderName
- See Also:
-
coreOptions
-
args
-
scriptpath
-
inputpath
-
basicChecksPassed
protected boolean basicChecksPassed -
ugerrstr
-
CLIENT_RUNNING_FILENAME_PREFIX
- See Also:
-
INSTALLER_LOCK_FILENAME
- See Also:
-
-
Constructor Details
-
AbstractClientContext
protected AbstractClientContext()
-
-
Method Details
-
dumpProgramError
-
checkRunningInstaller
public boolean checkRunningInstaller() -
initialize
-
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 JEBcoreandengines.- Throws:
JebException
-
stop
public void stop() -
assignCommandlineArguments
- Parameters:
argv-
-
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
-
getScriptpath
-
getNetworkUtility
-
getPropertyDefinitionManager
-
getPropertyManager
-
getConfiguration
public org.apache.commons.configuration2.Configuration getConfiguration() -
getTelemetry
-
isDevelopmentMode
public boolean isDevelopmentMode() -
setDevelopmentMode
public void setDevelopmentMode(boolean enabled) -
getLogLevel
public int getLogLevel() -
setLogLevel
public void setLogLevel(int level) -
getUuid
public final long getUuid() -
getPreferredLanguage
-
setPreferredLanguage
-
shouldCheckUpdates
public final boolean shouldCheckUpdates() -
getUpdateChannel
public final int getUpdateChannel() -
setUpdateChannel
public final void setUpdateChannel(int channel) -
getLatestAvailableUpdate
-
setLatestAvailableUpdate
-
shouldCheckPublicAnnouncements
public final boolean shouldCheckPublicAnnouncements() -
getProxyString
-
setProxyString
-
getLastPublicAnnouncementId
public final int getLastPublicAnnouncementId() -
setLastPublicAnnouncementId
public final void setLastPublicAnnouncementId(int id) -
isHeadless
public boolean isHeadless() -
checkUpdate
public abstract boolean checkUpdate()Not called locally: it is entirely up to the client to implement and decide who calls this method. -
displayEula
Called fromstart(). -
displayDemoInformation
Called fromstart(). -
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
Called fromstart(). -
notifySupportExpired
public abstract void notifySupportExpired()Called fromstart(). -
setupController
public abstract boolean setupController()Called fromstart(). -
notifyFloatingClient
May be called from anywhere, any thread. -
generateLicenseInformation
-
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
- 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
-
dumpUpdateToDisk
- Throws:
IOException
-
retrieveLatestPublicAnnouncement
-
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
-
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() -
formatMemoryUsage
-
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-inclMeminfo-inclTimes-inclCmdline-- Returns:
-
initializeEngines
Initialize the core context and an engines context.- Throws:
JebException
-
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:
-
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 primary engines context, possibly null if none was initialized
-
hasOpenedProject
public final boolean hasOpenedProject() -
getOpenedProject
Retrieve the current project, if any. Same asgetMainProject().- Returns:
- may be null
-
closeOpenedProject
public final boolean closeOpenedProject() -
getMainProject
Same asgetOpenedProject().- Specified by:
getMainProjectin interfaceIClientContext- Returns:
- the main project or null
-
closeMainProject
public boolean closeMainProject()Description copied from interface:IClientContextConvenience 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.- Specified by:
closeMainProjectin interfaceIClientContext- Returns:
- success indicator
-
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
-
setControllerInterface
-
getControllerPort
public int getControllerPort() -
setControllerPort
public void setControllerPort(int port) -
getControllerProtocol
public int getControllerProtocol() -
setControllerProtocol
public void setControllerProtocol(int protocol) -
getControllerMessage
-