Class CommandLineConfigurationSource

All Implemented Interfaces:
ConfigurationSource<AbstractHashConfigurationSource.HashConfigurationQuery<String,CommandLineConfigurationSource>,AbstractHashConfigurationSource.HashExecutableConfigurationQuery<String,CommandLineConfigurationSource>,AbstractHashConfigurationSource.HashListConfigurationQuery<String,CommandLineConfigurationSource>>, DefaultableConfigurationSource<AbstractHashConfigurationSource.HashConfigurationQuery<String,CommandLineConfigurationSource>,AbstractHashConfigurationSource.HashExecutableConfigurationQuery<String,CommandLineConfigurationSource>,AbstractHashConfigurationSource.HashListConfigurationQuery<String,CommandLineConfigurationSource>,CommandLineConfigurationSource>

public class CommandLineConfigurationSource extends AbstractHashConfigurationSource<String,CommandLineConfigurationSource>

A configuration source that looks up properties from command line arguments.

Configuration properties are specified as application arguments using the following syntax (ABNF):


 argument        = "--" {@literal property_name} [ "[" *(parameter ",") "]" ] "=" property_value

 property_name   = java_name

 property_value  = java_integer_literal
                 / java_floating_point_literal
                 / java_string_literal
                 / java_boolean_literal
                 / "unset"
                 / "null"

 parameter       = parameter_name "=" parameter_value

 parameter_name  = java_identifier

 parameter_value = java_integer_literal
                 / java_floating_point_literal
                 / java_string_literal
                 / java_boolean_literal

 

The following are valid configuration properties passed as command line arguments:

  • --web.server_port=8080
  • --web.server_port[profile="ssl"]=8443
  • --db.url[env="dev"]="jdbc:oracle:thin:@dev.db.server:1521:sid"
  • --db.url[env="prod",zone="eu"]="jdbc:oracle:thin:@prod_eu.db.server:1521:sid"
  • --db.url[env="prod",zone="us"]="jdbc:oracle:thin:@prod_us.db.server:1521:sid"
Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Constructor Details

    • CommandLineConfigurationSource

      public CommandLineConfigurationSource(String[] args)

      Creates a command line configuration source with the specified arguments using a Java String value decoder.

      Parameters:
      args - the command line arguments
    • CommandLineConfigurationSource

      public CommandLineConfigurationSource(String[] args, SplittablePrimitiveDecoder<String> decoder)

      Creates a command line configuration source with the specified arguments and the specified string value decoder.

      Parameters:
      args - the command line arguments
      decoder - a string decoder
  • Method Details