geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r661216 - in /geronimo/gshell/trunk: gshell-assembly/src/main/underlay/etc/ gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ gshell-core/src...
Date Thu, 29 May 2008 05:30:18 GMT
Author: jdillon
Date: Wed May 28 22:30:17 2008
New Revision: 661216

URL: http://svn.apache.org/viewvc?rev=661216&view=rev
Log:
Branding is now part of the application model, no longer a plexus component
Added --trace|-X support to show more logging output

Added:
    geronimo/gshell/trunk/gshell-model/src/test/java/org/apache/geronimo/gshell/model/application/TestBranding.java
      - copied, changed from r659770, geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Branding.java
Removed:
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/
    geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteBrandingProxy.java
Modified:
    geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
    geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties
    geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/FileHistory.java
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Application.java
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Branding.java
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/plugin/Plugin.java
    geronimo/gshell/trunk/gshell-model/src/test/resources/org/apache/geronimo/gshell/model/application/application1.xml
    geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java

Modified: geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/application.xml Wed May 28
22:30:17 2008
@@ -73,6 +73,10 @@
         </dependencyGroup>
     </dependencyGroups>
 
+    <branding>
+        <name>gshell</name>
+    </branding>
+
     <layout>
         <nodes>
             <command>

Modified: geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/underlay/etc/gsh-log4j.properties Wed May
28 22:30:17 2008
@@ -21,7 +21,7 @@
 ## $Rev$ $Date$
 ##
 
-log4j.rootCategory=DEBUG, CONSOLE, FILE
+log4j.rootCategory=${gshell.log.console.level}, CONSOLE, FILE
 
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
 log4j.appender.CONSOLE.Target=System.out
@@ -33,7 +33,7 @@
 log4j.appender.FILE=org.apache.log4j.FileAppender
 log4j.appender.FILE.File=${gshell.home}/log/gshell.log
 log4j.appender.FILE.Append=false
-log4j.appender.FILE.Threshold=DEBUG
+log4j.appender.FILE.Threshold=${gshell.log.console.level}
 log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
 log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p (%t) [%c] %m%n
 

Modified: geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Wed May 28 22:30:17 2008
@@ -24,20 +24,15 @@
 import org.apache.geronimo.gshell.GShellBuilder;
 import org.apache.geronimo.gshell.ansi.ANSI;
 import org.apache.geronimo.gshell.application.ApplicationLocator;
-import org.apache.geronimo.gshell.branding.Branding;
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.clp.CommandLineProcessor;
 import org.apache.geronimo.gshell.clp.Option;
 import org.apache.geronimo.gshell.clp.Printer;
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.model.application.Application;
+import org.apache.geronimo.gshell.model.application.Branding;
 import org.apache.geronimo.gshell.model.settings.Settings;
 import org.apache.geronimo.gshell.settings.SettingsLocator;
-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 java.util.ArrayList;
@@ -94,7 +89,7 @@
     	}
     }
     
-    @Option(name="-d", aliases={"--debug"}, description="Enable DEBUG logging output")
+    @Option(name="-d", aliases={"--debug"}, description="Enable DEBUG output")
     private void setDebug(boolean flag) {
         if (flag) {
             setConsoleLogLevel("DEBUG");
@@ -102,7 +97,15 @@
         }
     }
 
-    @Option(name="-v", aliases={"--verbose"}, description="Enable INFO logging output")
+    @Option(name="-X", aliases={"--trace"}, description="Enable TRACE output")
+    private void setTrace(boolean flag) {
+        if (flag) {
+            setConsoleLogLevel("TRACE");
+            io.setVerbosity(IO.Verbosity.DEBUG);
+        }
+    }
+
+    @Option(name="-v", aliases={"--verbose"}, description="Enable INFO output")
     private void setVerbose(boolean flag) {
         if (flag) {
             setConsoleLogLevel("INFO");
@@ -110,7 +113,7 @@
         }
     }                                                 
 
-    @Option(name="-q", aliases={"--quiet"}, description="Limit logging output to ERROR")
+    @Option(name="-q", aliases={"--quiet"}, description="Limit output to ERROR")
     private void setQuiet(boolean flag) {
         if (flag) {
             setConsoleLogLevel("ERROR");
@@ -172,15 +175,6 @@
         System.setProperty("jline.terminal", type);
     }
 
-    private PlexusContainer createContainer() throws PlexusContainerException {
-        // Boot up the container
-        ContainerConfiguration config = new DefaultContainerConfiguration();
-        config.setName("gshell.core");
-        config.setClassWorld(classWorld);
-
-        return new DefaultPlexusContainer(config);
-    }
-
     public void boot(final String[] args) throws Exception {
         assert args != null;
 
@@ -191,41 +185,6 @@
         clp.setStopAtNonOption(true);
         clp.process(args);
 
-        //
-        // HACK: We need the dang branding...
-        //
-
-        Branding branding = null;
-        if (help || version) {
-            PlexusContainer container = createContainer();
-            branding = (Branding) container.lookup(Branding.class);
-        }
-
-        //
-        // TODO: Use methods to handle these...
-        //
-
-        if (help) {
-            io.out.println(branding.getProgramName() + " [options] <command> [args]");
-            io.out.println();
-
-            Printer printer = new Printer(clp);
-            printer.printUsage(io.out);
-
-            io.out.println();
-            io.out.flush();
-
-            System.exit(ExitNotification.DEFAULT_CODE);
-        }
-
-        if (version) {
-            io.out.println(branding.getVersion());
-            io.out.println();
-            io.out.flush();
-
-            System.exit(ExitNotification.DEFAULT_CODE);
-        }
-
         // Setup a refereence for our exit code so our callback thread can tell if we've
shutdown normally or not
         final AtomicReference<Integer> codeRef = new AtomicReference<Integer>();
         int code = ExitNotification.DEFAULT_CODE;
@@ -259,6 +218,30 @@
             Application application = new ApplicationLocator().locate();
             builder.setApplication(application);
 
+            //
+            // HACK: --help and --version need access to the application's branding information,
so we have to handle these options late
+            //
+            if (help|version) {
+                Branding branding = application.getBranding();
+
+                if (help) {
+                    io.out.println(branding.getProgramName() + " [options] <command>
[args]");
+                    io.out.println();
+
+                    Printer printer = new Printer(clp);
+                    printer.printUsage(io.out);
+                }
+
+                if (version) {
+                    io.out.println(branding.getVersion());
+                }
+
+                io.out.println();
+                io.out.flush();
+
+                throw new ExitNotification();
+            }
+
             // Build the shell instance
             GShell gshell = builder.build();
 

Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
Wed May 28 22:30:17 2008
@@ -21,7 +21,6 @@
 
 import org.apache.geronimo.gshell.ansi.Code;
 import org.apache.geronimo.gshell.ansi.Renderer;
-import org.apache.geronimo.gshell.branding.Branding;
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.command.CommandSupport;
@@ -34,6 +33,7 @@
 import org.apache.geronimo.gshell.model.layout.Node;
 import org.apache.geronimo.gshell.registry.CommandRegistry;
 import org.apache.geronimo.gshell.registry.NotRegisteredException;
+import org.apache.geronimo.gshell.application.ApplicationManager;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -46,13 +46,13 @@
     extends CommandSupport
 {
     @Requirement
-    private CommandRegistry commandRegistry;
+    private ApplicationManager applicationManager;
 
     @Requirement
-    private LayoutManager layoutManager;
+    private CommandRegistry commandRegistry;
 
     @Requirement
-    private Branding branding;
+    private LayoutManager layoutManager;
 
     @Argument(metaVar="COMMAND", description="Display help for COMMAND")
     private String command;
@@ -62,10 +62,9 @@
     public HelpCommand() {
     }
 
-    public HelpCommand(CommandRegistry commandRegistry, LayoutManager layoutManager, Branding
branding) {
+    public HelpCommand(CommandRegistry commandRegistry, LayoutManager layoutManager) {
         this.commandRegistry = commandRegistry;
         this.layoutManager = layoutManager;
-        this.branding = branding;
     }
 
     protected Object doExecute() throws Exception {
@@ -82,8 +81,13 @@
     }
 
     private void displayAvailableCommands() throws Exception {
-        io.out.print(branding.getAbout());
-        io.out.println();
+        String about = applicationManager.getContext().getApplication().getBranding().getAboutMessage();
+
+        if (about != null) {
+            io.out.print(about);
+            io.out.println();
+        }
+
         io.out.println("Available commands:");
 
         GroupNode group = layoutManager.getLayout();

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
Wed May 28 22:30:17 2008
@@ -23,14 +23,13 @@
 import org.apache.geronimo.gshell.ansi.Renderer;
 import org.apache.geronimo.gshell.application.ApplicationContext;
 import org.apache.geronimo.gshell.application.ApplicationManager;
-import org.apache.geronimo.gshell.branding.Branding;
 import org.apache.geronimo.gshell.command.CommandExecutor;
 import org.apache.geronimo.gshell.console.Console;
 import org.apache.geronimo.gshell.console.Console.ErrorHandler;
 import org.apache.geronimo.gshell.console.Console.Prompter;
-import org.apache.geronimo.gshell.console.FileHistory;
 import org.apache.geronimo.gshell.console.JLineConsole;
 import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.model.application.Branding;
 import org.apache.geronimo.gshell.shell.Environment;
 import org.apache.geronimo.gshell.shell.InteractiveShell;
 import org.apache.geronimo.gshell.shell.Shell;
@@ -66,9 +65,6 @@
     private ShellInfo shellInfo;
 
     @Requirement
-    private Branding branding;
-
-    @Requirement
     private CommandExecutor executor;
 
     @Requirement
@@ -78,22 +74,22 @@
 
     private IO io;
 
+    private Branding branding;
+
     private Prompter prompter;
 
     private ErrorHandler errorHandler;
 
     public DefaultShell() {}
     
-    public DefaultShell(final ApplicationManager applicationManager, final ShellInfo shellInfo,
final Branding branding, final CommandExecutor executor, final History history) {
+    public DefaultShell(final ApplicationManager applicationManager, final ShellInfo shellInfo,
final CommandExecutor executor, final History history) {
         assert applicationManager != null;
         assert shellInfo != null;
-        assert branding != null;
         assert executor != null;
         assert history != null;
 
         this.applicationManager = applicationManager;
         this.shellInfo = shellInfo;
-        this.branding = branding;
         this.executor = executor;
         this.history = history;
     }
@@ -109,10 +105,11 @@
     public void initialize() throws InitializationException {
         assert applicationManager != null;
         
-        // Get IO/Env from application context
+        // Dereference some bits from the applciation context
         ApplicationContext context = applicationManager.getContext();
         this.io = context.getIo();
         this.env = context.getEnvironment();
+        this.branding = context.getApplication().getBranding();
         
         //
         // FIXME: This won't work as desired, as this shell instance is not yet registered,
so if a profile
@@ -159,7 +156,7 @@
         log.debug("Starting interactive console; args: {}", args);
 
         assert branding != null;
-        loadUserScript(branding.getInteractiveScriptName());
+        loadUserScript(branding.getInteractiveScriptFile());
 
         // Setup 2 final refs to allow our executor to pass stuff back to us
         final AtomicReference<ExitNotification> exitNotifHolder = new AtomicReference<ExitNotification>();
@@ -195,14 +192,18 @@
         console.setErrorHandler(getErrorHandler());
 
         // Hook up a nice history file (we gotta hold on to the history object at some point
so the 'history' command can get to it) 
-        if (history == null) {
-            history = new FileHistory(branding);
-        }
         console.setHistory(history);
 
         // Unless the user wants us to shut up, then display a nice welcome banner
         if (!io.isQuiet()) {
-            io.out.println(branding.getWelcomeBanner());
+            String message = branding.getWelcomeMessage();
+            if (message != null) {
+                io.out.println(message);
+            }
+
+            //
+            // TODO: Render a nice line here if the branding has some property configured
to enable it (move that bit out of branding's job)
+            //
         }
 
         // Check if there are args, and run them and then enter interactive
@@ -339,8 +340,8 @@
         assert branding != null;
 
         // Load profile scripts if they exist
-        loadSharedScript(branding.getProfileScriptName());
-        loadUserScript(branding.getProfileScriptName());
+        loadSharedScript(branding.getSharedProfileScriptFile());
+        loadUserScript(branding.getUserProfileScriptFile());
     }
 
     private void loadScript(final File file) throws Exception {
@@ -365,10 +366,8 @@
         }
     }
 
-    private void loadUserScript(final String fileName) throws Exception {
-        assert fileName != null;
-
-        File file = new File(branding.getUserDirectory(), fileName);
+    private void loadUserScript(final File file) throws Exception {
+        assert file != null;
 
         if (file.exists()) {
             log.debug("Loading user-script: {}", file);
@@ -380,10 +379,8 @@
         }
     }
 
-    private void loadSharedScript(final String fileName) throws Exception {
-        assert fileName != null;
-
-        File file = new File(branding.getSharedDirectory(), fileName);
+    private void loadSharedScript(final File file) throws Exception {
+        assert file != null;
 
         if (file.exists()) {
             log.debug("Loading shared-script: {}", file);

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
Wed May 28 22:30:17 2008
@@ -19,7 +19,6 @@
 
 package org.apache.geronimo.gshell;
 
-import org.apache.geronimo.gshell.branding.Branding;
 import org.apache.geronimo.gshell.shell.ShellInfo;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
@@ -44,19 +43,12 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @Requirement
-    private Branding branding;
-
     private InetAddress localHost;
 
     private File homeDir;
 
     public DefaultShellInfo() {}
     
-    public DefaultShellInfo(final Branding branding) {
-        this.branding = branding;
-    }
-
     public File getHomeDir() {
         if (homeDir == null) {
             throw new IllegalStateException();
@@ -91,7 +83,11 @@
     }
     
     private File detectHomeDir() throws InitializationException {
-        String homePath = branding.getProperty(Branding.HOME);
+        //
+        // FIXME:
+        //
+
+        String homePath = null; // branding.getProperty(Branding.HOME);
 
         if (homePath == null) {
             //

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/FileHistory.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/FileHistory.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/FileHistory.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/FileHistory.java
Wed May 28 22:30:17 2008
@@ -20,9 +20,11 @@
 package org.apache.geronimo.gshell.console;
 
 import jline.History;
-import org.apache.geronimo.gshell.branding.Branding;
+import org.apache.geronimo.gshell.application.ApplicationManager;
 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;
 import org.slf4j.LoggerFactory;
 
@@ -34,31 +36,27 @@
  *
  * @version $Rev: 573669 $ $Date: 2007-09-07 11:47:20 -0700 (Fri, 07 Sep 2007) $
  */
-@Component(role=History.class, hint="default")
+@Component(role=History.class, hint="default") // FIXME: should really be "file" here, or
rename to DefaultHistory (or sub-class for DefaultHistory support)
 public class FileHistory
     extends History
+    implements Initializable
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Requirement
-    private Branding branding;
+    private ApplicationManager applicationManager;
 
     public FileHistory() {}
 
-    public FileHistory(final Branding branding) throws IOException {
-        this.branding = branding;
-
-        initialize();
-    }
-
-    public void initialize() throws IOException {
-        assert branding != null;
-
-        //
-        // FIXME: Branding should just expose getHistoryFile() that handles this
-        //
+    public void initialize() throws InitializationException {
+        assert applicationManager != null;
         
-        setHistoryFile(new File(branding.getUserDirectory(), branding.getHistoryFileName()));
+        try {
+            setHistoryFile(applicationManager.getContext().getApplication().getBranding().getHistoryFile());
+        }
+        catch (IOException e) {
+            throw new InitializationException("Failed to set history file", e);
+        }
     }
 
     public void setHistoryFile(final File file) throws IOException {

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java
Wed May 28 22:30:17 2008
@@ -27,8 +27,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-
 /**
  * Default implementation of the {@link SettingsManager} component.
  *

Modified: geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Application.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Application.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Application.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Application.java
Wed May 28 22:30:17 2008
@@ -51,8 +51,6 @@
 
     private Layout layout;
 
-    // TODO: Paths
-
     public LocalRepository getLocalRepository() {
         return localRepository;
     }
@@ -90,21 +88,21 @@
     }
 
     public List<Dependency> dependencies() {
-        return dependencies(false);
-    }
-
-    public List<Dependency> dependencies(boolean includeGroups) {
         if (dependencies == null) {
             dependencies = new ArrayList<Dependency>();
         }
 
+        return dependencies;
+    }
+
+    public List<Dependency> dependencies(boolean includeGroups) {
         if (!includeGroups) {
-            return dependencies;
+            return dependencies();
         }
 
         List<Dependency> list = new ArrayList<Dependency>();
 
-        list.addAll(dependencies);
+        list.addAll(dependencies());
 
         for (DependencyGroup group : dependencyGroups()) {
             list.addAll(group.dependencies());
@@ -120,6 +118,10 @@
     }
 
     public Branding getBranding() {
+        if (branding == null) {
+            throw new IllegalStateException("Missing 'branding' configuration");
+        }
+        
         return branding;
     }
 
@@ -134,4 +136,16 @@
     public void setLayout(final Layout layout) {
         this.layout = layout;
     }
+
+    /**
+     * Link children to their parent when deserializing.
+     */
+    @SuppressWarnings({"UnusedDeclaration"})
+    private Object readResolve() {
+        if (branding != null) {
+            branding.setParent(this);
+        }
+
+        return this;
+    }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Branding.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Branding.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Branding.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Branding.java
Wed May 28 22:30:17 2008
@@ -21,6 +21,10 @@
 
 import com.thoughtworks.xstream.annotations.XStreamAlias;
 import org.apache.geronimo.gshell.model.common.ModelElement;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.Properties;
+import java.io.File;
 
 /**
  * Branding configuration element.
@@ -31,5 +35,214 @@
 public class Branding
     extends ModelElement
 {
-    // ???
+    //
+    // TODO: Provide some linkage to parent
+    //
+
+    private transient Application parent;
+
+    private Properties properties;
+
+    private String name;
+
+    private String displayName;
+
+    private String programName;
+
+    private String version;
+
+    private String userDirectory;
+
+    private String sharedDirectory;
+
+    private String profileScriptName;
+
+    private String historyFileName;
+
+    private String interactiveScriptName;
+
+    private String aboutMessage;
+
+    private String welcomeMessage;
+
+    private String goodbyeMessage;
+
+    public Application getParent() {
+        if (parent == null) {
+            throw new IllegalStateException("Not attached to parent");
+        }
+
+        return parent;
+    }
+
+    public void setParent(final Application parent) {
+        this.parent = parent;
+    }
+
+    public String getName() {
+        if (name == null) {
+            return getParent().getArtifactId();
+        }
+
+        return name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    public String getDisplayName() {
+        if (displayName == null) {
+            return StringUtils.capitalise(getName());
+        }
+
+        return displayName;
+    }
+
+    public void setDisplayName(final String displayName) {
+        this.displayName = displayName;
+    }
+
+    public String getProgramName() {
+        if (programName == null) {
+            return System.getProperty("program.name", getName());
+        }
+        
+        return programName;
+    }
+
+    public void setProgramName(final String programName) {
+        this.programName = programName;
+    }
+
+    public String getVersion() {
+        if (version == null) {
+            return getParent().getVersion();
+        }
+
+        return version;
+    }
+
+    public void setVersion(final String version) {
+        this.version = version;
+    }
+
+    //
+    // TODO: Add type File accessors, need to rename these, so the accessor can be *File
or *Directory
+    //
+
+    public String getUserDirectory() {
+        if (userDirectory == null) {
+            File userHome = new File(System.getProperty("user.home"));
+            File dir = new File(userHome, "." + getName());
+
+            return dir.getAbsolutePath();
+        }
+
+        return userDirectory;
+    }
+
+    public void setUserDirectory(final String userDirectory) {
+        this.userDirectory = userDirectory;
+    }
+
+    public String getSharedDirectory() {
+        //
+        // TODO: Default this to root under the application's directory
+        //
+
+        return sharedDirectory;
+    }
+
+    public void setSharedDirectory(final String sharedDirectory) {
+        this.sharedDirectory = sharedDirectory;
+    }
+
+    public String getProfileScriptName() {
+        if (profileScriptName == null) {
+            return getName() + ".profile";
+        }
+
+        return profileScriptName;
+    }
+
+    public File getUserProfileScriptFile() {
+        return new File(getUserDirectory(), getProfileScriptName());
+    }
+
+    public File getSharedProfileScriptFile() {
+        return new File(getSharedDirectory(), getProfileScriptName());
+    }
+
+    public void setProfileScriptName(final String profileScriptName) {
+        this.profileScriptName = profileScriptName;
+    }
+
+    public String getHistoryFileName() {
+        if (historyFileName == null) {
+            return getName() + ".history";
+        }
+
+        return historyFileName;
+    }
+
+    public File getHistoryFile() {
+        return new File(getUserDirectory(), getHistoryFileName());
+    }
+    
+    public void setHistoryFileName(final String historyFileName) {
+        this.historyFileName = historyFileName;
+    }
+
+    public String getInteractiveScriptName() {
+        if (interactiveScriptName == null) {
+            return getName() + ".rc";
+        }
+
+        return interactiveScriptName;
+    }
+
+    public File getInteractiveScriptFile() {
+        return new File(getUserDirectory(), getInteractiveScriptName());
+    }
+
+    public void setInteractiveScriptName(final String interactiveScriptName) {
+        this.interactiveScriptName = interactiveScriptName;
+    }
+
+    public String getAboutMessage() {
+        return aboutMessage;
+    }
+
+    public void setAboutMessage(final String aboutMessage) {
+        this.aboutMessage = aboutMessage;
+    }
+
+    public String getWelcomeMessage() {
+        return welcomeMessage;
+    }
+
+    public void setWelcomeMessage(final String welcomeMessage) {
+        this.welcomeMessage = welcomeMessage;
+    }
+
+    public String getGoodbyeMessage() {
+        return goodbyeMessage;
+    }
+
+    public void setGoodbyeMessage(final String goodbyeMessage) {
+        this.goodbyeMessage = goodbyeMessage;
+    }
+
+    public Properties getProperties() {
+        if (properties == null) {
+            properties = new Properties();
+        }
+        
+        return properties;
+    }
+
+    public void setProperties(final Properties properties) {
+        this.properties = properties;
+    }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/plugin/Plugin.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/plugin/Plugin.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/plugin/Plugin.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/plugin/Plugin.java
Wed May 28 22:30:17 2008
@@ -69,21 +69,21 @@
     }
 
     public List<Dependency> dependencies() {
-        return dependencies(false);
-    }
-
-    public List<Dependency> dependencies(boolean includeGroups) {
         if (dependencies == null) {
             dependencies = new ArrayList<Dependency>();
         }
 
+        return dependencies;
+    }
+
+    public List<Dependency> dependencies(boolean includeGroups) {
         if (!includeGroups) {
-            return dependencies;
+            return dependencies();
         }
 
         List<Dependency> list = new ArrayList<Dependency>();
 
-        list.addAll(dependencies);
+        list.addAll(dependencies());
 
         for (DependencyGroup group : dependencyGroups()) {
             list.addAll(group.dependencies());

Copied: geronimo/gshell/trunk/gshell-model/src/test/java/org/apache/geronimo/gshell/model/application/TestBranding.java
(from r659770, geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Branding.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/test/java/org/apache/geronimo/gshell/model/application/TestBranding.java?p2=geronimo/gshell/trunk/gshell-model/src/test/java/org/apache/geronimo/gshell/model/application/TestBranding.java&p1=geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Branding.java&r1=659770&r2=661216&rev=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/application/Branding.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/test/java/org/apache/geronimo/gshell/model/application/TestBranding.java
Wed May 28 22:30:17 2008
@@ -19,17 +19,13 @@
 
 package org.apache.geronimo.gshell.model.application;
 
-import com.thoughtworks.xstream.annotations.XStreamAlias;
-import org.apache.geronimo.gshell.model.common.ModelElement;
-
 /**
- * Branding configuration element.
+ * ???
  *
  * @version $Rev$ $Date$
  */
-@XStreamAlias("branding")
-public class Branding
-    extends ModelElement
+public class TestBranding
+    extends Branding
 {
-    // ???
+    private String customThingy;
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-model/src/test/resources/org/apache/geronimo/gshell/model/application/application1.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/test/resources/org/apache/geronimo/gshell/model/application/application1.xml?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/test/resources/org/apache/geronimo/gshell/model/application/application1.xml
(original)
+++ geronimo/gshell/trunk/gshell-model/src/test/resources/org/apache/geronimo/gshell/model/application/application1.xml
Wed May 28 22:30:17 2008
@@ -67,6 +67,17 @@
         </dependencyGroup>
     </dependencyGroups>
 
+    <!--
+    <branding class="org.apache.geronimo.gshell.model.application.TestBranding">
+        <programName>foo</programName>
+        <customThingy>bar</customThingy>
+    </branding>
+    -->
+
+    <branding>
+        <programName>foo</programName>
+    </branding>
+
     <layout>
         <nodes>
             <command>

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java?rev=661216&r1=661215&r2=661216&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/proxy/RemoteShellProxy.java
Wed May 28 22:30:17 2008
@@ -59,8 +59,6 @@
 
     private RemoteHistoryProxy history;
 
-    private RemoteBrandingProxy branding;
-
     public RemoteShellProxy(final RshClient client, final IO io) throws Exception {
         assert client != null;
         assert io != null;
@@ -79,7 +77,6 @@
         env = new RemoteEnvironmentProxy(client);
         shellInfo = new RemoteShellInfoProxy(client);
         history = new RemoteHistoryProxy(client);
-        branding = new RemoteBrandingProxy(client);
 
         // Copy the client's input stream to our outputstream so users see command output
         outputFeeder = new StreamFeeder(client.getInputStream(), io.outputStream);



Mime
View raw message