concept configuration property in category gwt

appears as: configuration properties, configuration property, configuration properties
GWT in Action

This is an excerpt from Manning's book GWT in Action.

The rest of this module file plays around with a number of properties and configuration properties, extending and setting them. These will all drive different behaviors in how the compiler operates. For example, the extending of the locale property tells the GWT compiler it needs to create a number of outputs for different locales (UK English, American English, Swedish, and so on).

If the generator is interested in the configuration properties of the compilation context, like our example is, then it can access information about them from the object returned from the getConfigurationProperty method. Listing 18.9 shows how you use this at the start of our example’s generate method to see if you want to generate the proxy class.

Listing 18.9. Accessing various configuration properties

Configuration properties are a little simpler than deferred-binding properties—they don’t change because of the permutation. Therefore, after accessing the property , the only method available returns all the values the property holds —getValues. A single-valued configuration property will only ever have one entry in the List<String> return object.

You’d typically use the values of a configuration property to invoke certain functionality in the generator. We’ve cheated a little in our example. Because you’re using a configuration property to determine whether to run the generator or not, it would have made more sense to include the check in the generate-with definition, but then we wouldn’t have been able to show how to programmatically access it in the code.

Don’t confuse deferred-binding properties with configuration properties. Deferred-binding properties generally drive permutations of the compiler; configuration properties are for passing some information to a generator (or linker) when it’s not sensible or possible to do so via a deferred-binding property, and those values don’t change between permutations.

You can use the <define-configuration-property> tag to define a configuration property. For example, let’s define a gwtia.debugWidgets configuration property that you’ll use later when you create your own generator:

<define-configuration-property name="gwtia.debugWidgets"
                                is-multi-valued="false" />

The definition gives a name to the configuration property and indicates whether it’s permitted to have multiple values or not. For this example, you want it to represent a simple yes/no flag, so you say that its is-multi-values attribute is false.

An example of a configuration property that’s multivalued is the set of runtime locales in internationalization, which we’ll come back to momentarily.