geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r453468 - in /geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src: main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java site/apt/usage/server.apt
Date Fri, 06 Oct 2006 02:27:07 GMT
Author: jdillon
Date: Thu Oct  5 19:27:06 2006
New Revision: 453468

URL: http://svn.apache.org/viewvc?view=rev&rev=453468
Log:
Refactored to allow a set of optionSet id's to be used to select more than one
Removed debug* bits this can now be done with optionSets

Modified:
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage/server.apt

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java?view=diff&rev=453468&r1=453467&r2=453468
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/server/StartServerMojo.java
Thu Oct  5 19:27:06 2006
@@ -27,6 +27,9 @@
 import java.util.HashMap;
 import java.util.Properties;
 import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.util.List;
+import java.util.ArrayList;
 
 import org.apache.maven.plugin.MojoExecutionException;
 
@@ -97,24 +100,6 @@
      */
     private int verifyTimeout = -1;
 
-    //
-    // TODO: Remove this debug stuff... make it use optionSet, maybe -Ddebug=true will enable
the "debug" optionSet?
-    //
-    
-    /**
-     * JVM arguments to be applied when debug is enabled.
-     *
-     * @parameter
-     */
-    private String[] debugArguments = null;
-
-    /**
-     * Enable debug mode.  When true, debugArguments are added to the JVM.
-     *
-     * @parameter expression="${debug}" default-value="false"
-     */
-    private boolean debug = false;
-
     /**
      * An array of option sets which can be enabled by setting optionSetId.
      *
@@ -123,11 +108,11 @@
     private OptionSet[] optionSets = null;
 
     /**
-     * The optionSet to be enabled.
+     * A comma seperated list of optionSets to enabled.
      *
-     * @parameter expression="${optionSetId}"
+     * @parameter expression="${options}"
      */
