Interface ResourceGenerator

All Known Implementing Classes:
AbstractResourceGenerator

public interface ResourceGenerator
Encapsulates per-type resource generation logic. This type is used only by developers who wish to add additional resource types to the resource generation system. Implementations are paired with one or more interfaces derived from ResourcePrototype that have been annotated with an ResourceGeneratorType annotation. Instances of ResourceGenerator must support default-instantiation (i.e. via Class.newInstance()).

The methods on an instance of ResourceGenerator will be called in the following order by the resource generation system:

  1. init(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext)
  2. prepare(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext, com.google.gwt.resources.ext.ClientBundleRequirements, com.google.gwt.core.ext.typeinfo.JMethod) once for each method
  3. Based on the requirements specified by the ResourceGenerator, the framework may decide that no further action is required. If this is the case, the framework will immediately invoke finish(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext).
  4. createFields(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext, com.google.gwt.resources.ext.ClientBundleFields)
  5. createAssignment(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext, com.google.gwt.core.ext.typeinfo.JMethod) once for each method
  6. finish(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext)

The methods prepare(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext, com.google.gwt.resources.ext.ClientBundleRequirements, com.google.gwt.core.ext.typeinfo.JMethod) and createAssignment(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext, com.google.gwt.core.ext.typeinfo.JMethod) will be called only with those methods whose ResourcePrototype-derived type specifies the particular type of ResourceGenerator as the implementor. The relative order in which ResourceGenerators are invoked and the specific order in which the bundle's methods are presented is undefined.

Direct access to the contents of the generated bundle implementation is intentionally limited to prevent unrelated ResourceGenerators from potentially creating namespace conflicts or generating invalid Java source.

See Also: