propagate from branch 'i2p.i2p.zzz.plugin' (head fafcd8c8c41873b4d106a9e06504dd7b48109ad8)
to branch 'i2p.i2p' (head 7eafbe18b0a1e26f09b9488d374f5fed4c278a78)
This commit is contained in:
@ -62,7 +62,7 @@ public class RouterContext extends I2PAppContext {
|
||||
private Calculator _capacityCalc;
|
||||
|
||||
|
||||
private static List _contexts = new ArrayList(1);
|
||||
private static List<RouterContext> _contexts = new ArrayList(1);
|
||||
|
||||
public RouterContext(Router router) { this(router, null); }
|
||||
public RouterContext(Router router, Properties envProps) {
|
||||
@ -148,7 +148,7 @@ public class RouterContext extends I2PAppContext {
|
||||
* context is created or a router is shut down.
|
||||
*
|
||||
*/
|
||||
public static List listContexts() { return _contexts; }
|
||||
public static List<RouterContext> listContexts() { return _contexts; }
|
||||
|
||||
/** what router is this context working for? */
|
||||
public Router router() { return _router; }
|
||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
@ -32,6 +33,13 @@ public class ClientAppConfig {
|
||||
public String args;
|
||||
public long delay;
|
||||
public boolean disabled;
|
||||
/** @since 0.7.12 */
|
||||
public String classpath;
|
||||
/** @since 0.7.12 */
|
||||
public String stopargs;
|
||||
/** @since 0.7.12 */
|
||||
public String uninstallargs;
|
||||
|
||||
public ClientAppConfig(String cl, String client, String a, long d, boolean dis) {
|
||||
className = cl;
|
||||
clientName = client;
|
||||
@ -40,6 +48,14 @@ public class ClientAppConfig {
|
||||
disabled = dis;
|
||||
}
|
||||
|
||||
/** @since 0.7.12 */
|
||||
public ClientAppConfig(String cl, String client, String a, long d, boolean dis, String cp, String sa, String ua) {
|
||||
this(cl, client, a, d, dis);
|
||||
classpath = cp;
|
||||
stopargs = sa;
|
||||
uninstallargs = ua;
|
||||
}
|
||||
|
||||
public static File configFile(I2PAppContext ctx) {
|
||||
String clientConfigFile = ctx.getProperty(PROP_CLIENT_CONFIG_FILENAME, DEFAULT_CLIENT_CONFIG_FILENAME);
|
||||
File cfgFile = new File(clientConfigFile);
|
||||
@ -72,6 +88,26 @@ public class ClientAppConfig {
|
||||
*/
|
||||
public static List<ClientAppConfig> getClientApps(RouterContext ctx) {
|
||||
Properties clientApps = getClientAppProps(ctx);
|
||||
return getClientApps(clientApps);
|
||||
}
|
||||
|
||||
/*
|
||||
* Go through the properties, and return a List of ClientAppConfig structures
|
||||
*/
|
||||
public static List<ClientAppConfig> getClientApps(File cfgFile) {
|
||||
Properties clientApps = new Properties();
|
||||
try {
|
||||
DataHelper.loadProps(clientApps, cfgFile);
|
||||
} catch (IOException ioe) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
return getClientApps(clientApps);
|
||||
}
|
||||
|
||||
/*
|
||||
* Go through the properties, and return a List of ClientAppConfig structures
|
||||
*/
|
||||
private static List<ClientAppConfig> getClientApps(Properties clientApps) {
|
||||
List<ClientAppConfig> rv = new ArrayList(8);
|
||||
int i = 0;
|
||||
while (true) {
|
||||
@ -83,6 +119,9 @@ public class ClientAppConfig {
|
||||
String delayStr = clientApps.getProperty(PREFIX + i + ".delay");
|
||||
String onBoot = clientApps.getProperty(PREFIX + i + ".onBoot");
|
||||
String disabled = clientApps.getProperty(PREFIX + i + ".startOnLoad");
|
||||
String classpath = clientApps.getProperty(PREFIX + i + ".classpath");
|
||||
String stopargs = clientApps.getProperty(PREFIX + i + ".stopargs");
|
||||
String uninstallargs = clientApps.getProperty(PREFIX + i + ".uninstallargs");
|
||||
i++;
|
||||
boolean dis = disabled != null && "false".equals(disabled);
|
||||
|
||||
@ -94,11 +133,13 @@ public class ClientAppConfig {
|
||||
if (delayStr != null && !onStartup)
|
||||
try { delay = 1000*Integer.parseInt(delayStr); } catch (NumberFormatException nfe) {}
|
||||
|
||||
rv.add(new ClientAppConfig(className, clientName, args, delay, dis));
|
||||
rv.add(new ClientAppConfig(className, clientName, args, delay, dis,
|
||||
classpath, stopargs, uninstallargs));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/** classpath and stopargs not supported */
|
||||
public static void writeClientAppConfig(RouterContext ctx, List apps) {
|
||||
File cfgFile = configFile(ctx);
|
||||
FileOutputStream fos = null;
|
||||
|
@ -48,16 +48,20 @@ public class LoadClientAppsJob extends JobImpl {
|
||||
}
|
||||
}
|
||||
}
|
||||
private class DelayedRunClient extends JobImpl {
|
||||
|
||||
public static class DelayedRunClient extends JobImpl {
|
||||
private String _className;
|
||||
private String _clientName;
|
||||
private String _args[];
|
||||
private Log _log;
|
||||
|
||||
public DelayedRunClient(RouterContext enclosingContext, String className, String clientName, String args[], long delay) {
|
||||
super(enclosingContext);
|
||||
_className = className;
|
||||
_clientName = clientName;
|
||||
_args = args;
|
||||
getTiming().setStartAfter(LoadClientAppsJob.this.getContext().clock().now() + delay);
|
||||
_log = enclosingContext.logManager().getLog(LoadClientAppsJob.class);
|
||||
getTiming().setStartAfter(getContext().clock().now() + delay);
|
||||
}
|
||||
public String getName() { return "Delayed client job"; }
|
||||
public void runJob() {
|
||||
|
Reference in New Issue
Block a user