GWT.create works differently:
- He tries to see if there are any declarations in the gwt.xml files about which implementation to use depending on the GWT property. This GWT property can be a well-known user agent, which in this case will have the effect of choosing different implementations for each browser, but it can also be used for other things, for example, to disable logging (the fact that logging is enabled or not has nothing to do with which browser it works in)
Example:
<replace-with class="com.x.app.client.ui.base.button.CustomSlicedButtonCellAppearance"> <when-type-is class="com.x.app.client.ui.base.button.CustomButtonCellAppearance" /> <when-property-is name="gxt.css3.enabled" value="false"/> <when-property-is name="gxt.theme" value="themeName" /> </replace-with>
In this case, it will use CustomSlicedButtonCellAppearance to call GWT.create (CustomButtonCellAppearance.class) only if css3 is not supported for this topic either. Note that "when-property-is" is optional, and if it is not specified, it will always use this implementation for this interface.
- It also looks for generators, in which case a new class is generated at compile time by GWT (or in devmode), usually based on the annotations that are present in the interface passed to the create method.
Example:
<generate-with class="org.fusesource.restygwt.rebind.RestServiceGenerator"> <when-type-assignable class="org.fusesource.restygwt.client.RestService" /> </generate-with>
In this case, RestServiceGenerator will generate the code to send the request. Another example is how UIBinder works: in addition to using annotations in the interface, it also generates code based on what is inside the ui.xml file.
- If no declaration matches the class / interface passed to the GWT.create method, then it will try to make a new one in this class (in case of interface failure).
Declarations in gwt.xml files can be overwritten by other declarations, which are subsequently processed, therefore, if you use a module that declares a rule, you can change this rule by declaring a new rule after inheriting the declaration of the module containing the original declaration.
source share