Package com.openfin.desktop
Class OpenFinRuntime
java.lang.Object
com.openfin.desktop.OpenFinRuntime
- Direct Known Subclasses:
System
public class OpenFinRuntime
extends java.lang.Object
An object representing the core of the OpenFin Runtime. Allows the developer to
perform system-level actions, such as accessing logs, viewing processes, clearing
the cache and exiting the Runtime.
Created by wche on 1/26/16.
-
Field Summary
Fields Modifier and Type Field Description protected org.json.JSONObjectconfigPayloadprotected DesktopConnectionconnectionprotected org.json.JSONObjecteventListenerPayload -
Constructor Summary
Constructors Constructor Description OpenFinRuntime(DesktopConnection connection)Constructor -
Method Summary
Modifier and Type Method Description voidaddEventListener(java.lang.String type, EventListener listener, AckListener callback)Registers an event listener on the specified eventprotected voidaddEventListener(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback)Registers an event listener on the specified eventvoidclearCache(boolean cache, boolean cookies, boolean localStorage, boolean appcache, boolean userData)Clears cached data containing window state/positions, application resource files (images, HTML, JavaScript files) cookies, and items stored in the Local Storage.voidclearCache(boolean cache, boolean cookies, boolean localStorage, boolean appcache, boolean userData, AckListener listener)Clears cached data containing window state/positions, application resource files (images, HTML, JavaScript files) cookies, and items stored in the Local Storage.voiddeleteCacheOnRestart()Clears all cached data when Runtime is restartedvoiddeleteCacheOnRestart(AckListener listener)Clears all cached data when App Desktop is restartedvoidexit()Exit Runtimestatic java.lang.StringgetAdapterBuildTime()Get build time of java adapterstatic java.lang.StringgetAdapterVersion()Get version info of java adaptervoidgetAllApplications(AckListener listener)Retrieves an array of data (uuid, running/active state) for all application windowsvoidgetAllWindows(AckListener listener)The object passed to callback takes the form:voidgetCommandLineArguments(AckListener listener)Retrieves the command line argument string that started App DesktopvoidgetConfig(java.lang.String section, AckListener callback)Retrieves the Runtime's configurationvoidgetEntityInfo(java.lang.String uuid, java.lang.String name, AckListener listener)Returns a frame info object relating to the entity specified by the uuid and name passed in.voidgetEnvironmentVariable(java.lang.String name, AckListener callback)Retrieve name of a environment variablevoidgetEnvironmentVariables(java.lang.String[] names, AckListener callback)Retrieve name of environment variablesvoidgetHostSpecs(AckListener listener)Get system informationstatic org.json.JSONObjectgetInstallInfo()Retrieve info about RVM and Runtime already installed on desktop.voidgetLog(java.lang.String logName, AckListener listener)Retrieves the contents of the log with the specified filenamevoidgetLogList(AckListener listener)Retrieves an array of data objects for all available logs Each object in the returned array takes the form: { name: (string) the filename of the log, size: (integer) the size of the log in bytes, date: (integer) the unix time at which the log was created }voidgetMachineId(AckListener listener)Gets Machine IDvoidgetMonitorInfo(AckListener listener)Retrieves an object that contains data about the about thejava.util.concurrent.CompletableFuture<MonitorInfo>getMonitorInfoAsync()voidgetMousePosition(AckListener listener)Returns the mouse in virtual screen coordinates (left, top)voidgetProcessList(AckListener listener)Retrieves an array of all App Desktop processes that are currently running Each element in the array is an object containing the uuid and the name of the application to which the process belongs.voidgetProxySettings(AckListener listener)Retrieves the proxy settings objectvoidgetRuntimeInfo(AckListener callback)Returns the version of the runtimevoidgetRvmInfo(AckListener callback)Returns information about the running RVMvoidgetVersion(AckListener listener)Gets AppDesktop version numbervoidlaunchExternalProcess(java.lang.String path, java.lang.String commandLine, AsyncCallback<LaunchExternalProcessResult> callback, AckListener listener)Runs an executable or batch file.voidlaunchExternalProcess(org.json.JSONObject launchConfig, AsyncCallback<LaunchExternalProcessResult> callback, AckListener listener)Runs an executable or batch file.voidlaunchManifest(java.lang.String manifestUrl, org.json.JSONObject rvmLaunchOptions, AckListener listener)Request Runtime to launch app from a manifest Shape of rvmLaunchOptions { noUi: boolean; userAppConfigArgs: JSONObject; }voidlog(java.lang.String level, java.lang.String message)Writes a message to the logvoidlog(java.lang.String level, java.lang.String message, AckListener listener)Writes a message to the logvoidopenUrlWithBrowser()Opens the passed URLvoidopenUrlWithBrowser(AckListener listener)Opens the passed URLvoidreleaseExternalProcess(java.lang.String processUuid, AckListener callback)Removes the process entry for the passed UUID obtained from a previous call to DesktopSystem.launchExternalProcess().voidremoveEventListener(java.lang.String type, EventListener listener, AckListener callback)Removes a previously registered event listener from the specified eventvoidresolveProxy(java.lang.String url, AckListener listener)Resolve proxy information for a given urlvoidsetClipboard(java.lang.String text, AckListener callback)Copies text to the clipboardvoidsetCookie(java.lang.String url, java.lang.String name, java.lang.String value, long ttl, boolean secure, boolean httpOnly, AckListener callback)Stores a cookie in the runtimevoidsetCookie(java.lang.String url, java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, long ttl, boolean secure, boolean httpOnly, AckListener callback)Stores a cookie in the runtimevoidshowDeveloperTools(java.lang.String applicationUUID, java.lang.String windowName, AckListener callback)Shows Developer toolvoidterminateExternalProcess(java.lang.String processUuid, int timeout, boolean killTree, AsyncCallback<TerminateExternalProcessResult> callback, AckListener listener)Attempts to cleanly close an external process and terminates it if the close has not occured after the elapsed timeout in milliseconds.voidupdateProxySettings(java.lang.String type, java.lang.String proxyAddress, int proxyPort, AckListener listener)Updates the proxy settings The passed type can be either "system" or "named".
-
Field Details
-
connection
-
eventListenerPayload
protected org.json.JSONObject eventListenerPayload -
configPayload
protected org.json.JSONObject configPayload
-
-
Constructor Details
-
OpenFinRuntime
Constructor- Parameters:
connection- Connection object to the AppDesktop- See Also:
DesktopConnection
-
-
Method Details
-
getMachineId
Gets Machine ID- Parameters:
listener- AckListener for machine ID- See Also:
AckListener
-
getEntityInfo
Returns a frame info object relating to the entity specified by the uuid and name passed in. The possible types are 'window', 'iframe', 'external connection' or 'unknown'.- Parameters:
uuid- entity uuidname- entity namelistener- AckListener for entity info- See Also:
AckListener
-
getVersion
Gets AppDesktop version number- Parameters:
listener- AckListener for version number- See Also:
AckListener
-
getCommandLineArguments
Retrieves the command line argument string that started App Desktop- Parameters:
listener- AckListener for command line argument- See Also:
AckListener
-
getProcessList
Retrieves an array of all App Desktop processes that are currently running Each element in the array is an object containing the uuid and the name of the application to which the process belongs.- Parameters:
listener- AckListener for process list- See Also:
AckListener
-
getLog
Retrieves the contents of the log with the specified filename- Parameters:
logName- The filename of the loglistener- AckListener for log contents- See Also:
AckListener
-
getLogList
Retrieves an array of data objects for all available logs Each object in the returned array takes the form: { name: (string) the filename of the log, size: (integer) the size of the log in bytes, date: (integer) the unix time at which the log was created }- Parameters:
listener- AckListener for log list- See Also:
AckListener
-
log
Writes a message to the log- Parameters:
level- The log level for the entry. Can be either "info", "warning" or "error"message- The log message text- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException
-
log
public void log(java.lang.String level, java.lang.String message, AckListener listener) throws DesktopExceptionWrites a message to the log- Parameters:
level- The log level for the entry. Can be either "info", "warning" or "error"message- The log message textlistener- AckListener for the result- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
getProxySettings
Retrieves the proxy settings objectThe proxy object the callback receives takes the following form: { type: (string) "system" or "named", proxyAddress: (string) the address of the proxy server, proxyPort: (integer) the port of proxy server }- Parameters:
listener- AckListener for the request- See Also:
AckListener
-
resolveProxy
Resolve proxy information for a given urlProxy setting for the url the callback receives takes the following form: DIRECT or PROXY host:port which can be retrieved with listener.getData()- Parameters:
url- url to resolvelistener- AckListener for the request- See Also:
AckListener
-
updateProxySettings
public void updateProxySettings(java.lang.String type, java.lang.String proxyAddress, int proxyPort, AckListener listener) throws DesktopExceptionUpdates the proxy settings The passed type can be either "system" or "named". Use "system" to use the default system proxy settings. Otherwise use "named" to specify the address and port of the proxy server.- Parameters:
type- Type of the proxyproxyAddress- Address of the proxyproxyPort- Port of the proxylistener- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
clearCache
public void clearCache(boolean cache, boolean cookies, boolean localStorage, boolean appcache, boolean userData) throws DesktopExceptionClears cached data containing window state/positions, application resource files (images, HTML, JavaScript files) cookies, and items stored in the Local Storage.- Parameters:
cache- If true, clears chrome cachescookies- If true, deletes all cookieslocalStorage- If true, clear application cachesappcache- If true, clears local storageuserData- If true, clears user data- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException
-
clearCache
public void clearCache(boolean cache, boolean cookies, boolean localStorage, boolean appcache, boolean userData, AckListener listener) throws DesktopExceptionClears cached data containing window state/positions, application resource files (images, HTML, JavaScript files) cookies, and items stored in the Local Storage.- Parameters:
cache- If true, clears chrome cachescookies- If true, deletes all cookieslocalStorage- If true, clear application cachesappcache- If true, clears local storageuserData- If true, clears user datalistener- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
deleteCacheOnRestart
Clears all cached data when Runtime is restarted- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException
-
deleteCacheOnRestart
Clears all cached data when App Desktop is restarted- Parameters:
listener- AckListener for the request- See Also:
AckListener
-
openUrlWithBrowser
Opens the passed URL- Parameters:
listener- AckListener for the request- See Also:
AckListener
-
getMonitorInfo
Retrieves an object that contains data about the about themonitor setup of the computer that App Desktop is running on. The returned object takes the form: { nonPrimaryMonitors: [{ availableRect: { bottom: (integer) bottom-most available monitor coordinate, left: (integer) left-most available monitor coordinate, right: (integer) right-most available monitor coordinate, top: (integer) top-most available monitor coordinate }, deviceId: (string) device id of the display, displayDeviceActive: (boolean) true if the display is active, monitorRect: { bottom: (integer) bottom-most monitor coordinate, left: (integer) left-most monitor coordinate, right: (integer) right-most monitor coordinate, top: (integer) top-most monitor coordinate }, name: (string) name of the display }, ... ], primaryMonitor: { availableRect: { bottom: (integer) bottom-most available monitor coordinate, left: (integer) left-most available monitor coordinate, right: (integer) right-most available monitor coordinate, top: (integer) top-most available monitor coordinate }, deviceId: (string) device id of the display, displayDeviceActive: (boolean) true if the display is active, monitorRect: { bottom: (integer) bottom-most monitor coordinate, left: (integer) left-most monitor coordinate, right: (integer) right-most monitor coordinate, top: (integer) top-most monitor coordinate }, name: (string) name of the display }, reason: (string) always "api-query", taskbar: { edge: {string} which edge of a monitor the taskbar is on, rect: { bottom: ({integer} bottom-most coordinate of the taskbar), left: ({integer} left-most coordinate of the taskbar), right: ({integer} right-most coordinate of the taskbar), top: ({integer} top-most coordinate of the taskbar) } }, virtualScreen: { bottom: (integer) bottom-most coordinate of the virtual screen, left: (integer) left-most coordinate of the virtual screen, right: (integer) right-most coordinate of the virtual screen, top: (integer) top-most coordinate of the virtual screen } }- Parameters:
listener- AckListener for the request- See Also:
AckListener
-
getMonitorInfoAsync
-
getAllWindows
The object passed to callback takes the form:[ { uuid: (string) uuid of the application, mainWindow: { name: (string) name of the main window, top: (integer) top-most coordinate of the main window, right: (integer) right-most coordinate of the main window, bottom: (integer) bottom-most coordinate of the main window, left: (integer) left-most coordinate of the main window }, childWindows: [{ name: (string) name of the child window, top: (integer) top-most coordinate of the child window, right: (integer) right-most coordinate of the child window, bottom: (integer) bottom-most coordinate of the child window, left: (integer) left-most coordinate of the child window }, ... ] }, ... ]- Parameters:
listener- AckListener for the request- See Also:
AckListener
-
getAllApplications
Retrieves an array of data (uuid, running/active state) for all application windowsThe object passed to callback takes the form: [ { uuid: (string) uuid of the application, isRunning: (bool) true when the application is running/active }, ... ]- Parameters:
listener- AckListener for the request
-
exit
Exit Runtime- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException
-
getMousePosition
Returns the mouse in virtual screen coordinates (left, top)The returned object takes the form: { top: (integer) the top position of the mouse in virtual screen coordinates, left: (integer) the left position of the mouse in virtual screen coordinates }- Parameters:
listener- AckListener for the request- See Also:
AckListener
-
openUrlWithBrowser
Opens the passed URL- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException
-
getConfig
Retrieves the Runtime's configuration- Parameters:
section- Which section to return from the configuration. Pass null to get all sectionscallback- AckListener for the request- Throws:
DesktopException- if this method fails to get Runtime configuration- See Also:
DesktopException,AckListener
-
showDeveloperTools
public void showDeveloperTools(java.lang.String applicationUUID, java.lang.String windowName, AckListener callback) throws DesktopExceptionShows Developer tool- Parameters:
applicationUUID- The application IDwindowName- The name of dev tool windowcallback- AckListener for the request- Throws:
DesktopException- if this method fails to show devtools- See Also:
DesktopException,AckListener
-
addEventListener
protected void addEventListener(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback) throws DesktopExceptionRegisters an event listener on the specified eventSupported system event types are: desktop-icon-clicked idle-state-changed monitor-info-changed session-changed- Parameters:
subscriptionObject- A JSON object containing subscription information such as the topic and typelistener- EventListener for the eventcallback- AckListener for the request- Throws:
DesktopException- if this method fails to add event listener specified- See Also:
EventListener,AckListener
-
addEventListener
public void addEventListener(java.lang.String type, EventListener listener, AckListener callback) throws DesktopExceptionRegisters an event listener on the specified eventSupported system event types are: desktop-icon-clicked idle-state-changed monitor-info-changed session-changed- Parameters:
type- Type of the eventlistener- EventListener for the eventcallback- AckListener for the request- Throws:
DesktopException- if this method fails to add event listener specified- See Also:
EventListener,AckListener
-
removeEventListener
public void removeEventListener(java.lang.String type, EventListener listener, AckListener callback) throws DesktopExceptionRemoves a previously registered event listener from the specified event- Parameters:
type- Type of the eventlistener- EventListener for the eventcallback- AckListener for the request- Throws:
DesktopException- if this method fails to remove event listener specified- See Also:
DesktopException,EventListener,AckListener
-
launchExternalProcess
public void launchExternalProcess(java.lang.String path, java.lang.String commandLine, AsyncCallback<LaunchExternalProcessResult> callback, AckListener listener) throws DesktopExceptionRuns an executable or batch file.- Parameters:
path- The path of the file to launch via the command linecommandLine- The command line arguments to passcallback- A function that is called if the method succeedslistener- A function that is called if the method fails- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AsyncCallback,LaunchExternalProcessResult,AckListener
-
launchExternalProcess
public void launchExternalProcess(org.json.JSONObject launchConfig, AsyncCallback<LaunchExternalProcessResult> callback, AckListener listener) throws DesktopExceptionRuns an executable or batch file.- Parameters:
launchConfig- configuration for launching external processcallback- A function that is called if the method succeedslistener- A function that is called if the method fails- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AsyncCallback,LaunchExternalProcessResult,AckListener
-
terminateExternalProcess
public void terminateExternalProcess(java.lang.String processUuid, int timeout, boolean killTree, AsyncCallback<TerminateExternalProcessResult> callback, AckListener listener) throws DesktopExceptionAttempts to cleanly close an external process and terminates it if the close has not occured after the elapsed timeout in milliseconds.- Parameters:
processUuid- The UUID for a process launched by DesktopSystem.launchExternalProcess()timeout- The time in milliseconds to wait for a close to occur before terminatingkillTree- true if child processes are includedcallback- A function that is called if the method succeed with result code being passedlistener- A function that is called if the method fails- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,terminateExternalProcess,TerminateExternalProcessResult,AckListener
-
releaseExternalProcess
public void releaseExternalProcess(java.lang.String processUuid, AckListener callback) throws DesktopExceptionRemoves the process entry for the passed UUID obtained from a previous call to DesktopSystem.launchExternalProcess().- Parameters:
processUuid- The UUID for a process launched by DesktopSystem.launchExternalProcess()callback- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
setClipboard
Copies text to the clipboard- Parameters:
text- The text to copycallback- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
setCookie
public void setCookie(java.lang.String url, java.lang.String name, java.lang.String value, long ttl, boolean secure, boolean httpOnly, AckListener callback) throws DesktopExceptionStores a cookie in the runtime- Parameters:
url- The URL that the cookie is forname- The key used to lookup the valuevalue- The value paired with the key (name)ttl- The time to till the cookie expires in milliseconds. Never expires when set to 0. Defaults to 0.secure- Accessible only on a secured connection (SSL)httpOnly- Accessible only on HTTP/HTTPS.callback- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
setCookie
public void setCookie(java.lang.String url, java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, long ttl, boolean secure, boolean httpOnly, AckListener callback) throws DesktopExceptionStores a cookie in the runtime- Parameters:
url- The URL that the cookie is forname- The key used to lookup the valuevalue- The value paired with the key (name)domain- domain of the cookiepath- path of the cookiettl- The time to till the cookie expires in milliseconds. Never expires when set to 0. Defaults to 0.secure- Accessible only on a secured connection (SSL)httpOnly- Accessible only on HTTP/HTTPS.callback- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
getRvmInfo
Returns information about the running RVM- Parameters:
callback- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
getRuntimeInfo
Returns the version of the runtime- Parameters:
callback- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
getEnvironmentVariable
public void getEnvironmentVariable(java.lang.String name, AckListener callback) throws DesktopExceptionRetrieve name of a environment variable- Parameters:
name- name of the environment variablecallback- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
AckListener,DesktopException
-
getEnvironmentVariables
public void getEnvironmentVariables(java.lang.String[] names, AckListener callback) throws DesktopExceptionRetrieve name of environment variables- Parameters:
names- names of the environment variablecallback- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
getHostSpecs
Get system information- Parameters:
listener- AckListener for the request- Throws:
DesktopException- if this method fails to send the request to Runtime- See Also:
DesktopException,AckListener
-
launchManifest
public void launchManifest(java.lang.String manifestUrl, org.json.JSONObject rvmLaunchOptions, AckListener listener) throws DesktopExceptionRequest Runtime to launch app from a manifest Shape of rvmLaunchOptions { noUi: boolean; userAppConfigArgs: JSONObject; }- Parameters:
manifestUrl- URL of a manifestrvmLaunchOptions- launch options used by RVMlistener- AckListner for the request- Throws:
DesktopException- if the request fails
-
getAdapterVersion
public static java.lang.String getAdapterVersion()Get version info of java adapter- Returns:
- version information
-
getAdapterBuildTime
public static java.lang.String getAdapterBuildTime()Get build time of java adapter- Returns:
- build time
-
getInstallInfo
public static org.json.JSONObject getInstallInfo()Retrieve info about RVM and Runtime already installed on desktop. Data is returned as JSONObject Example: { "rvm": { "path": "C:\\Users\\123\\AppData\\Local\\OpenFin\\OpenFinRVM.exe", "version": "5.0.0.9" }, "runtime": [{ "path": "C:\\Users\\123\\AppData\\Local\\OpenFin\\runtime\\10.66.39.43", "version": "10.66.39.43" }, { "path": "C:\\Users\\123\\AppData\\Local\\OpenFin\\runtime\\9.61.38.43", "version": "9.61.38.43" }] }- Returns:
- JSONObject
-