.classpath
| 2
etc/eclipse-tools/maven/RHQ
| 11
modules/common/filetemplate-bundle/pom.xml
| 37 ++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigdefRecipeCommand.java
| 69 +++++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/DeployRecipeCommand.java
| 76 +++++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeCommand.java
| 42 +++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
| 45 +++
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java
| 127 ++++++++++
modules/common/pom.xml
| 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
| 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
| 4
modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
| 37 ++
modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
| 32 ++
modules/plugins/filetemplate-bundle/pom.xml
| 13 -
14 files changed, 488 insertions(+), 13 deletions(-)
New commits:
commit 7f70926f340987e7808652cce688769dca1eac0e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 1 14:27:00 2010 -0500
stub the useage of parse results
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
index c810a97..ba53759 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
@@ -40,13 +40,15 @@ public class RecipeParseResults {
/** The set of bundle files that make up the bundle (version) as specified in the
recipe commands */
private Set<String> bundleFileNames;
- private RecipeParseResults(ConfigurationDefinition configDef, Set<String>
bundleFileNames) {
+ public RecipeParseResults(ConfigurationDefinition configDef, Set<String>
bundleFileNames) {
this.configDef = configDef;
this.bundleFileNames = bundleFileNames;
}
public ConfigurationDefinition getConfigDef() {
+
// stub out a test ConfigDef here until we actual parse the recipe
+ System.out.println("!!!!!! REMOVE THIS TEST CODE !!!!!!!!");
configDef = new ConfigurationDefinition("SampleBundle", "Stubbed
ConfigDef for Sample Bundle");
configDef.put(new
PropertyDefinitionSimple("sample.bundle.deploy.directory",
"Stubbed Property for deploy directory (must already exist on target
platform)", true,
@@ -62,6 +64,7 @@ public class RecipeParseResults {
public Set<String> getBundleFileNames() {
// stub out a test set of BundleFiles here until we actual parse the recipe. For
now lets just deploy
// a war file into an existing app server dir.
+ System.out.println("!!!!!! REMOVE THIS TEST CODE !!!!!!!!");
bundleFileNames = new HashSet<String>();
bundleFileNames.add("sample-bundle.war");
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
index 2bf4719..a2d6b96 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
@@ -19,12 +19,13 @@
package org.rhq.enterprise.server.plugin.pc.bundle;
+import org.rhq.enterprise.server.bundle.RecipeParseResults;
+
/**
* All bundle server plugins must implement this facet.
*
* @author John Mazzitelli
*/
public interface BundleServerPluginFacet {
- // TODO return something the server/jar SLSB likes
- void parseRecipe(String recipe) throws Exception;
+ RecipeParseResults parseRecipe(String recipe) throws Exception;
}
diff --git
a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
index a1f770e..96f7070 100644
---
a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
+++
b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
@@ -19,9 +19,17 @@
package org.rhq.enterprise.server.plugins.filetemplate;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.bundle.filetemplate.recipe.RecipeContext;
import org.rhq.bundle.filetemplate.recipe.RecipeParser;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.enterprise.server.bundle.RecipeParseResults;
import org.rhq.enterprise.server.plugin.pc.ControlFacet;
import org.rhq.enterprise.server.plugin.pc.ControlResults;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
@@ -35,28 +43,38 @@ import
org.rhq.enterprise.server.plugin.pc.bundle.BundleServerPluginFacet;
*/
public class BundleServerPluginComponent implements ServerPluginComponent,
BundleServerPluginFacet, ControlFacet {
+ private final Log log = LogFactory.getLog(BundleServerPluginComponent.class);
+
private ServerPluginContext context;
public void initialize(ServerPluginContext context) throws Exception {
this.context = context;
- System.out.println("The filetemplate bundle plugin has been initialized!!! :
" + this);
+ log.debug("The filetemplate bundle plugin has been initialized!!! : " +
this);
}
public void start() {
- System.out.println("The filetemplate bundle plugin has started!!! : " +
this);
+ log.debug("The filetemplate bundle plugin has started!!! : " + this);
}
public void stop() {
- System.out.println("The filetemplate bundle plugin has stopped!!! : " +
this);
+ log.debug("The filetemplate bundle plugin has stopped!!! : " + this);
}
public void shutdown() {
- System.out.println("The filetemplate bundle plugin has been shut down!!! :
" + this);
+ log.debug("The filetemplate bundle plugin has been shut down!!! : " +
this);
}
- public void parseRecipe(String recipe) throws Exception {
+ public RecipeParseResults parseRecipe(String recipe) throws Exception {
RecipeParser parser = new RecipeParser();
- parser.parseRecipe(recipe);
+ RecipeContext parserContext = parser.parseRecipe(recipe);
+
+ // TODO convert the context to the results object
+ ConfigurationDefinition configDef = null;
+ Set<String> bundleFileNames = null;
+
+ RecipeParseResults results = new RecipeParseResults(configDef, bundleFileNames);
+ return results;
+
}
public ControlResults invoke(String name, Configuration parameters) {
commit 7210b1f604f74ac9e384715a84f7ef0fc785fcfa
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 1 13:57:49 2010 -0500
first stubbed version of the commons filetemplate bundle commons lib
diff --git a/.classpath b/.classpath
index bb17f97..c6a1ed2 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src"
path="modules/common/jboss-as/src/main/java"/>
+ <classpathentry kind="src"
path="modules/common/filetemplate-bundle/src/main/java"/>
+ <classpathentry kind="src"
path="modules/common/filetemplate-bundle/src/test/java"/>
<classpathentry kind="src"
path="modules/enterprise/gui/base-perspective-jar/src/main/java"/>
<classpathentry kind="src"
path="modules/enterprise/server/plugins/jboss-software/src/test/java"/>
<classpathentry kind="src"
path="modules/enterprise/server/plugins/jboss-software/src/main/java"/>
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build and Test - Plugin Common
Libraries.launch b/etc/eclipse-tools/maven/RHQ Maven Build and Test - Plugin Common
Libraries.launch
new file mode 100644
index 0000000..34c8c3d
--- /dev/null
+++ b/etc/eclipse-tools/maven/RHQ Maven Build and Test - Plugin Common Libraries.launch
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<launchConfiguration
type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+<stringAttribute key="bad_container_name"
value="\rhq\etc\eclipse-tools\maven"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables"
value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION"
value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"
value="-o -Dmaven.test.skip=false install"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY"
value="${workspace_loc:/rhq/modules/common}"/>
+</launchConfiguration>
diff --git a/modules/common/filetemplate-bundle/pom.xml
b/modules/common/filetemplate-bundle/pom.xml
new file mode 100644
index 0000000..e6a3107
--- /dev/null
+++ b/modules/common/filetemplate-bundle/pom.xml
@@ -0,0 +1,37 @@
+<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.rhq</groupId>
+ <artifactId>rhq-common-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <packaging>jar</packaging>
+
+ <name>RHQ File Template Bundle Plugins Common Library</name>
+ <description>A library with the code common to the agent and server plugins for
File Template Bundles</description>
+
+ <scm>
+
<
connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/comm...
+
<
developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/mod...
+ </scm>
+
+ <properties>
+
<scm.module.path>modules/common/filetemplate-bundle/</scm.module.path>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>gnu-getopt</groupId>
+ <artifactId>getopt</artifactId>
+ <!-- NOTE: The version is defined in the root POM's
dependencyManagement section. -->
+ </dependency>
+
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git
a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigdefRecipeCommand.java
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigdefRecipeCommand.java
new file mode 100644
index 0000000..057d474
--- /dev/null
+++
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigdefRecipeCommand.java
@@ -0,0 +1,69 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.bundle.filetemplate.recipe;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+public class ConfigdefRecipeCommand implements RecipeCommand {
+
+ public String getName() {
+ return "configdef";
+ }
+
+ public void parse(RecipeContext context, String[] args) {
+ String sopts = ":f:";
+ LongOpt[] lopts = { new LongOpt("file", LongOpt.REQUIRED_ARGUMENT,
null, 'f') };
+
+ String filename = null;
+
+ Getopt getopt = new Getopt(context.toString(), args, sopts, lopts);
+ int code;
+
+ while ((code = getopt.getopt()) != -1) {
+ switch (code) {
+ case ':':
+ case '?': {
+ throw new IllegalArgumentException("Bad recipe command [" +
getName() + "]: " + args);
+ }
+
+ case 1: {
+ throw new IllegalArgumentException("Bad recipe command [" +
getName() + "]: " + args);
+ }
+
+ case 'f': {
+ filename = getopt.getOptarg();
+ break;
+ }
+
+ default: {
+ throw new IllegalArgumentException("Unexpected error in recipe
command [" + getName() + "]: " + args);
+ }
+
+ }
+ }
+
+ // TODO : do something with filename
+ }
+}
diff --git
a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/DeployRecipeCommand.java
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/DeployRecipeCommand.java
new file mode 100644
index 0000000..145398c
--- /dev/null
+++
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/DeployRecipeCommand.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.bundle.filetemplate.recipe;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+public class DeployRecipeCommand implements RecipeCommand {
+
+ public String getName() {
+ return "deploy";
+ }
+
+ public void parse(RecipeContext context, String[] args) {
+ String sopts = ":f:d:";
+ LongOpt[] lopts = { new LongOpt("file", LongOpt.REQUIRED_ARGUMENT,
null, 'f'),
+ new LongOpt("directory", LongOpt.REQUIRED_ARGUMENT, null,
'd') };
+
+ String filename = null;
+ String directory = null;
+
+ Getopt getopt = new Getopt(context.toString(), args, sopts, lopts);
+ int code;
+
+ while ((code = getopt.getopt()) != -1) {
+ switch (code) {
+ case ':':
+ case '?': {
+ throw new IllegalArgumentException("Bad recipe command [" +
getName() + "]: " + args);
+ }
+
+ case 1: {
+ throw new IllegalArgumentException("Bad recipe command [" +
getName() + "]: " + args);
+ }
+
+ case 'f': {
+ filename = getopt.getOptarg();
+ break;
+ }
+
+ case 'd': {
+ directory = getopt.getOptarg();
+ break;
+ }
+
+ default: {
+ throw new IllegalArgumentException("Unexpected error in recipe
command [" + getName() + "]: " + args);
+ }
+
+ }
+ }
+
+ // TODO : do something with filename and directory
+ }
+}
diff --git
a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeCommand.java
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeCommand.java
new file mode 100644
index 0000000..7cfa964
--- /dev/null
+++
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeCommand.java
@@ -0,0 +1,42 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.bundle.filetemplate.recipe;
+
+public interface RecipeCommand {
+
+ /**
+ * The name of the recipe command. This must be the first word in the recipe line in
order for this command to be triggered.
+ *
+ * @return name of the recipe command
+ */
+ String getName();
+
+ /**
+ * Parses this recipe command and optionally puts information in the context.
+ *
+ * @param context information where the parser can store information regarding the
command that was processed
+ * @param args arguments passed to the command.
+ */
+ void parse(RecipeContext context, String[] args);
+}
diff --git
a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
new file mode 100644
index 0000000..da96ceb
--- /dev/null
+++
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.bundle.filetemplate.recipe;
+
+/**
+ * @author John Mazzitelli
+ */
+public class RecipeContext {
+
+ private final String recipe;
+
+ public RecipeContext(String recipe) {
+ this.recipe = recipe;
+ }
+
+ /**
+ * The full recipe that this context represents.
+ *
+ * @return the actual recipe text
+ */
+ public String getRecipe() {
+ return recipe;
+ }
+}
diff --git
a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java
new file mode 100644
index 0000000..ff9b91f
--- /dev/null
+++
b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeParser.java
@@ -0,0 +1,127 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.bundle.filetemplate.recipe;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StreamTokenizer;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Parses the file template recipe.
+ *
+ * @author John Mazzitelli
+ *
+ */
+public class RecipeParser {
+ private Map<String, RecipeCommand> recipeCommands;
+
+ public RecipeParser() {
+ setupRecipeCommands();
+ }
+
+ public RecipeContext parseRecipe(String recipe) throws Exception {
+ RecipeContext context = new RecipeContext(recipe);
+
+ BufferedReader recipeReader = new BufferedReader(new StringReader(recipe));
+ String line = recipeReader.readLine();
+ while (line != null) {
+ String[] commandLineArray = splitCommandLine(line);
+ String commandName = commandLineArray[0];
+ String[] arguments = extractArguments(commandLineArray);
+
+ RecipeCommand recipeCommand = recipeCommands.get(commandName);
+ if (recipeCommand == null) {
+ throw new Exception("Unknown command in recipe: " +
commandName);
+ }
+
+ recipeCommand.parse(context, arguments);
+
+ line = recipeReader.readLine();
+ }
+
+ return context;
+ }
+
+ private void setupRecipeCommands() {
+ recipeCommands = new HashMap<String, RecipeCommand>();
+
+ RecipeCommand[] knownCommands = new RecipeCommand[] { new
ConfigdefRecipeCommand(), //
+ new DeployRecipeCommand() //
+ };
+
+ for (RecipeCommand recipeCommand : knownCommands) {
+ recipeCommands.put(recipeCommand.getName(), recipeCommand);
+ }
+ }
+
+ private String[] splitCommandLine(String cmdLine) {
+ ByteArrayInputStream in = new ByteArrayInputStream(cmdLine.getBytes());
+ StreamTokenizer strtok = new StreamTokenizer(new InputStreamReader(in));
+ List<String> args = new ArrayList<String>();
+ boolean keep_going = true;
+
+ // we don't want to parse numbers and we want ' to be a normal word
character
+ strtok.ordinaryChars('0', '9');
+ strtok.ordinaryChar('.');
+ strtok.ordinaryChar('-');
+ strtok.ordinaryChar('\'');
+ strtok.wordChars(33, 127);
+ strtok.quoteChar('\"');
+
+ // parse the command line
+ while (keep_going) {
+ int nextToken;
+
+ try {
+ nextToken = strtok.nextToken();
+ } catch (IOException e) {
+ nextToken = StreamTokenizer.TT_EOF;
+ }
+
+ if (nextToken == java.io.StreamTokenizer.TT_WORD) {
+ args.add(strtok.sval);
+ } else if (nextToken == '\"') {
+ args.add(strtok.sval);
+ } else if ((nextToken == java.io.StreamTokenizer.TT_EOF) || (nextToken ==
java.io.StreamTokenizer.TT_EOL)) {
+ keep_going = false;
+ }
+ }
+
+ return args.toArray(new String[args.size()]);
+ }
+
+ private String[] extractArguments(String[] commandLine) {
+ // strip the first element (the command name) from the array, leaving only the
arguments
+ int newLength = commandLine.length - 1;
+ String[] argsOnly = new String[newLength];
+ System.arraycopy(commandLine, 1, argsOnly, 0, newLength);
+ return argsOnly;
+ }
+}
diff --git a/modules/common/pom.xml b/modules/common/pom.xml
index e9f0385..8abfe11 100644
--- a/modules/common/pom.xml
+++ b/modules/common/pom.xml
@@ -66,5 +66,6 @@
<modules>
<module>jboss-as</module>
+ <module>filetemplate-bundle</module>
</modules>
</project>
\ No newline at end of file
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
index 0585a4b..2bf4719 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
@@ -25,5 +25,6 @@ package org.rhq.enterprise.server.plugin.pc.bundle;
* @author John Mazzitelli
*/
public interface BundleServerPluginFacet {
-
+ // TODO return something the server/jar SLSB likes
+ void parseRecipe(String recipe) throws Exception;
}
diff --git a/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
b/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
index 7a19819..4a3536e 100644
--- a/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
+++ b/modules/enterprise/server/plugins/filetemplate-bundle/pom.xml
@@ -42,6 +42,12 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- 3rd Party Deps -->
<!-- TODO: This is a fix for the Javac bug requiring annotations to be
@@ -71,11 +77,37 @@
<configuration>
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
<!--
- <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
+ <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
-->
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <id>copy-rhq-plugins</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+
+ <artifactItem>
+ <groupId>org.rhq</groupId>
+
<artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <version>${project.version}</version>
+ </artifactItem>
+
+ </artifactItems>
+
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
@@ -141,7 +173,8 @@
<include name="META-INF/**"
/>
</patternset>
</unjar>
- <jar destfile="${deployment.file}"
manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
update="true">
+ <jar destfile="${deployment.file}"
manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+ update="true">
</jar>
</tasks>
</configuration>
diff --git
a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
index 58dd5b1..a1f770e 100644
---
a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
+++
b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.plugins.filetemplate;
+import org.rhq.bundle.filetemplate.recipe.RecipeParser;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.enterprise.server.plugin.pc.ControlFacet;
@@ -53,6 +54,11 @@ public class BundleServerPluginComponent implements
ServerPluginComponent, Bundl
System.out.println("The filetemplate bundle plugin has been shut down!!! :
" + this);
}
+ public void parseRecipe(String recipe) throws Exception {
+ RecipeParser parser = new RecipeParser();
+ parser.parseRecipe(recipe);
+ }
+
public ControlResults invoke(String name, Configuration parameters) {
ControlResults controlResults = new ControlResults();
if (name.equals("testControl")) {
diff --git a/modules/plugins/filetemplate-bundle/pom.xml
b/modules/plugins/filetemplate-bundle/pom.xml
index b1f18b5..93f1c4c 100644
--- a/modules/plugins/filetemplate-bundle/pom.xml
+++ b/modules/plugins/filetemplate-bundle/pom.xml
@@ -26,13 +26,17 @@
<dependencies>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<plugins>
- <!--
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
@@ -47,9 +51,9 @@
<artifactItems>
<artifactItem>
- <groupId>org.jboss</groupId>
- <artifactId>byteman</artifactId>
- <version>1.2.0</version>
+ <groupId>org.rhq</groupId>
+
<artifactId>rhq-filetemplate-bundle-common</artifactId>
+ <version>${project.version}</version>
</artifactItem>
</artifactItems>
@@ -58,7 +62,6 @@
</execution>
</executions>
</plugin>
- -->
</plugins>
</build>