Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 46971 invoked from network); 15 Oct 2008 18:05:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Oct 2008 18:05:58 -0000 Received: (qmail 39867 invoked by uid 500); 15 Oct 2008 18:05:59 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 39715 invoked by uid 500); 15 Oct 2008 18:05:59 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 39673 invoked by uid 99); 15 Oct 2008 18:05:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Oct 2008 11:05:59 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Oct 2008 18:04:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2C13B238897B; Wed, 15 Oct 2008 11:05:37 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: gnodet@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081015180537.2C13B238897B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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) {