Java Reference
In-Depth Information
The ServiceManager class
The ServiceManager class provides the means for obtaining services from the JNLP Client
through the use of the lookup() method. This method is called by passing it a string with the
fully qualified class name. To discover all the available services, use the method
getServiceNames . The method setServiceManagerStub is used only by the JNLP Client to
install its implementation of the services factory.
11
N OTE
The superclass of all the service classes is Object (see Figure 11.1).
The BasicService class
To begin with, we will study the BasicService class, the most general-purpose service of all
the JNLP services. It provides four methods:
getCodebase(). Returns the codebase URL as specified in the main JNLP file.
• isOffline(). Useful for applications or installers that need to determine whether the client
computer is currently connected.
•showDocument(). Launches the installed Web browser to the specified URL. Used, for
example, in the JNLPLabel class in this chapter.
isWebBrowserSupported() . Useful to know whether a Web browser is currently
installed on the given OS.
A Utility class
We already saw the Utilities class in the previous chapter. This class helped us keep the
code short and meaningful. It is a singleton (see note below), with two instantiation methods,
namely getInstance() and getInstance(String) . The latter initializes the class with a spec-
ified resource bundle for dealing with multilingual applications (but it is always a good idea to
use it). These initialization methods are not required. If we call a static method without prior
initialization:
Utilities.getService(“javax.jnlp.ClipboardService”);
The Utilities class is able to initialize itself transparently.
Search WWH ::




Custom Search