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 void
addEventCallback(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)
void
addExternalMessageHandler(ExternalMessageListener listener, java.lang.Object source)
Registers a listener to handle messages for this connection's UUID originating via HTTPS/HTTPvoid
connect(DesktopStateListener listener)
Connects to an Runtime process.void
connect(RuntimeConfiguration configuration, DesktopStateListener listener, int timeout)
Connect to Runtime with the specified configuration.void
disconnect()
Disconnects from Runtimeprotected void
disconnect(java.lang.String reason)
void
exit()
Notify Runtime to exitChannel
getChannel(java.lang.String name)
Gets specified channel.InterApplicationBus
getInterApplicationBus()
Gets the Inter-Application message dispatcher associated with this DesktopConnectionInterop
getInterop()
Gets Interop API object.java.lang.Integer
getPort()
Gets port number that Runtime is running onSnapshotSource
getSnapshotSource()
Gets SnapshotSource API objectjava.lang.String
getUuid()
Gets the UUID of this connection.boolean
isConnected()
InterApplicationBusvoid
removeEventCallback(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 void
respondToPing(long pingId)
void
sendAction(java.lang.String action, org.json.JSONObject payload)
Sends a message to Runtimevoid
sendAction(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)
void
setAdditionalRuntimeArguments(java.lang.String additionalRuntimeArguments)
Deprecated.useRuntimeConfiguration
insteadvoid
setAdditionalRvmArguments(java.lang.String additionalRvmArguments)
Deprecated.useRuntimeConfiguration
insteadvoid
setDevToolsPort(int port)
Deprecated.useRuntimeConfiguration
insteadvoid
setLogLevel(boolean enabled)
Deprecated.void
setRdmUrl(java.lang.String url)
Deprecated.void
setRuntimeSecurityRealm(java.lang.String runtimeSecurityRealm)
Deprecated.useRuntimeConfiguration
instead
-
Constructor Details
-
DesktopConnection
Creates a new connection to Runtime.
If the system property "com.openfin.desktop.threads.message.out=nThreads" is defined, it creates
OpenFinThreadPool
with 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 createsOpenFinThreadPool
with 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.useRuntimeConfiguration
insteadSet 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.useRuntimeConfiguration
insteadSet additional runtime arguments passed to the RVM- Parameters:
additionalRvmArguments
- additional arguments
-
setRuntimeSecurityRealm
public void setRuntimeSecurityRealm(java.lang.String runtimeSecurityRealm)Deprecated.useRuntimeConfiguration
insteadSet 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.useRuntimeConfiguration
insteadSet 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:
Channel
object 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.
-