- if Web Start is available, can be set a boolean flag (defined in
ApplicationContext) read-only for applications ? Could be useful
in many situations ...
Better, we (or i) can do an utility method (maybe static, and maybe in
ApplicationContext, and without having a global instance boolean
variable) that tries to get a reference to a Web Start Service
(Codebase or another), and if available return true, very simple and
could be useful in many other situations.
Perhaps. But what might an application do with such information? If an
application needs JNLP features, shouldn't it simply attempt to use
the JNLP APIs, and gracefully handle any exceptions thrown when it has
not been launched via Web Start?
I think this probably falls outside the realm of Pivot functionality.
But a block of code like this is already in DesktopApplicationContext,
take a look:
// Load the JNLP classes dynamically because they are
only available
// when run via javaws
Class<?> serviceManagerClass =
Class.forName("javax.jnlp.ServiceManager");
Method lookupMethod =
serviceManagerClass.getMethod("lookup", new Class<?>[]
{String.class});
Object basicService = lookupMethod.invoke(null,
"javax.jnlp.BasicService");
Class<?> basicServiceClass =
Class.forName("javax.jnlp.BasicService");
Method getCodeBaseMethod =
basicServiceClass.getMethod("getCodeBase", new Class<?>[] {});
URL codeBase = (URL)getCodeBaseMethod.invoke(basicService);
if (codeBase != null) {
origin = new URL(codeBase.getProtocol(),
codeBase.getHost(), codeBase.getPort(), "");
We need that code to obtain the origin, so applications can reliably
request it regardless of how they are launched.