Package net.i2p.router.web
Class ShellService
- java.lang.Object
-
- net.i2p.router.web.ShellService
-
- All Implemented Interfaces:
ClientApp
public class ShellService extends Object implements ClientApp
Alternative to ShellCommand for plugins based on ProcessBuilder, which manages a process and keeps track of it's state by maintaining a Process object. Keeps track of the process, and reports start/stop status correctly on configplugins. When running a ShellService from a clients.config file, the user MUST pass -shellservice.name in the args field in clients.config to override the plugin name. The name passed to -shellservice.name should be unique to avoid causing issues. (https://i2pgit.org/i2p-hackers/i2p.i2p/-/merge_requests/39#note_4234) -shellservice.displayName is optional and configures the name of the plugin which is shown on the console. In most cases, the -shellservice.name must be the same as the plugin name in order for the $PLUGIN field in clients.config to match the expected value. If this is not the case, i.e. (-shellservice.name != plugin.name), you must not use $PLUGIN in your clients.config file. The recommended way to use this tool is to manage a single forked app/process, with a single ShellService, in a single plugin. When you are writing your clients.config file, please take note that $PLUGIN will be derived from the `shellservice.name` field in the config file args. Works on Windows, OSX, and Linux.- Since:
- 1.6.0/0.9.52, moved from net.i2p.app in 0.9.53
- Author:
- eyedeekay
-
-
Constructor Summary
Constructors Constructor Description ShellService(I2PAppContext context, ClientAppManager listener, String[] args)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDisplayName()
The display name of the ClientApp, used in user interfaces.String
getName()
The generic name of the ClientApp, used for registration, e.g.ClientAppState
getState()
Query the state of managed process and determine if it is running or not.boolean
isProcessRunning()
Determine if the process running or not.boolean
isProcessStopped()
Determine if the process running or not.void
shutdown(String[] args)
Shut down the process by calling Process.destroy()void
startup()
Determine if a ShellService corresponding to the wrapped application has been started yet.
-
-
-
Constructor Detail
-
ShellService
public ShellService(I2PAppContext context, ClientAppManager listener, String[] args)
-
-
Method Detail
-
startup
public void startup() throws Throwable
Determine if a ShellService corresponding to the wrapped application has been started yet. If it hasn't, attempt to start the process and notify the router that it has been started.
-
isProcessStopped
public boolean isProcessStopped()
Determine if the process running or not.- Returns:
true
if the Process is NOT running,false
if the Process is running
-
isProcessRunning
public boolean isProcessRunning()
Determine if the process running or not.- Returns:
true
if the Process is running,false
if the Process is not running
-
shutdown
public void shutdown(String[] args) throws Throwable
Shut down the process by calling Process.destroy()
-
getState
public ClientAppState getState()
Query the state of managed process and determine if it is running or not. Convert to corresponding ClientAppState and return the correct value.
-
getName
public String getName()
The generic name of the ClientApp, used for registration, e.g. "console". Do not translate. Has a special use in the context of ShellService, must match the plugin name.
-
getDisplayName
public String getDisplayName()
The display name of the ClientApp, used in user interfaces. The app must translate.- Specified by:
getDisplayName
in interfaceClientApp
- Returns:
- non-null
-
-