jwrapper.jwutils
Class JWService

java.lang.Object
  extended by jwrapper.jwutils.JWService

public class JWService
extends java.lang.Object

JWService is a utility class that allows JWrapper virtual apps to be run as an operating system service. JWService launches an elevated ManageService helper app which performs the installation and managed of the OS service.


Nested Class Summary
static class JWService.ServiceManagementException
           
static class JWService.ServiceMessageHandler
          We use this message handler to receive messages from the elevated service install component.
 
Constructor Summary
JWService()
           
 
Method Summary
static java.lang.String getDefaultServiceName()
          Get the default service name used when setting up a JWrapper service.
static java.lang.String getServicePID()
          Return the process identifier reported by the last running service.
static void installService(java.lang.String startVirtualApp, boolean requiresUI)
          Install an OS service which launches the specified virtual app.
static void installService(java.lang.String startVirtualApp, java.lang.String stopVirtualApp, boolean requiresUI)
          Install an OS service which launches the specified virtual app.
static void installService(java.lang.String startVirtualApp, java.lang.String stopVirtualApp, java.net.URL overrideUpdateURL, boolean requiresUI)
          Install an OS service which launches the specified virtual app.
static boolean isServiceRunning()
          Check whether an instance of the service is running.
static void removeService()
          Called to remove the OS service.
static void setServiceRestartOnFailure(java.lang.String serviceName, boolean on, boolean neverGiveUp)
          Currently only on Windows
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JWService

public JWService()
Method Detail

getDefaultServiceName

public static java.lang.String getDefaultServiceName()
Get the default service name used when setting up a JWrapper service.

Returns:

getServicePID

public static java.lang.String getServicePID()
Return the process identifier reported by the last running service. Note that this method does not check to ensure that the service is still running.

Returns:
the process identifier number, as a string, or null if no process identifier exists.

installService

public static void installService(java.lang.String startVirtualApp,
                                  boolean requiresUI)
                           throws java.lang.Exception
Install an OS service which launches the specified virtual app. The virtual app, once launched, should register its existence with JWrapper by calling JWServiceApp.serviceStarted(). Use requiresUI to specify whether the service requires access to the window server. This has different implications on different operating systems. On MacOS the service is installed as a LaunchAgent instead of a LaunchDaemon and runnings in the current context of every logged in user. On Linux the service waits for the X server to start and negotiates appropriate credentials to access it.

Parameters:
startVirtualApp - the name of the virtual app that should be started by the service.
requiresUI - set to true if this service requires access to the UI service.
Throws:
java.lang.Exception

installService

public static void installService(java.lang.String startVirtualApp,
                                  java.lang.String stopVirtualApp,
                                  boolean requiresUI)
                           throws java.lang.Exception
Install an OS service which launches the specified virtual app. The virtual app, once launched, should register its existence with JWrapper by calling JWServiceApp.serviceStarted(). Use requiresUI to specify whether the service requires access to the window server. This has different implications on different operating systems. On MacOS the service is installed as a LaunchAgent instead of a LaunchDaemon and runnings in the current context of every logged in user. On Linux the service waits for the X server to start and negotiates appropriate credentials to access it.

Parameters:
startVirtualApp - the name of the virtual app that should be started by the service.
stopVirtualApp - the name of the virtual app to call when the service should be stopped.
requiresUI - set to true if this service requires access to the UI service.
Throws:
java.lang.Exception

installService

public static void installService(java.lang.String startVirtualApp,
                                  java.lang.String stopVirtualApp,
                                  java.net.URL overrideUpdateURL,
                                  boolean requiresUI)
                           throws java.lang.Exception
Install an OS service which launches the specified virtual app. The virtual app, once launched, should register its existence with JWrapper by calling JWServiceApp.serviceStarted(). Use requiresUI to specify whether the service requires access to the window server. This has different implications on different operating systems. On MacOS the service is installed as a LaunchAgent instead of a LaunchDaemon and runnings in the current context of every logged in user. On Linux the service waits for the X server to start and negotiates appropriate credentials to access it.

Parameters:
startVirtualApp - the name of the virtual app that should be started by the service.
stopVirtualApp - the name of the virtual app that should be called when the OS service wishes to stop the service app. This can be null.
overrideUpdateURL - a new update URL to use for the virtual app launchers, or null if no update URL overriding is required.
requiresUI - set to true if this service requires access to the UI service.
Throws:
java.lang.Exception

isServiceRunning

public static boolean isServiceRunning()
Check whether an instance of the service is running.

Returns:
true if the service is running, false otherwise.

removeService

public static void removeService()
                          throws JWService.ServiceManagementException,
                                 java.io.IOException,
                                 java.lang.Exception
Called to remove the OS service.

Throws:
JWService.ServiceManagementException
java.io.IOException
java.lang.Exception

setServiceRestartOnFailure

public static void setServiceRestartOnFailure(java.lang.String serviceName,
                                              boolean on,
                                              boolean neverGiveUp)
Currently only on Windows

Parameters:
b -