geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r575237 - in /geronimo/server/trunk/modules/geronimo-commands: pom.xml src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java src/main/resources/org/apache/geronimo/commands/version.properties
Date Thu, 13 Sep 2007 09:31:18 GMT
Author: jdillon
Date: Thu Sep 13 02:31:18 2007
New Revision: 575237

URL: http://svn.apache.org/viewvc?rev=575237&view=rev
Log:
Add custom branding

Added:
    geronimo/server/trunk/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java
  (with props)
    geronimo/server/trunk/modules/geronimo-commands/src/main/resources/org/apache/geronimo/commands/version.properties
  (with props)
Modified:
    geronimo/server/trunk/modules/geronimo-commands/pom.xml

Modified: geronimo/server/trunk/modules/geronimo-commands/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-commands/pom.xml?rev=575237&r1=575236&r2=575237&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-commands/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-commands/pom.xml Thu Sep 13 02:31:18 2007
@@ -55,6 +55,12 @@
             <artifactId>gshell-command-api</artifactId>
         </dependency>
         
+        <!-- For branding -->
+        <dependency>
+            <groupId>org.apache.geronimo.gshell</groupId>
+            <artifactId>gshell-core</artifactId>
+        </dependency>
+        
         <dependency>
             <groupId>org.codehaus.groovy</groupId>
             <artifactId>groovy-all</artifactId>
@@ -64,6 +70,36 @@
     <build>
         <sourceDirectory>${pom.basedir}/src/main/groovy</sourceDirectory>
         
+        <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/commands/version.properties</include>
+                </includes>
+            </resource>
+        </resources>
+        
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.codehaus.plexus</groupId>
+                    <artifactId>plexus-java5-maven-plugin</artifactId>
+                    <version>1.0-SNAPSHOT</version>
+                    <configuration>
+                        <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+        
         <plugins>
             <plugin>
                 <groupId>org.codehaus.mojo.groovy</groupId>
@@ -76,8 +112,21 @@
                     </execution>
                 </executions>
             </plugin>
+            
+            <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>
 

Added: geronimo/server/trunk/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java?rev=575237&view=auto
==============================================================================
--- geronimo/server/trunk/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java
(added)
+++ geronimo/server/trunk/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java
Thu Sep 13 02:31:18 2007
@@ -0,0 +1,138 @@
+/*
+ * 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.commands;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.geronimo.gshell.ansi.Buffer;
+import org.apache.geronimo.gshell.ansi.Code;
+import org.apache.geronimo.gshell.ansi.RenderWriter;
+import org.apache.geronimo.gshell.branding.Branding;
+import org.apache.geronimo.gshell.branding.BrandingSupport;
+import org.apache.geronimo.gshell.branding.VersionLoader;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.IOUtil;
+
+import jline.Terminal;
+
+/**
+ * Provides the branding for Geronimo usage of GShell.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=Branding.class, hint="geronimo")
+public class GeronimoBranding
+    extends BrandingSupport
+{
+    //
+    // FIXME: This needs work before it can really be used...
+    //
+    
+    // @Requirement
+    // private VersionLoader versionLoader;
+
+    @Requirement
+    private Terminal terminal;
+
+    //
+    // FIXME: Don't override this... leave things as 'gshell' until we have more use-cases
for branding fluff
+    //
+    
+    public String getName() {
+        return "gshell";
+    }
+    
+    public String getDisplayName() {
+        return "Apache Geronimo";
+    }
+
+    public String getProgramName() {
+        //
+        // FIXME: For now we leave this as 'gsh' ...
+        //
+        return System.getProperty("program.name", "gsh");
+    }
+
+    public String getAbout() {
+        StringWriter writer = new StringWriter();
+        PrintWriter out = new RenderWriter(writer);
+
+        out.println("For information about @|cyan " + getDisplayName() + "|, visit:");
+        out.println("    @|bold http://geronimo.apache.org| ");
+        out.flush();
+
+        return writer.toString();
+    }
+
+    //
+    // HACK: Just duplicating the PropertiesVersionLoader here for now
+    //
+    
+    private Properties props;
+
+    public String getVersion() {
+        if (props == null) {
+            String resourceName = "version.properties";
+            InputStream input = getClass().getResourceAsStream(resourceName);
+            assert input != null;
+
+            try {
+                props = new Properties();
+                props.load(input);
+            }
+            catch (IOException e) {
+                throw new RuntimeException("Failed to load: " + resourceName, e);
+            }
+            finally {
+                IOUtil.close(input);
+            }
+        }
+        
+        return props.getProperty("version");
+    }
+
+    public String getWelcomeBanner() {
+        StringWriter writer = new StringWriter();
+        PrintWriter out = new RenderWriter(writer);
+
+        out.println("@|bold " + getDisplayName() + "| (" + getVersion() + ")");
+        out.println();
+        out.println("Type '@|bold help|' for more information.");
+
+        // If we can't tell, or have something bogus then use a reasonable default
+        int width = terminal.getTerminalWidth();
+        if (width < 1) {
+            width = 80;
+        }
+        
+        out.print(StringUtils.repeat("-", width - 1));
+
+        out.flush();
+
+        return writer.toString();
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-commands/src/main/resources/org/apache/geronimo/commands/version.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-commands/src/main/resources/org/apache/geronimo/commands/version.properties?rev=575237&view=auto
==============================================================================
--- geronimo/server/trunk/modules/geronimo-commands/src/main/resources/org/apache/geronimo/commands/version.properties
(added)
+++ geronimo/server/trunk/modules/geronimo-commands/src/main/resources/org/apache/geronimo/commands/version.properties
Thu Sep 13 02:31:18 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=${version}

Propchange: geronimo/server/trunk/modules/geronimo-commands/src/main/resources/org/apache/geronimo/commands/version.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-commands/src/main/resources/org/apache/geronimo/commands/version.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/modules/geronimo-commands/src/main/resources/org/apache/geronimo/commands/version.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message