Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsgibly2006-08-02 08:48:23 -0400
committersgibly2006-08-02 08:48:23 -0400
commitd0b43c8a4100866326dfbf5662cfaad6d21b28e7 (patch)
treeecb46046d00556bc13ba2ddfdfef40663eb47362
parent02b86d54b970efb951b0487a6c1dd41fa7ca5258 (diff)
downloadorg.eclipse.pdt-d0b43c8a4100866326dfbf5662cfaad6d21b28e7.tar.gz
org.eclipse.pdt-d0b43c8a4100866326dfbf5662cfaad6d21b28e7.tar.xz
org.eclipse.pdt-d0b43c8a4100866326dfbf5662cfaad6d21b28e7.zip
Handle multiple daemons
-rw-r--r--plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/DaemonPlugin.java42
-rw-r--r--plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/communication/CommunicationDaemonRegistry.java23
2 files changed, 37 insertions, 28 deletions
diff --git a/plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/DaemonPlugin.java b/plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/DaemonPlugin.java
index 1f5e52781..2b086abfa 100644
--- a/plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/DaemonPlugin.java
+++ b/plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/DaemonPlugin.java
@@ -23,7 +23,8 @@ public class DaemonPlugin extends Plugin {
//The shared instance.
private static DaemonPlugin plugin;
- private ICommunicationDaemon daemon;
+ // Hold an array of possible daemons.
+ private ICommunicationDaemon[] daemons;
/**
* The constructor.
@@ -37,10 +38,12 @@ public class DaemonPlugin extends Plugin {
*/
public void start(BundleContext context) throws Exception {
super.start(context);
- daemon = CommunicationDaemonRegistry.getBestMatchCommunicationDaemon();
- if (daemon != null) {
- daemon.init();
- daemon.startListen();
+ daemons = CommunicationDaemonRegistry.getBestMatchCommunicationDaemons();
+ if (daemons != null) {
+ for (int i = 0; i < daemons.length; i++) {
+ daemons[i].init();
+ daemons[i].startListen();
+ }
}
}
@@ -50,16 +53,18 @@ public class DaemonPlugin extends Plugin {
public void stop(BundleContext context) throws Exception {
super.stop(context);
plugin = null;
- if (daemon != null) {
- daemon.stopListen();
- daemon = null;
+ if (daemons != null) {
+ for (int i = 0; i < daemons.length; i++) {
+ daemons[i].stopListen();
+ }
}
+ daemons = null;
}
public static String getID() {
return ID;
}
-
+
/**
* Returns the shared instance.
*/
@@ -67,17 +72,16 @@ public class DaemonPlugin extends Plugin {
return plugin;
}
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
+ }
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, ID, INTERNAL_ERROR, "Debug Daemon plugin internal error", e)); //$NON-NLS-1$
- }
+ public static void log(Throwable e) {
+ log(new Status(IStatus.ERROR, ID, INTERNAL_ERROR, "Debug Daemon plugin internal error", e)); //$NON-NLS-1$
+ }
- public static void logErrorMessage(String message) {
- log(new Status(IStatus.ERROR, ID, INTERNAL_ERROR, message, null));
- }
+ public static void logErrorMessage(String message) {
+ log(new Status(IStatus.ERROR, ID, INTERNAL_ERROR, message, null));
+ }
}
diff --git a/plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/communication/CommunicationDaemonRegistry.java b/plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/communication/CommunicationDaemonRegistry.java
index 128795b2a..a9e64d0fc 100644
--- a/plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/communication/CommunicationDaemonRegistry.java
+++ b/plugins/org.eclipse.php.debug.daemon/src/org/eclipse/php/debug/daemon/communication/CommunicationDaemonRegistry.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.php.debug.daemon.communication;
+import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -32,8 +33,8 @@ public class CommunicationDaemonRegistry {
private static final String DAEMON_TAG = "daemon"; //$NON-NLS-1$
private static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$
private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
- private static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
-
+// private static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
+
private static final String DEFAULT_DEBUG_DAEMONS_NAMESPACE = "org.eclipse.php.debug.core";
/** Actions stored by ID */
@@ -74,17 +75,18 @@ public class CommunicationDaemonRegistry {
}
/**
- * Return best matching ICommunicationDaemon.
- * The returned ICommunicationDaemon is always a new instance.
+ * Return best matching ICommunicationDaemons array.
+ * The returned ICommunicationDaemons are always new instances.
* In case of an error, null is returned.
*
- * @return A new instance of a best match ICommunicationDaemon
+ * @return New instances of a best match ICommunicationDaemons
*/
- public static ICommunicationDaemon getBestMatchCommunicationDaemon() {
+ public static ICommunicationDaemon[] getBestMatchCommunicationDaemons() {
try {
ICommunicationDaemon defaultDaemon = null;
Dictionary factories = getInstance().getDaemons();
Enumeration e = factories.elements();
+ ArrayList daemons = new ArrayList(4);
while (e.hasMoreElements()) {
CommunicationDaemonFactory initializerFactory = (CommunicationDaemonFactory) e.nextElement();
ICommunicationDaemon initializerDaemon = initializerFactory.createDaemon();
@@ -94,13 +96,16 @@ public class CommunicationDaemonRegistry {
}
} else {
if (initializerDaemon.isEnabled()) {
- return initializerDaemon;
+ daemons.add(initializerDaemon);
}
}
}
- if (defaultDaemon != null) {
- return defaultDaemon;
+ if (daemons.isEmpty() && defaultDaemon != null) {
+ return new ICommunicationDaemon[] { defaultDaemon };
}
+ ICommunicationDaemon[] daemonsLoaded = new ICommunicationDaemon[daemons.size()];
+ daemons.toArray(daemonsLoaded);
+ return daemonsLoaded;
} catch (Exception e) {
DaemonPlugin.log(e);
}

Back to the top