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 boolean
static final String
protected CoreOptions
A reference to core options that will be used when the JEB core context is instantiated instart()
.static final String
static final String
static final String
static final String
static final String
protected String
static final String
protected String
protected String
Fields inherited from class com.pnfsoftware.jeb.client.AbstractContext
app_company, app_dates, app_description, app_domain, app_email_licensing, app_email_support, app_email_updates, app_licensing_backup, app_name, app_uri, app_url_apidoc, app_url_changelist, 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_updated
Fields inherited from class com.pnfsoftware.jeb.util.events.EventSource
onEventCallCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
assignCommandlineArguments
(String[] argv) Initialize the |configpath| and |inputpath|attributes.boolean
abstract boolean
Not called locally: it is entirely up to the client to implement and decide who calls this method.boolean
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
abstract void
displayDemoInformation
(String demoInfo) Called fromstart()
.abstract boolean
displayEula
(String eula) Called fromstart()
.final void
dumpUpdateToDisk
(byte[] data, String password) static String
static String
formatProcessInfo
(boolean inclPid, boolean inclMeminfo, boolean inclTimes, boolean inclCmdline) Format various process information bits.static final String
String[]
Get the input arguments provided to this client context.org.apache.commons.configuration2.Configuration
int
int
final ICoreContext
Get the JEB core instance.final IEnginesContext
Get the JEB engines instance.final int
final Version
int
Same asgetOpenedProject()
.long
Get the theoretical maximum amount of memory that JEB can allocate and use.final IRuntimeProject
Retrieve the current project, if any.final String
long
Retrieve the process id of the Java VM executing JEB.final String
final String
Retrieve the JEB scripts directory path.final File
Retrieve and if necessary create the JEB scripts directory.Retrieve a reference to the transient store provided by this context.final int
long
Get the amount of memory currently used by JEB.final long
getUuid()
final boolean
void
initialize
(String[] argv) protected final void
Initialize the core context and an engines context.boolean
boolean
final void
abstract void
notifyFloatingClient
(ControllerNotification notification) May be called from anywhere, any thread.abstract void
Called fromstart()
.abstract void
onUpdatedSoftware
(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 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
abstract String
retrieveLicenseKey
(String licdata) Called fromstart()
.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) abstract boolean
Called fromstart()
.final void
setUpdateChannel
(int channel) final boolean
final boolean
void
start()
Install update, if any.void
stop()
Methods inherited from class com.pnfsoftware.jeb.client.AbstractContext
getAppDirectory, getBaseDirectory, getChannelName, getCurrentDirectory, getJebClassesLocation, getProgramDirectory, getSoftwareVersion, getStartTimestamp, initNetworkUtility, isPreRelease, terminate
Methods inherited from class com.pnfsoftware.jeb.util.events.EventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, notifyListeners, notifyListeners, relay, removeListener, setParentSource
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
-
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 JEBcore
andengines
.- Throws:
JebException
-
stop
public void stop() -
assignCommandlineArguments
Initialize the |configpath| and |inputpath|attributes.- Parameters:
argv
-
-
getArguments
Description copied from interface:IClientContext
Get the input arguments provided to this client context. The returned array depends on how the context was instantiated and called.- Specified by:
getArguments
in 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; seeVersion
for 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:IClientContext
Get the amount of memory currently used by JEB.- Specified by:
getUsedMemory
in interfaceIClientContext
- Returns:
- used memory in bytes
-
getMaxMemory
public long getMaxMemory()Description copied from interface:IClientContext
Get the theoretical maximum amount of memory that JEB can allocate and use.- Specified by:
getMaxMemory
in interfaceIClientContext
- Returns:
- total theoretical memory that JEB could use, in bytes
-
getProcessId
public long getProcessId()Description copied from interface:IClientContext
Retrieve the process id of the Java VM executing JEB.- Specified by:
getProcessId
in 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:
getEnginesContext
in 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:
getMainProject
in interfaceIClientContext
- Returns:
- the main project or null
-
closeMainProject
public boolean closeMainProject()Description copied from interface:IClientContext
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.- Specified by:
closeMainProject
in interfaceIClientContext
- Returns:
- success indicator
-
open
Description copied from interface:IClientContext
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.- Specified by:
open
in 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:IClientContext
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- Specified by:
getTransientStore
in 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
-