public interface ResourceGenerator
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:
init(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext)
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 methodfinish(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext)
.createFields(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext, com.google.gwt.resources.ext.ClientBundleFields)
createAssignment(com.google.gwt.core.ext.TreeLogger, com.google.gwt.resources.ext.ResourceContext, com.google.gwt.core.ext.typeinfo.JMethod)
once for each methodfinish(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.
ResourceGeneratorUtil
Modifier and Type | Method and Description |
---|---|
String |
createAssignment(com.google.gwt.core.ext.TreeLogger logger,
ResourceContext context,
com.google.gwt.core.ext.typeinfo.JMethod method)
Produce the right-hand-side of a Java assignment expression to provide the
singleton instance object for a particular resource.
|
void |
createFields(com.google.gwt.core.ext.TreeLogger logger,
ResourceContext context,
ClientBundleFields fields)
The ResourceGenerator can create fields within the implementation of the
bundle type.
|
void |
finish(com.google.gwt.core.ext.TreeLogger logger,
ResourceContext context)
Called at the end of the resource generation phase and can be used to
perform cleanup.
|
void |
init(com.google.gwt.core.ext.TreeLogger logger,
ResourceContext context)
Initialize the ResourceGenerator with the generation context that will
remain valid for the duration of the resource-generation phase.
|
void |
prepare(com.google.gwt.core.ext.TreeLogger logger,
ResourceContext context,
ClientBundleRequirements requirements,
com.google.gwt.core.ext.typeinfo.JMethod method)
Called once for each method the ResourceGenerator is expected to handle.
|
String createAssignment(com.google.gwt.core.ext.TreeLogger logger, ResourceContext context, com.google.gwt.core.ext.typeinfo.JMethod method) throws com.google.gwt.core.ext.UnableToCompleteException
Example:
new MySampleResource() { public Foo getFoo() { ... } }
com.google.gwt.core.ext.UnableToCompleteException
void createFields(com.google.gwt.core.ext.TreeLogger logger, ResourceContext context, ClientBundleFields fields) throws com.google.gwt.core.ext.UnableToCompleteException
The Fields instance should not be retained beyond the lifetime of this method as operation on this object is not defined after the implementation of this method returns.
com.google.gwt.core.ext.UnableToCompleteException
void finish(com.google.gwt.core.ext.TreeLogger logger, ResourceContext context) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
void init(com.google.gwt.core.ext.TreeLogger logger, ResourceContext context) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
void prepare(com.google.gwt.core.ext.TreeLogger logger, ResourceContext context, ClientBundleRequirements requirements, com.google.gwt.core.ext.typeinfo.JMethod method) throws com.google.gwt.core.ext.UnableToCompleteException
com.google.gwt.core.ext.UnableToCompleteException
Copyright © 2016. All rights reserved.