aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java
diff options
context:
space:
mode:
authorDaniel Pocock <daniel@pocock.pro>2014-07-10 15:44:20 +0200
committerDaniel Pocock <daniel@pocock.pro>2014-08-13 13:51:27 +0200
commite8d71b740d03c29150dbc17480d8d3a6841f9cc9 (patch)
tree13cc5389fe778dd492860236bf9701fdc39b529c /src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java
parent027044dbd1f66342093760cac174470bd504eb44 (diff)
downloadjitsi-e8d71b740d03c29150dbc17480d8d3a6841f9cc9.zip
jitsi-e8d71b740d03c29150dbc17480d8d3a6841f9cc9.tar.gz
jitsi-e8d71b740d03c29150dbc17480d8d3a6841f9cc9.tar.bz2
Add support for a chained main class, for running a second app in the same JVM
Diffstat (limited to 'src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java')
-rw-r--r--src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java b/src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java
index 51c02c4..0ba3dd9 100644
--- a/src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java
+++ b/src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java
@@ -23,6 +23,48 @@ public class SIPCommunicatorJWS
// allow access to everything
System.setSecurityManager(null);
+ // optional: the name of another class with a main method
+ // that should be started in the same JVM:
+ String chainMain = System.getProperty("chain.main.class");
+ if(chainMain != null)
+ {
+ // optional: a space-separated list of arguments to be passed
+ // to the chained main() method:
+ String chainArgs = System.getProperty("chain.main.args");
+ if(chainArgs == null)
+ {
+ chainArgs = "";
+ }
+ final String[] _chainArgs = chainArgs.split("\\s");
+ try
+ {
+ Class<?> c = Class.forName(chainMain);
+ final Method m = c.getMethod("main", _chainArgs.getClass());
+ new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ m.invoke(null, new Object[]{_chainArgs});
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.err.println("Exception running the " +
+ "chained main class, will continue anyway.");
+ }
+ }
+ }.start();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.err.println("Exception finding the chained main " +
+ "class, will continue anyway.");
+ }
+ }
+
// prepare the logger
// needed by the FileHandler-Logger
SIPCommunicator.setScHomeDir(System.getProperty("os.name"));