Package com.openfin.desktop
Class DesktopConnection
java.lang.Object
com.openfin.desktop.DesktopConnection
public class DesktopConnection
extends java.lang.Object
A object for launching, connecting to, and controlling Runtime.
-
Constructor Summary
Constructors Constructor Description DesktopConnection(java.lang.String uuid)Creates a new connection to Runtime.DesktopConnection(java.lang.String uuid, java.lang.String host, java.lang.Integer port)Deprecated.useDesktopConnection(String)instead. -
Method Summary
Modifier and Type Method Description voidaddEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, java.lang.Object source)Registers an event listener on the specified eventjava.util.concurrent.CompletionStage<Ack>addEventCallbackAsync(org.json.JSONObject subscriptionObject, EventListener listener, java.lang.Object source)voidaddExternalMessageHandler(ExternalMessageListener listener, java.lang.Object source)Registers a listener to handle messages for this connection's UUID originating via HTTPS/HTTPvoidconnect(DesktopStateListener listener)Connects to an Runtime process.voidconnect(RuntimeConfiguration configuration, DesktopStateListener listener, int timeout)Connect to Runtime with the specified configuration.voiddisconnect()Disconnects from Runtimeprotected voiddisconnect(java.lang.String reason)voidexit()Notify Runtime to exitChannelgetChannel(java.lang.String name)Gets specified channel.InterApplicationBusgetInterApplicationBus()Gets the Inter-Application message dispatcher associated with this DesktopConnectionInteropgetInterop()Gets Interop API object.java.lang.IntegergetPort()Gets port number that Runtime is running onSnapshotSourcegetSnapshotSource()Gets SnapshotSource API objectjava.lang.StringgetUuid()Gets the UUID of this connection.booleanisConnected()InterApplicationBusvoidremoveEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, java.lang.Object source)Removes a previously registered event listener from the specified eventjava.util.concurrent.CompletionStage<Ack>removeEventCallbackAsync(org.json.JSONObject subscriptionObject, EventListener listener, java.lang.Object source)protected voidrespondToPing(long pingId)voidsendAction(java.lang.String action, org.json.JSONObject payload)Sends a message to RuntimevoidsendAction(java.lang.String action, org.json.JSONObject payload, AckListener ackListener, java.lang.Object source)Sends a message to Runtimejava.util.concurrent.CompletableFuture<Ack>sendActionAsync(java.lang.String action, org.json.JSONObject payload, java.lang.Object source)voidsetAdditionalRuntimeArguments(java.lang.String additionalRuntimeArguments)Deprecated.useRuntimeConfigurationinsteadvoidsetAdditionalRvmArguments(java.lang.String additionalRvmArguments)Deprecated.useRuntimeConfigurationinsteadvoidsetDevToolsPort(int port)Deprecated.useRuntimeConfigurationinsteadvoidsetLogLevel(boolean enabled)Deprecated.voidsetRdmUrl(java.lang.String url)Deprecated.voidsetRuntimeSecurityRealm(java.lang.String runtimeSecurityRealm)Deprecated.useRuntimeConfigurationinstead
-
Constructor Details
-
DesktopConnection
Creates a new connection to Runtime.
If the system property "com.openfin.desktop.threads.message.out=nThreads" is defined, it creates
OpenFinThreadPoolwith fixed thread pool size of nThread and uses it to send outgoing messages. If the system property "com.openfin.desktop.threads.message.in=nThreads" is defined, it createsOpenFinThreadPoolwith fixed thread pool size of nThread and uses it to process incoming messages. Otherwise ForkJoinPool.commonPool() will be used to process incoming and/or outgoing messages.- Parameters:
uuid- unique ID for Runtime to refer to this DesktopConnection- Throws:
DesktopException- if this method fails to create a connection
-
DesktopConnection
public DesktopConnection(java.lang.String uuid, java.lang.String host, java.lang.Integer port) throws DesktopExceptionDeprecated.useDesktopConnection(String)instead.Creates a new connection to Runtime.- Parameters:
uuid- unique ID for Runtime to refer to this DesktopConnectionhost- The host that Runtime is running on. Only "localhost" is acceptedport- The port that Runtime is listening on for connections. -null if unknown- Throws:
DesktopException- if this method fails to create a connection
-
-
Method Details
-
connect
public void connect(RuntimeConfiguration configuration, DesktopStateListener listener, int timeout) throws DesktopIOException, java.io.IOExceptionConnect to Runtime with the specified configuration. If the specified version is not running, this method will try to start it.- Parameters:
configuration- an instance of RuntimeConfigurationlistener- Receives updates on startup and connection statetimeout- number of seconds to wait for connection. If connection to Runtime is not established by the timeout the listener will get an onError() call- Throws:
DesktopIOException- if this method fails to connect to Runtimejava.io.IOException- if IO exception is thrown during launching Runtime- See Also:
RuntimeConfiguration
-
disconnect
Disconnects from Runtime- Throws:
DesktopException- if this method fails to disconnect from Runtime
-
disconnect
- Throws:
DesktopException
-
isConnected
public boolean isConnected()InterApplicationBus- Returns:
- true if connected
-
exit
Notify Runtime to exit- Throws:
DesktopException- if this method fails to exit
-
getInterApplicationBus
Gets the Inter-Application message dispatcher associated with this DesktopConnection- Returns:
- InterApplicationBus
-
getPort
public java.lang.Integer getPort()Gets port number that Runtime is running on- Returns:
- port number
-
sendAction
public void sendAction(java.lang.String action, org.json.JSONObject payload) throws DesktopExceptionSends a message to Runtime- Parameters:
action- The action of the messagepayload- The message object to send- Throws:
DesktopException- if this method fails to send the message
-
sendActionAsync
public java.util.concurrent.CompletableFuture<Ack> sendActionAsync(java.lang.String action, org.json.JSONObject payload, java.lang.Object source) -
sendAction
public void sendAction(java.lang.String action, org.json.JSONObject payload, AckListener ackListener, java.lang.Object source)Sends a message to Runtime- Parameters:
action- The action of the messagepayload- The message object to sendackListener- AckListener for the messagesource- Message source- See Also:
AckListener
-
connect
Connects to an Runtime process. Internal use only- Parameters:
listener- Receives updates on startup and connection state- See Also:
DesktopStateListener
-
addEventCallbackAsync
public java.util.concurrent.CompletionStage<Ack> addEventCallbackAsync(org.json.JSONObject subscriptionObject, EventListener listener, java.lang.Object source) -
addEventCallback
public void addEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, java.lang.Object source)Registers an event listener on the specified event- Parameters:
subscriptionObject- JSON object containing subscription information such as the topic and typelistener- EventListener for the eventcallback- AckListener for this requestsource- Source of this request- See Also:
EventListener,AckListener
-
removeEventCallbackAsync
public java.util.concurrent.CompletionStage<Ack> removeEventCallbackAsync(org.json.JSONObject subscriptionObject, EventListener listener, java.lang.Object source) -
removeEventCallback
public void removeEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, java.lang.Object source)Removes a previously registered event listener from the specified event- Parameters:
subscriptionObject- JSON object containing subscription information such as the topic and typelistener- EventListener that was registered beforecallback- AckListener for this requestsource- source of this request
-
respondToPing
protected void respondToPing(long pingId) -
addExternalMessageHandler
Registers a listener to handle messages for this connection's UUID originating via HTTPS/HTTP- Parameters:
listener- process a received HTTPS/HTTP message for this connectionsource- The object that originally registered the listener
-
setAdditionalRuntimeArguments
public void setAdditionalRuntimeArguments(java.lang.String additionalRuntimeArguments)Deprecated.useRuntimeConfigurationinsteadSet additional runtime arguments passed to the Runtime- Parameters:
additionalRuntimeArguments- additional arguments, such as "--v=1" to enable more logging
-
setAdditionalRvmArguments
public void setAdditionalRvmArguments(java.lang.String additionalRvmArguments)Deprecated.useRuntimeConfigurationinsteadSet additional runtime arguments passed to the RVM- Parameters:
additionalRvmArguments- additional arguments
-
setRuntimeSecurityRealm
public void setRuntimeSecurityRealm(java.lang.String runtimeSecurityRealm)Deprecated.useRuntimeConfigurationinsteadSet security realm of the Runtime- Parameters:
runtimeSecurityRealm- name of the realm
-
setRdmUrl
public void setRdmUrl(java.lang.String url)Deprecated.Set URL of RDM service- Parameters:
url- URL of RDM service
-
setDevToolsPort
public void setDevToolsPort(int port)Deprecated.useRuntimeConfigurationinsteadSet port for accessing devtools on localhost- Parameters:
port- port number
-
setLogLevel
public void setLogLevel(boolean enabled)Deprecated.Set log level to be FINE- Parameters:
enabled- true for enabling DEBUG logging
-
getChannel
Gets specified channel.- Parameters:
name- Name of the channel- Returns:
Channelobject with the given name.
-
getInterop
Gets Interop API object.- Returns:
- an instance of Interop
-
getSnapshotSource
Gets SnapshotSource API object- Returns:
- an instance of SnapshotSource
-
getUuid
public java.lang.String getUuid()Gets the UUID of this connection.- Returns:
- uuid of the connection.
-