geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r704977 - in /geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry: AliasMetaMapper.java CommandMetaMapper.java
Date Wed, 15 Oct 2008 18:05:37 GMT
Author: gnodet
Date: Wed Oct 15 11:05:36 2008
New Revision: 704977

URL: http://svn.apache.org/viewvc?rev=704977&view=rev
Log:
Fix race problem if commands/aliases are registered before the meta mappers

Modified:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java?rev=704977&r1=704976&r2=704977&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
Wed Oct 15 11:05:36 2008
@@ -25,6 +25,7 @@
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.support.MetaDataRegistryConfigurer;
+import org.apache.geronimo.gshell.registry.AliasRegistry;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import javax.annotation.PostConstruct;
@@ -43,18 +44,27 @@
     @Autowired
     private MetaDataRegistry metaRegistry;
 
+    @Autowired
+    private AliasRegistry aliasRegistry;
+
     private MetaDataRegistryConfigurer metaConfig;
 
     @PostConstruct
-    public void init() {
+    public synchronized void init() throws Exception {
         assert metaRegistry != null;
         metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
 
         assert eventManager != null;
         eventManager.addListener(this);
+
+        // Add existing aliases in case some have already been registered
+        for (String name : aliasRegistry.getAliasNames()) {
+            MetaData data = metaConfig.addFile("/aliases/" + name);
+            data.addAttribute("ALIAS", aliasRegistry.getAlias(name));
+        }
     }
 
-    public void onEvent(final Event event) throws Exception {
+    public synchronized void onEvent(final Event event) throws Exception {
         assert event != null;
 
         if (event instanceof AliasRegisteredEvent) {

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java?rev=704977&r1=704976&r2=704977&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
Wed Oct 15 11:05:36 2008
@@ -25,6 +25,7 @@
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
 import org.apache.geronimo.gshell.vfs.provider.meta.data.support.MetaDataRegistryConfigurer;
+import org.apache.geronimo.gshell.registry.CommandRegistry;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import javax.annotation.PostConstruct;
@@ -43,18 +44,27 @@
     @Autowired
     private MetaDataRegistry metaRegistry;
 
+    @Autowired
+    private CommandRegistry commandRegistry;
+
     private MetaDataRegistryConfigurer metaConfig;
 
     @PostConstruct
-    public void init() {
+    public synchronized void init() throws Exception {
         assert metaRegistry != null;
         metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
 
         assert eventManager != null;
         eventManager.addListener(this);
+
+        // Add existing commands in case some have already been registered
+        for (String name : commandRegistry.getCommandNames()) {
+            MetaData data = metaConfig.addFile("/commands/" + name);
+            data.addAttribute("COMMAND", commandRegistry.getCommand(name));
+        }
     }
 
-    public void onEvent(final Event event) throws Exception {
+    public synchronized void onEvent(final Event event) throws Exception {
         assert event != null;
 
         if (event instanceof CommandRegisteredEvent) {



Mime
View raw message