Package org.jclouds.scriptbuilder
Class ScriptBuilder
- java.lang.Object
-
- org.jclouds.scriptbuilder.ScriptBuilder
-
- All Implemented Interfaces:
AcceptsStatementVisitor
,Statement
public class ScriptBuilder extends Object implements Statement, AcceptsStatementVisitor
Creates a shell script.
-
-
Constructor Summary
Constructors Constructor Description ScriptBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(StatementVisitor visitor)
ScriptBuilder
addEnvironmentVariableScope(String scopeName, Map<String,String> variables)
Exports a variable inside the scriptScriptBuilder
addStatement(Statement statement)
static Statement
call(String fn, String... args)
static Statement
findPid(String pid)
static Statement
forget(String instanceName, String script, String logDir)
Iterable<String>
functionDependencies(OsFamily family)
String
render(OsFamily osFamily)
builds the shell script, by adding the following shell declaration line variable exports case/switchstatic Map<String,String>
resolveFunctionDependenciesForStatements(Map<String,String> knownFunctions, Iterable<Statement> statements, OsFamily osFamily)
ScriptBuilder
unsetEnvironmentVariable(String name)
Unsets a variable to ensure it is set within the script.static void
writeFunctions(Map<String,String> functionsToWrite, OsFamily osFamily, StringBuilder builder)
-
-
-
Method Detail
-
addStatement
public ScriptBuilder addStatement(Statement statement)
-
unsetEnvironmentVariable
public ScriptBuilder unsetEnvironmentVariable(String name)
Unsets a variable to ensure it is set within the script.- Parameters:
variable
- name in UPPER_UNDERSCORE case format
-
addEnvironmentVariableScope
public ScriptBuilder addEnvironmentVariableScope(String scopeName, Map<String,String> variables)
Exports a variable inside the script- Parameters:
scopeName
-variables
- keys are the variables to export in UPPER_UNDERSCORE case format
-
render
public String render(OsFamily osFamily)
builds the shell script, by adding the following- shell declaration line
- variable exports
- case/switch
-
writeFunctions
public static void writeFunctions(Map<String,String> functionsToWrite, OsFamily osFamily, StringBuilder builder)
-
resolveFunctionDependenciesForStatements
public static Map<String,String> resolveFunctionDependenciesForStatements(Map<String,String> knownFunctions, Iterable<Statement> statements, OsFamily osFamily)
-
functionDependencies
public Iterable<String> functionDependencies(OsFamily family)
- Specified by:
functionDependencies
in interfaceStatement
-
accept
public void accept(StatementVisitor visitor)
- Specified by:
accept
in interfaceAcceptsStatementVisitor
-
-