Class BrowserService
java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.commons.core.service.AbstractService
com.tccc.kos.core.service.browser.BrowserService
- All Implemented Interfaces:
CtxEventListener
,ContextHandleAware
,HandleAware
,Ready
,ReadyListener
Service that manages browsers connected to this service. In a typical
single-node environment that has a screen, there is a single browser
instance running on the same node as this service. In more complex
devices, other nodes may run browsers that are controlled by the node
this service is running on. For example, consider a device with a main
control node and one or more display nodes. The display nodes may run
just a browser that connects back to the main control node. In this
case each browser instance is identified by the nodeId of the node it
is running on and the name of the browser.
Typically, a node will run a single browser. In this case the browser has no name (empty string). This service provides several methods for fetching a browser. Use the one the best matches the needs of your device.
A Browser
object is a logical browser abstraction and allows
navigation commands to be sent to the browser. Browser
objects
can exist without a corresponding browser instance. For example, the
browser may be on another node and that node is powered off. The
Browser
object is still accessible and can accept commands.
When the actual browser instance connects, the last navigation command
will be sent to the browser.
- Since:
- 1.0
- Version:
- 2023-03-06
-
Method Summary
Modifier and TypeMethodDescriptiongetBrowser
(NodeId nodeId, String name) Returns the named browser on the specified nodeId.getBrowser
(BrowserId browserId) Returns theBrowser
with the specifiedBrowserId
, which is simply the combination of a nodeId and name.Returns a collection of existingBrowser
objects.Returns the defaultBrowser
running on the local node.void
goToIntent
(NodeId nodeId, String type) Navigates the default browser on the specified node to the specified intent.void
goToIntent
(NodeId nodeId, String name, String type) Navigates the named browser on the specified node to the specified intent.boolean
goToIntent
(BrowserIntent intent) Resolve the specified intent and navigate the browser accordingly.void
goToIntent
(String type) Navigates the browser on the current node to the specified intent.void
Navigates the default browser on the specified node to the specified URL.void
Navigates the named browser on the specified node to the specified URL.void
goToUrl
(BrowserUrl request) Navigates to the url contained in the navigation request.void
Navigates the browser on the current node to the specified URL.void
Navigates the browser on the current node to the specified URL with optional redirect.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefix
Methods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReady, onBeanReady, onDependenciesReady
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompleted
Methods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPath
Methods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Method Details
-
getLocalBrowser
Returns the defaultBrowser
running on the local node. This is a convenience method for a typical single-node device that runs a single browser locally. User code can interact with theBrowser
object but will have no effect until a correspondingBrowserSession
connects to the service. At that point, the currentBrowser
object state is sent to the actual browser instance. This allows URLs to be sent before the browser is actually available. -
getBrowser
Returns the named browser on the specified nodeId. If there is noBrowser
then it is created. User code can interact with theBrowser
object but will have no effect until a correspondingBrowserSession
connects to the service. At that point, the currentBrowser
object state is sent to the actual browser instance. This allows URLs to be sent before the browser is actually available.- Parameters:
nodeId
- the node to return the browser for.name
- the name of the browser on the node
-
getBrowser
Returns theBrowser
with the specifiedBrowserId
, which is simply the combination of a nodeId and name. If there is noBrowser
with the specified id then it is created. User code can interact with theBrowser
object but will have no effect until a correspondingBrowserSession
connects to the service. At that point, the currentBrowser
object state is sent to the actual browser instance. This allows URLs to be sent before the browser is actually available.- Parameters:
browserId
- the id of the browser to return
-
getBrowsers
Returns a collection of existingBrowser
objects. These may or may not be connected to a real browser instance. -
goToUrl
Navigates the browser on the current node to the specified URL.- Parameters:
url
- the URL to navigate to
-
goToUrl
Navigates the browser on the current node to the specified URL with optional redirect.- Parameters:
url
- the URL to navigate toredirect
- if true, bounce through a redirect URL
-
goToUrl
Navigates the default browser on the specified node to the specified URL.- Parameters:
nodeId
- use the default browser on the node, null will use the local nodeurl
- the URL to navigate toredirect
- if true, bounce through a redirect URL
-
goToUrl
Navigates the named browser on the specified node to the specified URL.- Parameters:
nodeId
- use the named browser on the node, null will use the local nodename
- name of the browser instance to useurl
- the URL to navigate toredirect
- if true, bounce through a redirect URL
-
goToUrl
Navigates to the url contained in the navigation request.- Parameters:
request
- the browser url request
-
goToIntent
Navigates the browser on the current node to the specified intent.- Parameters:
type
- the intent type to navigate to
-
goToIntent
Navigates the default browser on the specified node to the specified intent.- Parameters:
nodeId
- use the default browser on the node, null will use the local nodetype
- the intent type to navigate to
-
goToIntent
Navigates the named browser on the specified node to the specified intent.- Parameters:
nodeId
- use the named browser on the node, null will use the local nodename
- name of the browser instance to usetype
- the intent type to navigate to
-
goToIntent
Resolve the specified intent and navigate the browser accordingly. Returns true if the intent resolved to a url.- Parameters:
intent
- the intent of the navigation
-