geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r573960 - in /geronimo/sandbox/gshell/trunk: ./ gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/ gshell-cli/ gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-cli/src/main/resources/META-INF/plexus/ gshell-...
Date Sun, 09 Sep 2007 08:47:36 GMT
Author: jdillon
Date: Sun Sep  9 01:47:33 2007
New Revision: 573960

URL: http://svn.apache.org/viewvc?rev=573960&view=rev
Log:
Adding support for shell flavoring... chocolate... yummmy... to allow apps to better brand
their shell

Added:
    geronimo/sandbox/gshell/trunk/gshell-flavor/
    geronimo/sandbox/gshell/trunk/gshell-flavor/pom.xml   (with props)
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/package-info.java
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/apt/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/site.xml   (with props)
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/java/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/java/org/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/java/org/apache/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/java/org/apache/geronimo/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/java/org/apache/geronimo/gshell/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/java/org/apache/geronimo/gshell/flavor/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/resources/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/resources/org/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/resources/org/apache/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/resources/org/apache/geronimo/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/resources/org/apache/geronimo/gshell/
    geronimo/sandbox/gshell/trunk/gshell-flavor/src/test/resources/org/apache/geronimo/gshell/flavor/
Removed:
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Version.java
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/org/apache/geronimo/gshell/cli/
Modified:
    geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
    geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
    geronimo/sandbox/gshell/trunk/pom.xml

Modified: geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java?rev=573960&r1=573959&r2=573960&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
Sun Sep  9 01:47:33 2007
@@ -45,6 +45,10 @@
         programName = getProgramName();
         setProperty("program.name", programName);
 
+        //
+        // TODO: Use the Flavor to figure out what the property name to set is here... ?????
+        //
+        
         homeDir = getHomeDir();
         setProperty("gshell.home", homeDir.getCanonicalPath());
 

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml?rev=573960&r1=573959&r2=573960&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml Sun Sep  9 01:47:33 2007
@@ -51,6 +51,12 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.geronimo.gshell</groupId>
+            <artifactId>gshell-flavor</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <dependency>
             <groupId>org.codehaus.plexus</groupId>
             <artifactId>plexus-classworlds</artifactId>
         </dependency>

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=573960&r1=573959&r2=573960&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Sun Sep  9 01:47:33 2007
@@ -20,9 +20,6 @@
 package org.apache.geronimo.gshell.cli;
 
 import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
@@ -42,10 +39,12 @@
 import org.apache.geronimo.gshell.common.StopWatch;
 import org.apache.geronimo.gshell.console.Console;
 import org.apache.geronimo.gshell.console.JLineConsole;
+import org.apache.geronimo.gshell.flavor.Flavor;
 import org.codehaus.plexus.ContainerConfiguration;
 import org.codehaus.plexus.DefaultContainerConfiguration;
 import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusContainerException;
 import org.codehaus.plexus.classworlds.ClassWorld;
 import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
@@ -75,6 +74,9 @@
     // Late initialized
     private Logger log;
 
+    // HACK:
+    private Flavor flavor;
+    
     public Main(final ClassWorld classWorld) {
         assert classWorld != null;
 
@@ -84,7 +86,7 @@
     @Option(name="-h", aliases={"--help"}, description="Display this help message")
     private boolean help;
 
-    @Option(name="-V", aliases={"--version"}, description="Display GShell version")
+    @Option(name="-V", aliases={"--version"}, description="Display program version")
     private boolean version;
 
     @Option(name="-i", aliases={"--interactive"}, description="Run in interactive mode")
@@ -171,22 +173,10 @@
         System.setProperty("jline.terminal", type);
     }
 
