Package com.openfin.desktop
Class DesktopConnection
- java.lang.Object
-
- com.openfin.desktop.DesktopConnection
-
public class DesktopConnection extends Object
An object for launching, connecting to, and controlling Runtime.
-
-
Constructor Summary
Constructors Constructor Description DesktopConnection(String uuid)Creates a new connection to Runtime.DesktopConnection(String uuid, String host, Integer port)Deprecated.useDesktopConnection(String)instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, Object source)Registers an event listener on the specified eventCompletionStage<Ack>addEventCallbackAsync(org.json.JSONObject subscriptionObject, EventListener listener, Object source)voidaddExternalMessageHandler(ExternalMessageListener listener, 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(String reason)voidexit()Notify Runtime to exitChannelgetChannel(String name)Gets specified channel.InterApplicationBusgetInterApplicationBus()Gets the Inter-Application message dispatcher associated with this DesktopConnectionInteropgetInterop()Gets Interop API object.IntegergetPort()Gets port number that Runtime is running onSnapshotSourcegetSnapshotSource()Gets SnapshotSource API objectStringgetUuid()Gets the UUID of this connection.booleanisConnected()InterApplicationBus<T> CompletableFuture<T>launchManifest(String manifestUrl, Class<T> type, RVMOptions options)voidremoveEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, Object source)Removes a previously registered event listener from the specified eventCompletionStage<Ack>removeEventCallbackAsync(org.json.JSONObject subscriptionObject, EventListener listener, Object source)protected voidrespondToPing(long pingId)voidsendAction(String action, org.json.JSONObject payload)Sends a message to RuntimevoidsendAction(String action, org.json.JSONObject payload, AckListener ackListener, Object source)Sends a message to RuntimeCompletableFuture<Ack>sendActionAsync(String action, org.json.JSONObject payload, Object source)voidsetAdditionalRuntimeArguments(String additionalRuntimeArguments)Deprecated.useRuntimeConfigurationinsteadvoidsetAdditionalRvmArguments(String additionalRvmArguments)Deprecated.useRuntimeConfigurationinsteadvoidsetDevToolsPort(int port)Deprecated.useRuntimeConfigurationinsteadvoidsetLogLevel(boolean enabled)Deprecated.voidsetRdmUrl(String url)Deprecated.voidsetRuntimeSecurityRealm(String runtimeSecurityRealm)Deprecated.useRuntimeConfigurationinstead
-
-
-
Constructor Detail
-
DesktopConnection
public DesktopConnection(String uuid) throws DesktopException
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(String uuid, String host, Integer port) throws DesktopException
Deprecated.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 Detail
-
connect
public void connect(RuntimeConfiguration configuration, DesktopStateListener listener, int timeout) throws DesktopIOException, IOException
Connect 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 RuntimeIOException- if IO exception is thrown during launching Runtime- See Also:
RuntimeConfiguration
-
disconnect
public void disconnect() throws DesktopExceptionDisconnects from Runtime- Throws:
DesktopException- if this method fails to disconnect from Runtime
-
disconnect
protected void disconnect(String reason) throws DesktopException
- Throws:
DesktopException
-
isConnected
public boolean isConnected()
InterApplicationBus- Returns:
- true if connected
-
exit
public void exit() throws DesktopExceptionNotify Runtime to exit- Throws:
DesktopException- if this method fails to exit
-
getInterApplicationBus
public InterApplicationBus getInterApplicationBus()
Gets the Inter-Application message dispatcher associated with this DesktopConnection- Returns:
- InterApplicationBus
-
getPort
public Integer getPort()
Gets port number that Runtime is running on- Returns:
- port number
-
sendAction
public void sendAction(String action, org.json.JSONObject payload) throws DesktopException
Sends 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 CompletableFuture<Ack> sendActionAsync(String action, org.json.JSONObject payload, Object source)
-
sendAction
public void sendAction(String action, org.json.JSONObject payload, AckListener ackListener, 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
public void connect(DesktopStateListener listener)
Connects to an Runtime process. Internal use only- Parameters:
listener- Receives updates on startup and connection state- See Also:
DesktopStateListener
-
addEventCallbackAsync
public CompletionStage<Ack> addEventCallbackAsync(org.json.JSONObject subscriptionObject, EventListener listener, Object source)
-
addEventCallback
public void addEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, 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 CompletionStage<Ack> removeEventCallbackAsync(org.json.JSONObject subscriptionObject, EventListener listener, Object source)
-
removeEventCallback
public void removeEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, 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
public void addExternalMessageHandler(ExternalMessageListener listener, Object source)
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(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(String additionalRvmArguments)
Deprecated.useRuntimeConfigurationinsteadSet additional runtime arguments passed to the RVM- Parameters:
additionalRvmArguments- additional arguments
-
setRuntimeSecurityRealm
public void setRuntimeSecurityRealm(String runtimeSecurityRealm)
Deprecated.useRuntimeConfigurationinsteadSet security realm of the Runtime- Parameters:
runtimeSecurityRealm- name of the realm
-
setRdmUrl
public void setRdmUrl(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
public Channel getChannel(String name)
Gets specified channel.- Parameters:
name- Name of the channel- Returns:
Channelobject with the given name.
-
getInterop
public Interop getInterop()
Gets Interop API object.- Returns:
- an instance of Interop
-
getSnapshotSource
public SnapshotSource getSnapshotSource()
Gets SnapshotSource API object- Returns:
- an instance of SnapshotSource
-
getUuid
public String getUuid()
Gets the UUID of this connection.- Returns:
- uuid of the connection.
-
launchManifest
public <T> CompletableFuture<T> launchManifest(String manifestUrl, Class<T> type, RVMOptions options) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
-