-    private String optionSetId = null;
+    private String options = null;
 
     /**
      * A list of module names to be started using --override.
@@ -158,58 +143,41 @@
             java.setMaxmemory(maximumMemory);
         }
 
-        if (debug) {
-            if (debugArguments == null) {
-                throw new MojoExecutionException("To enable debug mode a set of debugArguments
needs to be configured");
-            }
-            else if (debugArguments.length == 0) {
-                throw new MojoExecutionException("At least one argument must be configured
with debugArguments");
-            }
-
-            log.info("Enabling debug JVM arguments");
-
-            for (int i=0; i < debugArguments.length; i++) {
-                java.createJvmarg().setValue(debugArguments[i]);
-            }
-        }
-
         // Apply option sets
-        if (optionSetId != null  && (optionSets == null || optionSets.length == 0))
{
-            throw new MojoExecutionException("At least one optionSet must be defined to select
one using optionSetId");
+        if (options != null  && (optionSets == null || optionSets.length == 0)) {
+            throw new MojoExecutionException("At least one optionSet must be defined to select
one using options");
         }
-        else if (optionSetId == null) {
-            optionSetId = "default";
+        else if (options == null) {
+            options = "default";
         }
         
         if (optionSets != null && optionSets.length != 0) {
-            //
-            // TODO: Support selecting a comma seperated list of optionSet ids
-            //
-            
-            OptionSet set = selectOptionSet(optionSetId);
+            OptionSet[] sets = selectOptionSets();
 
-            if (log.isDebugEnabled()) {
-                log.debug("Selected option set: " + set);
-            }
-            else {
-                log.info("Selected option set: " + optionSetId);    
-            }
+            for (int i=0; i < sets.length; i++) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Selected option set: " + sets[i]);
+                }
+                else {
+                    log.info("Selected option set: " + sets[i].getId());
+                }
 
-            String[] options = set.getOptions();
-            if (options != null) {
-                for (int i=0; i<options.length; i++) {
-                    java.createJvmarg().setValue(options[i]);
+                String[] options = sets[i].getOptions();
+                if (options != null) {
+                    for (int j=0; j < options.length; j++) {
+                        java.createJvmarg().setValue(options[j]);
+                    }
                 }
-            }
 
-            Properties props = set.getProperties();
-            if (props != null) {
-                Iterator iter = props.keySet().iterator();
-                while (iter.hasNext()) {
-                    String name = (String)iter.next();
-                    String value = props.getProperty(name);
+                Properties props = sets[i].getProperties();
+                if (props != null) {
+                    Iterator iter = props.keySet().iterator();
+                    while (iter.hasNext()) {
+                        String name = (String)iter.next();
+                        String value = props.getProperty(name);
 
-                    setSystemProperty(java, name, value);
+                        setSystemProperty(java, name, value);
+                    }
                 }
             }
         }
@@ -343,7 +311,7 @@
         return System.getProperty(name) + File.pathSeparator + file.getPath();
     }
 
-    private OptionSet selectOptionSet(final String targetId) throws MojoExecutionException
{
+    private OptionSet[] selectOptionSets() throws MojoExecutionException {
         // Make a map of the option sets and validate ids
         Map map = new HashMap();
         for (int i=0; i<optionSets.length; i++) {
@@ -361,23 +329,36 @@
                 optionSets[i].setId(id);
             }
 
+            assert id != null;
+            id = id.trim();
+
             if (map.containsKey(id)) {
                 throw new MojoExecutionException("Must specify unique id for optionSet: "
+ id);
             }
             map.put(id, optionSets[i]);
         }
 
-        OptionSet set = (OptionSet)map.get(targetId);
-        if (set == null) {
-            if ("default".equals(targetId)) {
-                log.warn("Default optionSet selected, but no optionSet defined with that
id; ignoring");
+        StringTokenizer stok = new StringTokenizer(options, ",");
+
+        List selected = new ArrayList();
+        while (stok.hasMoreTokens()) {
+            String id = stok.nextToken();
+            OptionSet set = (OptionSet)map.get(options);
+            
+            if (set == null) {
+                if ("default".equals(options)) {
+                    log.debug("Default optionSet selected, but no optionSet defined with
that id; ignoring");
+                }
+                else {
+                    throw new MojoExecutionException("Missing optionSet for id: " + id);
+                }
             }
             else {
-                throw new MojoExecutionException("Missing optionSet for id: " + targetId);
+                selected.add(set);
             }
         }
 
-        return set;
+        return (OptionSet[]) selected.toArray(new OptionSet[selected.size()]);
     }
 
     private void setSystemProperty(final Java java, final String name, final String value)
{

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage/server.apt
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage/server.apt?view=diff&rev=453468&r1=453467&r2=453468
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage/server.apt
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/site/apt/usage/server.apt
Thu Oct  5 19:27:06 2006
@@ -132,7 +132,8 @@
 mvn geronimo:start -Dverbose=true
 +----------+
 
- Optional JVM debug arguments may be configured.
+ Optional JVM options and/or system properties can be set by configuring a set of options
+ and selecting the options to be enabled.
 
 +----------+
 <plugin>
@@ -140,19 +141,38 @@
     <artifactId>geronimo-maven-plugin</artifactId>
 
     <configuration>
-        <debugArguments>
-            <argument>-Xdebug</argument>
-            <argument>-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n</argument>
-        </debugArguments>
+        <optionSets>
+            <optionSet>
+                <id>debug</id>
+                <options>
+                    <option>-Xdebug</option>
+                    <option>-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n</option>
+                </options>
+            </optionSet>
+
+            <optionSet>
+                <id>other</id>
+                <properties>
+                    <property>
+                        <name>foo</name>
+                        <value>bar</value>
+                    </property>
+                </properties>
+            </optionSet>
+        </optionSets>
     </configuration>
 </plugin>
 +----------+
 
- By setting the <<<debug>>> parameter the JVM will be started in debug
mode.
+ Option sets may be selected by configuring the <<<options>>> parameter
with a comma seperated
+ list of <<<optionSet>>> ids.  To enable a set of options to be enabled
by default, then
+ configure an <<<optionSet>>> with the id of <<<default>>>
and omit the <<<options>>> parameter.
  
 +----------+
-mvn geronimo:start -Ddebug=true
+mvn geronimo:start -Doptions=debug,other
 +----------+
+
+* Waiting for a Geronimo Server
 
  If you already have a server started and just need to wait until the server has started:
 



Mime
View raw message