geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
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 GMT
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 @@
 
         <property name="commands">
             <list>
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-admin:list-plugins"/>
 
                     <property name="action">
@@ -54,7 +54,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-admin:install-plugin"/>
 
                     <property name="action">

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 @@
 
         <property name="commands">
             <list>
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-bsf:script"/>
 
                     <property name="action">

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 @@
 
     <context:annotation-config/>
 
-    <!--
-    <bean id="commandTemplate" abstract="true" class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
-        <property name="documenter">
-            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandDocumenterImpl"/>
-        </property>
-
-        <property name="completer">
-            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandCompleterImpl"/>
-        </property>
-
-        <property name="messages">
-            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandMessageSourceImpl"/>
-        </property>
-    </bean>
-    -->
-
     <bean class="org.apache.geronimo.gshell.wisdom.plugin.PluginImpl">
         <property name="id" value="gshell-bultins"/>
 
@@ -62,7 +46,7 @@
 
         <property name="commands">
             <list>
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-builtins:clear"/>
 
                     <property name="action">
@@ -70,7 +54,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-builtins:echo"/>
 
                     <property name="action">
@@ -78,7 +62,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-builtins:exit"/>
 
                     <property name="action">
@@ -86,7 +70,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-builtins:help"/>
 
                     <property name="action">
@@ -94,7 +78,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-builtins:source"/>
 
                     <property name="action">
@@ -102,7 +86,7 @@
                     </property>
                 </bean>
                 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-builtins:set"/>
 
                     <property name="action">
@@ -110,7 +94,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-builtins:unset"/>
 
                     <property name="action">

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 @@
 
         <property name="commands">
             <list>
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-optional:cat"/>
 
                     <property name="action">
@@ -54,7 +54,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-optional:exec"/>
 
                     <property name="action">
@@ -62,7 +62,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-optional:java"/>
 
                     <property name="action">
@@ -70,7 +70,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-optional:sleep"/>
 
                     <property name="action">
@@ -78,7 +78,7 @@
                     </property>
                 </bean>
 
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-optional:wait"/>
 
                     <property name="action">

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 @@
 
         <property name="commands">
             <list>
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-repository:resolve"/>
 
                     <property name="action">

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 @@
 
         <property name="commands">
             <list>
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-vfs:copy"/>
 
                     <property name="action">

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 @@
 
         <property name="commands">
             <list>
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-remote-client:rsh"/>
 
                     <property name="action">

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 @@
 
         <property name="commands">
             <list>
-                <bean class="org.apache.geronimo.gshell.wisdom.command.CommandImpl">
+                <bean parent="commandTemplate">
                     <property name="id" value="gshell-remote-server:rsh-server"/>
 
                     <property name="action">

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 @@
 
     <bean id="shell" class="org.apache.geronimo.gshell.wisdom.shell.ShellImpl"/>
 
+    <bean id="commandTemplate" class="org.apache.geronimo.gshell.wisdom.command.CommandImpl"
abstract="true">
+        <property name="documenter">
+            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandDocumenterImpl"/>
+        </property>
+
+        <property name="completer">
+            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandCompleterImpl"/>
+        </property>
+
+        <property name="messages">
+            <bean class="org.apache.geronimo.gshell.wisdom.command.CommandMessageSource"/>
+        </property>
+    </bean>
+
 </beans>
\ No newline at end of file



Mime
View raw message