Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2015-02-26 08:12:13 +0000
committerMarkus Tiede2015-02-26 08:27:43 +0000
commit5a7188dd52a5862aa30cbb42bbb1fd47b37e53d5 (patch)
tree55e89f6e72d80601c01872190126d4d028494c07 /org.eclipse.jubula.app.autrun
parent0969cc82e0b556d5084d96ea0b48417ffad25058 (diff)
downloadorg.eclipse.jubula.core-5a7188dd52a5862aa30cbb42bbb1fd47b37e53d5.tar.gz
org.eclipse.jubula.core-5a7188dd52a5862aa30cbb42bbb1fd47b37e53d5.tar.xz
org.eclipse.jubula.core-5a7188dd52a5862aa30cbb42bbb1fd47b37e53d5.zip
Sprint task - implementation for http://eclip.se/457600#c8
Diffstat (limited to 'org.eclipse.jubula.app.autrun')
-rw-r--r--org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunApplication.java57
-rw-r--r--org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunner.java2
2 files changed, 48 insertions, 11 deletions
diff --git a/org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunApplication.java b/org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunApplication.java
index 2f6828fc2..44436e031 100644
--- a/org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunApplication.java
+++ b/org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunApplication.java
@@ -15,6 +15,7 @@ import java.net.InetSocketAddress;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
@@ -26,6 +27,7 @@ import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.Parser;
import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.adaptor.EclipseStarter;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.jubula.app.autrun.i18n.Messages;
@@ -33,6 +35,8 @@ import org.eclipse.jubula.tools.internal.constants.AutConfigConstants;
import org.eclipse.jubula.tools.internal.constants.EnvConstants;
import org.eclipse.jubula.tools.internal.constants.StringConstants;
import org.eclipse.jubula.tools.internal.registration.AutIdentifier;
+import org.eclipse.jubula.tools.internal.utils.IsAliveThread;
+import org.eclipse.jubula.tools.internal.utils.TimeUtil;
import org.eclipse.jubula.version.Vn;
import org.eclipse.osgi.util.NLS;
import org.slf4j.Logger;
@@ -45,18 +49,11 @@ import org.slf4j.LoggerFactory;
* that the following JVM parameters (or equivalent) are used:<ul>
* <li>osgi.noShutdown=true</li>
* <li>eclipse.jobs.daemon=true</li>
- * <li>eclipse.enableStateSaver=false</li>
- * <li>osgi.framework.activeThreadType=false</li>
* </ul>
* These parameters are required because the original application was designed
* to run outside of an OSGi context, i.e. the application should end only
* when no non-daemon threads are active.
*
- * The <i>osgi.framework.activeThreadType</i> entry can actually be
- * anything other than "normal", but it must be present. This requirement exists
- * since changing org.eclipse.equinox.launcher from 1.1.0 to 1.2.0, and was the
- * cause of bug http://eclip.se/375931.
- *
* @author BREDEX GmbH
* @created Dec 9, 2009
*/
@@ -165,7 +162,7 @@ public class AutRunApplication implements IApplication {
/**
* prints help options
- * @param pe a parse Execption - may also be null
+ * @param pe a parse Exception - may also be null
*/
private static void printHelp(ParseException pe) {
System.out.println(Vn.getDefault().getVersion());
@@ -298,6 +295,43 @@ public class AutRunApplication implements IApplication {
}
/**
+ * @author BREDEX GmbH
+ */
+ private static final class WatchDog extends Thread {
+ /**
+ * Constructor
+ *
+ * @param name
+ * the name
+ */
+ private WatchDog(String name) {
+ super(name);
+ }
+
+ /** {@inheritDoc} */
+ public void run() {
+ boolean shouldShutdown;
+ do {
+ TimeUtil.delay(2500);
+ shouldShutdown = true;
+ Set<Thread> allThreads = Thread.getAllStackTraces().keySet();
+ for (Thread t : allThreads) {
+ if (t instanceof IsAliveThread) {
+ shouldShutdown = false;
+ break;
+ }
+ }
+ } while (!shouldShutdown);
+
+ try {
+ EclipseStarter.shutdown();
+ } catch (Exception e) {
+ LOG.error(e.getLocalizedMessage(), e);
+ }
+ }
+ }
+
+ /**
* This class implements the <code>Comparator</code> interface for comparing
* Options.
*/
@@ -321,7 +355,11 @@ public class AutRunApplication implements IApplication {
*
* {@inheritDoc}
*/
- public Object start(IApplicationContext context) throws Exception {
+ public Object start(final IApplicationContext context) throws Exception {
+ Thread watchDog = new WatchDog("http://eclip.se/457600#c8"); //$NON-NLS-1$
+ watchDog.setDaemon(true);
+ watchDog.start();
+
String[] args = (String[])context.getArguments().get(
IApplicationContext.APPLICATION_ARGS);
if (args == null) {
@@ -382,7 +420,6 @@ public class AutRunApplication implements IApplication {
System.err.println(Messages.infoNonAutAgentConnectionInfo);
}
}
-
return IApplication.EXIT_OK;
}
diff --git a/org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunner.java b/org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunner.java
index 5adff2daa..4a547a4b4 100644
--- a/org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunner.java
+++ b/org.eclipse.jubula.app.autrun/src/org/eclipse/jubula/app/autrun/AutRunner.java
@@ -39,7 +39,7 @@ public class AutRunner {
/**
* @author BREDEX GmbH
*/
- private final class AgentConnectionWatcher extends IsAliveThread {
+ private final class AgentConnectionWatcher extends Thread {
/** the writer */
private final PrintWriter m_writer;
/** the socket */

Back to the top