Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-04-19 21:11:56 +0000
committerRoberto E. Escobar2012-04-19 21:11:56 +0000
commit6b1629895c9fd891dec231844bbb225dcad47614 (patch)
tree34c798d30c8b3986837a8b9e1a6156d350560163 /plugins/org.eclipse.osee.console.admin
parent52475f13181346eb1d7d710a54a9d3757b3a3aeb (diff)
downloadorg.eclipse.osee-6b1629895c9fd891dec231844bbb225dcad47614.tar.gz
org.eclipse.osee-6b1629895c9fd891dec231844bbb225dcad47614.tar.xz
org.eclipse.osee-6b1629895c9fd891dec231844bbb225dcad47614.zip
refactor: Remove OSGI references from consoleAdmin
Diffstat (limited to 'plugins/org.eclipse.osee.console.admin')
-rw-r--r--plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdmin.java39
-rw-r--r--plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdminUtils.java11
2 files changed, 22 insertions, 28 deletions
diff --git a/plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdmin.java b/plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdmin.java
index 226655a14f7..0176bc47913 100644
--- a/plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdmin.java
+++ b/plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdmin.java
@@ -10,18 +10,16 @@
*******************************************************************************/
package org.eclipse.osee.console.admin.internal;
-import java.util.List;
import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.osee.console.admin.ConsoleAdminConstants;
import org.eclipse.osee.console.admin.ConsoleCommand;
import org.eclipse.osee.event.EventService;
import org.eclipse.osee.executor.admin.ExecutorAdmin;
import org.eclipse.osee.logger.Log;
import org.eclipse.osgi.framework.console.CommandProvider;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
/**
@@ -29,8 +27,8 @@ import org.osgi.framework.ServiceRegistration;
*/
public class ConsoleAdmin {
- private final List<ServiceReference<ConsoleCommand>> pending =
- new CopyOnWriteArrayList<ServiceReference<ConsoleCommand>>();
+ private final Map<ConsoleCommand, Map<String, String>> pending =
+ new ConcurrentHashMap<ConsoleCommand, Map<String, String>>();
private Log logger;
private EventService eventService;
@@ -69,8 +67,8 @@ public class ConsoleAdmin {
thread = new Thread("Register Pending Osee Console Commands") {
@Override
public void run() {
- for (ServiceReference<ConsoleCommand> reference : pending) {
- register(reference);
+ for (Entry<ConsoleCommand, Map<String, String>> entry : pending.entrySet()) {
+ register(entry.getKey(), entry.getValue());
}
pending.clear();
}
@@ -95,25 +93,25 @@ public class ConsoleAdmin {
return getDispatcher() != null && getLogger() != null;
}
- public void addCommand(ServiceReference<ConsoleCommand> reference) {
+ public void addCommand(ConsoleCommand reference, Map<String, String> props) {
if (isReady()) {
- register(reference);
+ register(reference, props);
} else {
- pending.add(reference);
+ pending.put(reference, props);
}
}
- public void removeCommand(ServiceReference<ConsoleCommand> reference) {
+ public void removeCommand(ConsoleCommand reference, Map<String, String> props) {
if (isReady()) {
- unregister(reference);
+ unregister(reference, props);
} else {
pending.remove(reference);
}
}
- private void unregister(ServiceReference<ConsoleCommand> reference) {
- String componentName = ConsoleAdminUtils.getComponentName(reference);
- String contextName = ConsoleAdminUtils.getContextName(reference);
+ private void unregister(ConsoleCommand reference, Map<String, String> props) {
+ String componentName = ConsoleAdminUtils.getComponentName(props);
+ String contextName = ConsoleAdminUtils.getContextName(props);
getDispatcher().unregister(componentName);
getLogger().debug("De-registering command for '%s' with alias '%s'\n", componentName, contextName);
@@ -121,13 +119,10 @@ public class ConsoleAdmin {
notifyDeRegistration(componentName, contextName);
}
- private void register(ServiceReference<ConsoleCommand> reference) {
- String componentName = ConsoleAdminUtils.getComponentName(reference);
- String contextName = ConsoleAdminUtils.getContextName(reference);
+ private void register(ConsoleCommand consoleCommand, Map<String, String> props) {
+ String componentName = ConsoleAdminUtils.getComponentName(props);
+ String contextName = ConsoleAdminUtils.getContextName(props);
try {
- Bundle bundle = reference.getBundle();
- ConsoleCommand consoleCommand = bundle.getBundleContext().getService(reference);
-
getDispatcher().register(componentName, consoleCommand);
notifyRegistration(componentName, contextName);
getLogger().debug("Registered command for '%s' with alias '%s'\n", componentName, contextName);
diff --git a/plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdminUtils.java b/plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdminUtils.java
index 57dae9f5800..1bb39a77d4b 100644
--- a/plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdminUtils.java
+++ b/plugins/org.eclipse.osee.console.admin/src/org/eclipse/osee/console/admin/internal/ConsoleAdminUtils.java
@@ -22,7 +22,6 @@ import org.eclipse.osee.console.admin.ConsoleParameters;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.osgi.framework.ServiceReference;
/**
* @author Roberto E. Escobar
@@ -33,16 +32,16 @@ public final class ConsoleAdminUtils {
// Utility class
}
- public static String getContextName(ServiceReference<?> reference) {
- String contextName = (String) reference.getProperty("context.name");
+ public static String getContextName(Map<String, String> props) {
+ String contextName = props.get("context.name");
if (!isValid(contextName)) {
- contextName = getComponentName(reference);
+ contextName = getComponentName(props);
}
return normalize(contextName);
}
- public static String getComponentName(ServiceReference<?> reference) {
- return (String) reference.getProperty("component.name");
+ public static String getComponentName(Map<String, String> props) {
+ return props.get("component.name");
}
private static String normalize(String contextName) {

Back to the top