Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 48262 invoked from network); 22 Sep 2008 09:35:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Sep 2008 09:35:15 -0000 Received: (qmail 51216 invoked by uid 500); 22 Sep 2008 09:35:12 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 51161 invoked by uid 500); 22 Sep 2008 09:35:11 -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 51152 invoked by uid 99); 22 Sep 2008 09:35:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Sep 2008 02:35:11 -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; Mon, 22 Sep 2008 09:34:20 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B3EDB23889F7; Mon, 22 Sep 2008 02:34:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r697742 - in /geronimo/gshell/trunk: gshell-commands/gshell-admin/src/main/resources/META-INF/spring/ gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/ gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/ gshell-... Date: Mon, 22 Sep 2008 09:34:53 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080922093453.B3EDB23889F7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jdillon Date: Mon Sep 22 02:34:52 2008 New Revision: 697742 URL: http://svn.apache.org/viewvc?rev=697742&view=rev Log: Added CommandMessageSource, created commandTemplate bean, using that as the parent for all commands Dropped init() manual component creation muck, just let spring handle it Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandMessageSource.java (with props) Modified: geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml Modified: geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml Mon Sep 22 02:34:52 2008 @@ -46,7 +46,7 @@ - + @@ -54,7 +54,7 @@ - + Modified: geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml Mon Sep 22 02:34:52 2008 @@ -46,7 +46,7 @@ - + Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml Mon Sep 22 02:34:52 2008 @@ -29,22 +29,6 @@ - - @@ -62,7 +46,7 @@ - + @@ -70,7 +54,7 @@ - + @@ -78,7 +62,7 @@ - + @@ -86,7 +70,7 @@ - + @@ -94,7 +78,7 @@ - + @@ -102,7 +86,7 @@ - + @@ -110,7 +94,7 @@ - + Modified: geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml Mon Sep 22 02:34:52 2008 @@ -46,7 +46,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -78,7 +78,7 @@ - + Modified: geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml Mon Sep 22 02:34:52 2008 @@ -46,7 +46,7 @@ - + Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/spring/components.xml Mon Sep 22 02:34:52 2008 @@ -46,7 +46,7 @@ - + Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/resources/META-INF/spring/components.xml?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/resources/META-INF/spring/components.xml Mon Sep 22 02:34:52 2008 @@ -46,7 +46,7 @@ - + Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-remote/gshell-remote-server/src/main/resources/META-INF/spring/components.xml Mon Sep 22 02:34:52 2008 @@ -46,7 +46,7 @@ - + Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java Mon Sep 22 02:34:52 2008 @@ -22,23 +22,20 @@ import org.apache.geronimo.gshell.clp.CommandLineProcessor; import org.apache.geronimo.gshell.clp.Option; import org.apache.geronimo.gshell.command.Arguments; -import org.apache.geronimo.gshell.command.CommandAction; import org.apache.geronimo.gshell.command.Command; +import org.apache.geronimo.gshell.command.CommandAction; import org.apache.geronimo.gshell.command.CommandContext; import org.apache.geronimo.gshell.command.CommandDocumenter; import org.apache.geronimo.gshell.command.CommandResult; import org.apache.geronimo.gshell.command.Variables; -import org.apache.geronimo.gshell.i18n.ResourceBundleMessageSource; import org.apache.geronimo.gshell.io.IO; import org.apache.geronimo.gshell.notification.Notification; -import org.apache.geronimo.gshell.spring.BeanContainerAware; import org.apache.geronimo.gshell.spring.BeanContainer; +import org.apache.geronimo.gshell.spring.BeanContainerAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; -import javax.annotation.PostConstruct; - /** * The default {@link Command} component. * @@ -58,26 +55,6 @@ this.container = container; } - @SuppressWarnings({"UnusedDeclaration"}) - @PostConstruct - private void init() { - // - // TODO: Should ask the container to auto-wire these folks, or ask for defalut versions from the container via factory? - // or simply use a parent bean to configure them? - // - - // Create default components if not configured - if (getDocumenter() == null) { - setDocumenter(new CommandDocumenterImpl()); - } - if (getCompleter() == null) { - setCompleter(new CommandCompleterImpl()); - } - if (getMessages() == null) { - setMessages(new ResourceBundleMessageSource(getAction().getClass())); - } - } - public CommandResult execute(final Object[] args, final IO io, final Variables variables) { assert args != null; assert io != null; Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandMessageSource.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandMessageSource.java?rev=697742&view=auto ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandMessageSource.java (added) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandMessageSource.java Mon Sep 22 02:34:52 2008 @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.geronimo.gshell.wisdom.command; + +import org.apache.geronimo.gshell.command.Command; +import org.apache.geronimo.gshell.command.CommandAware; +import org.apache.geronimo.gshell.i18n.MessageSource; +import org.apache.geronimo.gshell.i18n.ResourceBundleMessageSource; + +/** + * Command {@link MessageSource}. + * + * @version $Rev$ $Date$ + */ +public class CommandMessageSource + implements MessageSource, CommandAware +{ + private Command command; + + private MessageSource messages; + + public void setCommand(final Command command) { + assert command != null; + this.command = command; + } + + private MessageSource getMessages() { + if (messages == null) { + assert command != null; + messages = new ResourceBundleMessageSource(command.getAction().getClass()); + } + + return messages; + } + + public String getMessage(final String code) { + return getMessages().getMessage(code); + } + + public String format(final String code, final Object... args) { + return getMessages().format(code, args); + } +} Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandMessageSource.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandMessageSource.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandMessageSource.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java Mon Sep 22 02:34:52 2008 @@ -49,6 +49,8 @@ private MessageSource messages; public String getId() { + assert id != null; + return id; } @@ -59,6 +61,8 @@ } public CommandAction getAction() { + assert action != null; + return action; } @@ -71,6 +75,8 @@ } public CommandDocumenter getDocumenter() { + assert documenter != null; + return documenter; } @@ -83,6 +89,8 @@ } public CommandCompleter getCompleter() { + assert completer != null; + return completer; } @@ -95,6 +103,8 @@ } public MessageSource getMessages() { + assert messages != null; + return messages; } Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml?rev=697742&r1=697741&r2=697742&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml Mon Sep 22 02:34:52 2008 @@ -43,4 +43,18 @@ + + + + + + + + + + + + + + \ No newline at end of file