Groovy Services

A groovy service is instantiated using the following service descriptor

 
<service> 
	<background>true</background>
	<fork>true</fork>
	<script> myscript.groovy propA=valuea propB=B </script> 
</service> 
Passing Parameters

Parameters can be passed to a groovy service using:

  • override properties file,
  • Command-line arguments

1.) Properties File.

A property file has the following format

 
propertyA=value1
propertyB=value2

Each property is available to your groovy service as a variable. This places the same restrictions on groovy variable naming on the properties override file.

2.) Command-line arguments

Any parameters passed to your groovy script in the script tag can be accessed in the args variable. If you had the following arguments:

myscript -host localhost -port 33600

The args contains the arguments as they appear. For the example above the args list will have the following values

 
["-host","localhost","-port","33600"]
The same values can be automatically created in your groovy service as variables using the key value syntax.
myscript host=localhost port=33600
The same mechanism that is used to bind values to variables for the properties override file can is used for command line values.