-    private File getUserStateDirectory() {
-        File userHome = new File(System.getProperty("user.home"));
-        File dir = new File(userHome, ".gshell");
-
-        try {
-            return dir.getCanonicalFile();
-        }
-        catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
     private void loadUserScript(final Shell shell, final String fileName) throws Exception
{
         assert fileName != null;
 
-        File file = new File(getUserStateDirectory(), fileName);
+        File file = new File(flavor.getUserStateDirectory(), fileName);
 
         if (file.exists()) {
             log.debug("Loading user-script: {}", file);
@@ -248,34 +238,26 @@
         }
     }
 
-    private String getBanner() {
-        StringWriter writer = new StringWriter();
-        PrintWriter out = new PrintWriter(writer);
-
-        out.println("   ____ ____  _          _ _ ");
-        out.println("  / ___/ ___|| |__   ___| | |");
-        out.println(" | |  _\\___ \\| '_ \\ / _ \\ | |");
-        out.println(" | |_| |___) | | | |  __/ | |");
-        out.println("  \\____|____/|_| |_|\\___|_|_|");
-        out.println();
-        out.println(" @|bold GShell| (" + Version.getInstance() + ")");
-        out.println();
-        out.println("Type '@|bold help|' for help.");
-        out.flush();
+    private PlexusContainer createContainer() throws PlexusContainerException {
+        // Boot up the container
+        ContainerConfiguration config = new DefaultContainerConfiguration();
+        config.setName("gshell.core");
+        config.setClassWorld(classWorld);
 
-        return writer.toString();
+        return new DefaultPlexusContainer(config);
     }
 
     private int execute(final String[] args) throws Exception {
         // Its okay to use logging now
         log = LoggerFactory.getLogger(getClass());
 
-        // Boot up the container
-        ContainerConfiguration config = new DefaultContainerConfiguration();
-        config.setName("gshell.core");
-        config.setClassWorld(classWorld);
+        PlexusContainer container = createContainer();
 
-        PlexusContainer container = new DefaultPlexusContainer(config);
+        //
+        // HACK: Load the flavor here for now
+        //
+        
+        flavor = (Flavor) container.lookup(Flavor.class);
 
         //
         // TODO: We need to pass in our I/O context to the container directly
@@ -306,11 +288,7 @@
             // TODO: Load gsh.properties if it exists?
             //
 
-            //
-            // TODO: Get the name from the branding theme
-            //
-
-            loadUserScript(shell, "gshell.profile");
+            loadUserScript(shell, flavor.getProfileScriptName());
 
             //
             // TODO: Pass interactive flags (maybe as property) so gshell knows what modfooe
it is
@@ -324,11 +302,7 @@
             else if (interactive) {
                 log.debug("Starting interactive console");
 
-                //
-                // TODO: Get the name from the branding theme
-                //
-
-                loadUserScript(shell, "gshell.rc");
+                loadUserScript(shell, flavor.getInteractiveScriptName());
 
                 IO io = shell.getIO();
 
@@ -366,13 +340,9 @@
                     }
                 });
 
-                //
-                // TODO: Get the name from the branding theme
-                //
-                
                 runner.setHistory(new History());
-                runner.setHistoryFile(new File(getUserStateDirectory(), "gshell.history"));
-
+                runner.setHistoryFile(new File(flavor.getUserStateDirectory(), flavor.getHistoryFileName()));
+                
 
                 // Check if there are args, and run them and then enter interactive
                 if (args.length != 0) {
@@ -380,12 +350,8 @@
                 }
 
                 if (!io.isQuiet()) {
-                    //
-                    // TODO: Use a plugable branding theme object here to get the welcome
banner text...
-                    //
+                    io.out.print(flavor.getWelcomeBanner());
                     
-                    io.out.println(getBanner());
-
                     int width = term.getTerminalWidth();
 
                     // If we can't tell, or have something bogus then use a reasonable default
@@ -439,11 +405,20 @@
         clp.process(args);
 
         //
+        // HACK: We need the dang flavor...
+        //
+
+        if (help || version) {
+            PlexusContainer container = createContainer();
+            flavor = (Flavor) container.lookup(Flavor.class);
+        }
+
+        //
         // TODO: Use methods to handle these...
         //
         
         if (help) {
-            io.out.println(System.getProperty("program.name", "gshell") + " [options] <command>
[args]");
+            io.out.println(System.getProperty("program.name", flavor.getName()) + " [options]
<command> [args]");
             io.out.println();
 
             Printer printer = new Printer(clp);
@@ -456,7 +431,7 @@
         }
 
         if (version) {
-            io.out.println(Version.getInstance());
+            io.out.println(flavor.getVersion());
             io.out.println();
             io.out.flush();
 

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml?rev=573960&r1=573959&r2=573960&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
Sun Sep  9 01:47:33 2007
@@ -52,7 +52,21 @@
             <role-hint>default</role-hint>
             <implementation>org.apache.geronimo.gshell.plugin.PluginCollector</implementation>
         </component>
-        
+
+        <!--
+        Hook up the flavor to use.
+        -->
+        <component>
+            <role>org.apache.geronimo.gshell.flavor.Flavor</role>
+            <role-hint>default</role-hint>
+            <implementation>org.apache.geronimo.gshell.flavor.VanillaFlavor</implementation>
+            <requirements>
+                <requirement>
+                    <role>org.apache.geronimo.gshell.flavor.VersionLoader</role>
+                </requirement>
+            </requirements>
+        </component>
+
         <!--
         HACK: This is a massive hackinstine just to get things moving along... and will be
tossed as soon as a palatable solution crosses my path.
         -->

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml?rev=573960&r1=573959&r2=573960&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml Sun Sep  9 01:47:33
2007
@@ -49,6 +49,12 @@
             <artifactId>gshell-core</artifactId>
             <version>${pom.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell</groupId>
+            <artifactId>gshell-flavor</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
     </dependencies>
 
     <build>

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java?rev=573960&r1=573959&r2=573960&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
Sun Sep  9 01:47:33 2007
@@ -26,6 +26,7 @@
 import org.apache.geronimo.gshell.command.CommandSupport;
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
 import org.apache.geronimo.gshell.command.descriptor.CommandDescriptor;
+import org.apache.geronimo.gshell.flavor.Flavor;
 import org.apache.geronimo.gshell.layout.LayoutManager;
 import org.apache.geronimo.gshell.plugin.PluginCollector;
 import org.codehaus.plexus.component.annotations.Requirement;
@@ -46,19 +47,17 @@
     @Requirement
     private LayoutManager layoutManager;
 
+    @Requirement
+    private Flavor flavor;
+
     private Renderer renderer = new Renderer();
 
     protected Object doExecute() throws Exception {
         assert pluginCollector != null;
         assert layoutManager != null;
 
-        //
-        // TODO: Get this from branding theme thingy
-        //
-
         io.out.println();
-        io.out.println("For information about Apache Geronimo, visit:");
-        io.out.println("    http://geronimo.apache.org ");
+        io.out.println(flavor.getAbout());
         io.out.println();
 
         io.out.println("Available commands:");

Modified: geronimo/sandbox/gshell/trunk/gshell-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/pom.xml?rev=573960&r1=573959&r2=573960&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/pom.xml Sun Sep  9 01:47:33 2007
@@ -43,6 +43,12 @@
             <artifactId>gshell-command-api</artifactId>
             <version>${pom.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell</groupId>
+            <artifactId>gshell-flavor</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
         
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java?rev=573960&r1=573959&r2=573960&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
Sun Sep  9 01:47:33 2007
@@ -22,8 +22,9 @@
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.geronimo.gshell.ShellInfo;
+import org.apache.geronimo.gshell.flavor.Flavor;
 import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.slf4j.Logger;
@@ -40,6 +41,9 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    @Requirement
+    private Flavor flavor;
+    
     private File homeDir;
 
     public File getHomeDir() {
@@ -56,13 +60,10 @@
     }
     
     private File detectHomeDir() throws InitializationException {
-        // For right now we require that a "gshell.home" property be set, which should have
been set by the Bootstrapper.
-        // Will eventually allow this to be changed for shell branding mucko
-
-        String homePath = System.getProperty("gshell.home");
-
+        String homePath = flavor.getProperty(Flavor.HOME);
+        
         if (homePath == null) {
-            throw new InitializationException("The 'gshell.home' property must be set for
the shell to function correctly");
+            throw new InitializationException("The '" + flavor.getPropertyName(Flavor.HOME)
+ "' property must be set for the shell to function correctly");
         }
 
         // And now lets resolve this sucker

Added: geronimo/sandbox/gshell/trunk/gshell-flavor/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-flavor/pom.xml?rev=573960&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/pom.xml (added)
+++ geronimo/sandbox/gshell/trunk/gshell-flavor/pom.xml Sun Sep  9 01:47:33 2007
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    
+    <modelVersion>4.0.0</modelVersion>
+    
+    <parent>
+        <groupId>org.apache.geronimo.gshell</groupId>
+        <artifactId>gshell</artifactId>
+        <version>1.0-alpha-1-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>gshell-flavor</artifactId>
+    <name>GShell Flavor</name>
+
+    <description>
+        Provides muck for branding a GShell application.
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.gshell</groupId>
+            <artifactId>gshell-command-api</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-common</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-component-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-component-annotations</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>${pom.basedir}/src/main/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+
+            <resource>
+                <directory>${pom.basedir}/src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>org/apache/geronimo/gshell/flavor/version.properties</include>
+                </includes>
+            </resource>
+        </resources>
+
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.plexus</groupId>
+                <artifactId>plexus-java5-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>descriptor</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java?rev=573960&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java
Sun Sep  9 01:47:33 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.flavor;
+
+import java.io.File;
+
+/**
+ * Defines the basic elements for branding a GShell application.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Flavor
+{
+    String HOME = "home";
+
+    String getName();
+
+    String getDisplayName();
+
+    String getAbout();
+
+    String getVersion();
+    
+    String getWelcomeBanner();
+
+    File getUserStateDirectory();
+
+    String getProfileScriptName();
+
+    String getInteractiveScriptName();
+
+    String getHistoryFileName();
+
+    String getPropertyName(String name);
+
+    String getProperty(String name);
+
+    String getProperty(String name, String defaultValue);
+
+    //
+    // TODO: Add getGoodbyeMessage() ?
+    //
+
+    //
+    // TODO: Maybe this should just be a map of stuff, with well defined keys?  That would
support
+    //       handy loading of flavors from properties files...
+    //
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java?rev=573960&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java
Sun Sep  9 01:47:33 2007
@@ -0,0 +1,59 @@
+/*
+ * 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.flavor;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.codehaus.plexus.component.annotations.Component;
+
+/**
+ * Loads a version number from a properties file.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=VersionLoader.class, hint="default") // HACK: hint="properties")
+public class PropertiesVersionLoader
+    implements VersionLoader
+{
+    private Properties props;
+
+    // @Configuraton(key="resourceName", value="version.properties")
+    private String resourceName = "version.properties";
+
+    public String getVersion() {
+        if (props == null) {
+            InputStream input = getClass().getResourceAsStream(resourceName);
+            assert input != null;
+
+            try {
+                props = new Properties();
+                props.load(input);
+                input.close();
+            }
+            catch (IOException e) {
+                throw new RuntimeException("Failed to load " + resourceName, e);
+            }
+        }
+        
+        return props.getProperty("version");
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java?rev=573960&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java
Sun Sep  9 01:47:33 2007
@@ -0,0 +1,123 @@
+/*
+ * 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.flavor;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+/**
+ * Provides the <em>vanilla</em> flavor for GShell.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=Flavor.class, hint="vanilla")
+public class VanillaFlavor
+    implements Flavor
+{
+    @Requirement
+    private VersionLoader versionLoader;
+
+    public String getName() {
+        return "gshell";
+    }
+
+    public String getDisplayName() {
+        return "GShell";
+    }
+
+    public String getAbout() {
+        StringWriter writer = new StringWriter();
+        PrintWriter out = new PrintWriter(writer);
+
+        out.println("For information about Apache Geronimo, visit:");
+        out.println("    http://geronimo.apache.org ");
+        out.flush();
+
+        return writer.toString();
+    }
+
+    public String getVersion() {
+        assert versionLoader != null;
+
+        return versionLoader.getVersion();
+    }
+
+    public String getWelcomeBanner() {
+        StringWriter writer = new StringWriter();
+        PrintWriter out = new PrintWriter(writer);
+
+        out.println("   ____ ____  _          _ _ ");
+        out.println("  / ___/ ___|| |__   ___| | |");
+        out.println(" | |  _\\___ \\| '_ \\ / _ \\ | |");
+        out.println(" | |_| |___) | | | |  __/ | |");
+        out.println("  \\____|____/|_| |_|\\___|_|_|");
+        out.println();
+        out.println(" @|bold GShell| (" + getVersion() + ")");
+        out.println();
+        out.println("Type '@|bold help|' for help.");
+        out.flush();
+
+        return writer.toString();
+    }
+
+    public File getUserStateDirectory() {
+        File userHome = new File(System.getProperty("user.home"));
+
+        File dir = new File(userHome, "." + getName());
+        
+        return dir.getAbsoluteFile();
+    }
+
+    public String getProfileScriptName() {
+        return getName() + ".profile";
+    }
+
+    public String getInteractiveScriptName() {
+        return getName() + ".rc";
+    }
+
+    public String getHistoryFileName() {
+        return getName() + ".history";
+    }
+
+    public String getPropertyName(final String name) {
+        assert name != null;
+        
+        return getName() + "." + name;
+    }
+
+    public String getProperty(final String name) {
+        return System.getProperty(getPropertyName(name));
+    }
+
+    public String getProperty(final String name, final String defaultValue) {
+        String value = getProperty(name);
+        
+        if (value == null) {
+            return defaultValue;
+        }
+
+        return value;
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java?rev=573960&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java
Sun Sep  9 01:47:33 2007
@@ -0,0 +1,30 @@
+/*
+ * 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.flavor;
+
+/**
+ * Provides a simple interface for loading a version identifier.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface VersionLoader
+{
+    String getVersion();
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/package-info.java?rev=573960&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/package-info.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/package-info.java
Sun Sep  9 01:47:33 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides muck for branding a GShell application.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.flavor;
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties?rev=573960&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties
Sun Sep  9 01:47:33 2007
@@ -0,0 +1,24 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+version=${pom.version}

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/site.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/site.xml?rev=573960&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/site.xml (added)
+++ geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/site.xml Sun Sep  9 01:47:33 2007
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project name="${project.name}">
+    
+    <body>
+        
+        ${parentProject}
+        
+        ${modules}
+        
+        ${reports}
+        
+    </body>
+
+</project>
+
+

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/site.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-flavor/src/site/site.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: geronimo/sandbox/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/pom.xml?rev=573960&r1=573959&r2=573960&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/pom.xml Sun Sep  9 01:47:33 2007
@@ -335,6 +335,7 @@
         <module>gshell-support</module>
         <module>gshell-bootstrap</module>
         <module>gshell-command-api</module>
+        <module>gshell-flavor</module>
         <module>javacc-maven-plugin</module>
         <module>gshell-parser</module>
         <module>gshell-core</module>



Mime
View raw message