public abstract class

AbstractClientBundleGenerator

extends Generator
java.lang.Object
   ↳ com.google.gwt.core.ext.Generator
     ↳ com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator
Known Direct Subclasses

Class Overview

The base class for creating new ClientBundle implementations.

The general structure of the generated class is as follows:

 public ResourceType resource() {
   return resource;
 }
 private void _init0() {
   resource = new Resource();
 }
 // Other ResourceGenerator-defined fields
 private static ResourceType resource;
 private static HashMap<String, ResourcePrototype> resourceMap;
 static {
   new ClientBundle()._init0();
 }
 public ResourcePrototype[] getResources() {
   return new ResourcePrototype[] { resource() };
 }
 public ResourcePrototype getResource(String name) {
   if (GWT.isScript()) {
     return getResourceNative(name);
   } else {
     if (resourceMap == null) {
       resourceMap = new HashMap();
       resourceMap.put("resource", resource());
     }
     return resourceMap.get(name);
   }
 }
 private native ResourcePrototype getResourceNative(String name) /-{
   switch (name) {
     case 'resource': return this.@...::resource()();
   }
   return null;
 }-/
 
The instantiation of the individual ResourcePrototypes is done in the content of an instance of the ClientBundle type so that resources can refer to one another by simply emitting a call to resource().

Summary

Nested Classes
class AbstractClientBundleGenerator.FieldsImpl An implementation of ClientBundleFields. 
Public Constructors
AbstractClientBundleGenerator()
Public Methods
final String generate(TreeLogger logger, GeneratorContext generatorContext, String typeName)
Protected Methods
abstract AbstractResourceContext createResourceContext(TreeLogger logger, GeneratorContext context, JClassType resourceBundleType)
Create the ResourceContext object that will be used by ResourceGenerator subclasses.
void doAddFieldsAndRequirements(TreeLogger logger, GeneratorContext context, AbstractClientBundleGenerator.FieldsImpl fields, ClientBundleRequirements requirements)
Provides a hook for subtypes to add additional fields or requirements to the bundle.
void doCreateBundleForPermutation(TreeLogger logger, GeneratorContext generatorContext, AbstractClientBundleGenerator.FieldsImpl fields, String generatedSimpleSourceName)
This method is called after the ClientBundleRequirements have been evaluated and a new ClientBundle implementation is being created.
void doFinish(TreeLogger logger)
Provides a hook for finalizing generated resources.
[Expand]
Inherited Methods
From class com.google.gwt.core.ext.Generator
From class java.lang.Object

Public Constructors

public AbstractClientBundleGenerator ()

Public Methods

public final String generate (TreeLogger logger, GeneratorContext generatorContext, String typeName)

Throws
UnableToCompleteException

Protected Methods

protected abstract AbstractResourceContext createResourceContext (TreeLogger logger, GeneratorContext context, JClassType resourceBundleType)

Create the ResourceContext object that will be used by ResourceGenerator subclasses. This is the primary way to implement custom logic in the resource generation pass.

Throws
UnableToCompleteException

protected void doAddFieldsAndRequirements (TreeLogger logger, GeneratorContext context, AbstractClientBundleGenerator.FieldsImpl fields, ClientBundleRequirements requirements)

Provides a hook for subtypes to add additional fields or requirements to the bundle.

Parameters
logger a TreeLogger
context the GeneratorContext
fields ClentBundle fields
requirements ClientBundleRequirements
Throws
UnableToCompleteException if an error occurs.

protected void doCreateBundleForPermutation (TreeLogger logger, GeneratorContext generatorContext, AbstractClientBundleGenerator.FieldsImpl fields, String generatedSimpleSourceName)

This method is called after the ClientBundleRequirements have been evaluated and a new ClientBundle implementation is being created.

Parameters
logger a TreeLogger
generatorContext the GeneratoContext
fields ClientBundle fields
generatedSimpleSourceName a String
Throws
UnableToCompleteException if an error occurs.

protected void doFinish (TreeLogger logger)

Provides a hook for finalizing generated resources.

Parameters
logger a TreeLogger
Throws
UnableToCompleteException if an error occurs.