Add some synchronization to make sure we don't loose commands

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@772639 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiAliasRegistry.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiAliasRegistry.java
index 4e632a1..d8d4732 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiAliasRegistry.java
+++ b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiAliasRegistry.java
@@ -34,11 +34,11 @@
         this.aliasRegistry = aliasRegistry;
     }
 
-    public void register(final Alias alias, Map<String, ?> properties) throws Exception {
+    public synchronized void register(final Alias alias, Map<String, ?> properties) throws Exception {
         aliasRegistry.registerAlias(alias.getName(), alias.getAlias());
     }
 
-    public void unregister(final Alias alias, Map<String, ?> properties) throws Exception {
+    public synchronized void unregister(final Alias alias, Map<String, ?> properties) throws Exception {
         aliasRegistry.removeAlias(alias.getName());
     }
 
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandRegistry.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandRegistry.java
index 78097b3..d0daff3 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandRegistry.java
+++ b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandRegistry.java
@@ -37,21 +37,21 @@
         this.commandRegistry = commandRegistry;
     }
 
-    public void register(final Command command, Map<String, ?> properties) throws Exception {
+    public synchronized void register(final Command command, Map<String, ?> properties) throws Exception {
         commandRegistry.registerCommand(command);
     }
 
-    public void unregister(final Command command, Map<String, ?> properties) throws Exception {
+    public synchronized void unregister(final Command command, Map<String, ?> properties) throws Exception {
         commandRegistry.removeCommand(command);
     }
 
-    public void register(final Link link, Map<String, ?> properties) throws Exception {
+    public synchronized void register(final Link link, Map<String, ?> properties) throws Exception {
         LinkCommand cmd = new LinkCommand(commandRegistry, link.getTarget());
         cmd.setLocation(new CommandLocationImpl(link.getName()));
         commandRegistry.registerCommand(cmd);
     }
 
-    public void unregister(final Link link, Map<String, ?> properties) throws Exception {
+    public synchronized void unregister(final Link link, Map<String, ?> properties) throws Exception {
         commandRegistry.removeCommand(commandRegistry.getCommand(link.getName()));
     }