public abstract class

AbstractResourceContext

extends Object
implements ResourceContext
java.lang.Object
   ↳ com.google.gwt.resources.rebind.context.AbstractResourceContext
Known Direct Subclasses

Class Overview

Defines base methods for ResourceContext implementations.

Summary

Constants
int MAX_INLINE_SIZE The largest file size that will be inlined.
Protected Constructors
AbstractResourceContext(TreeLogger logger, GeneratorContext context, JClassType resourceBundleType, ClientBundleContext clientBundleCtx)
Public Methods
String deploy(URL resource, String mimeType, boolean forceExternal)
Cause a specific collection of bytes to be available in the program's compiled output.
String deploy(URL resource, boolean forceExternal)
Cause a specific collection of bytes to be available in the program's compiled output.
<T> T getCachedData(String key, Class<T> clazz)
Retrieve data from the ResourceContext.
JClassType getClientBundleType()
Return the interface type of the resource bundle being generated.
GeneratorContext getGeneratorContext()
Return the GeneratorContext in which the overall resource generation framework is being run.
String getImplementationSimpleSourceName()
Returns the simple source name of the implementation of the bundle being generated.
<T> boolean putCachedData(String key, T value)
Store data in the ResourceContext.
Protected Methods
GeneratorContext getContext()
TreeLogger getLogger()
static String toBase64(byte[] data)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.gwt.resources.ext.ResourceContext

Constants

protected static final int MAX_INLINE_SIZE

The largest file size that will be inlined. Note that this value is taken before any encodings are applied.

Constant Value: 65536 (0x00010000)

Protected Constructors

protected AbstractResourceContext (TreeLogger logger, GeneratorContext context, JClassType resourceBundleType, ClientBundleContext clientBundleCtx)

Public Methods

public String deploy (URL resource, String mimeType, boolean forceExternal)

Cause a specific collection of bytes to be available in the program's compiled output. The return value of this method is a Java expression which will evaluate to the location of the resource at runtime. The exact format should not be depended upon.

Parameters
resource the resource to add to the compiled output
mimeType optional MIME Type to be used for an embedded resource
forceExternal prevents embedding of the resource, e.g. in case of known incompatibilities or for example to enforce compatibility with security restrictions if the resource is intended to be accessed via an XMLHttpRequest
Returns
  • a Java expression which will evaluate to the location of the provided resource at runtime
Throws
UnableToCompleteException

public String deploy (URL resource, boolean forceExternal)

Cause a specific collection of bytes to be available in the program's compiled output. The return value of this method is a Java expression which will evaluate to the location of the resource at runtime. The exact format should not be depended upon.

Parameters
resource the resource to add to the compiled output
forceExternal prevents embedding of the resource, e.g. in case of known incompatibilities or for example to enforce compatibility with security restrictions if the resource is intended to be accessed via an XMLHttpRequest
Returns
  • a Java expression which will evaluate to the location of the provided resource at runtime
Throws
UnableToCompleteException

public T getCachedData (String key, Class<T> clazz)

Retrieve data from the ResourceContext.

Parameters
key the key value passed to getCachedData(String, Class)
clazz the type to which the cached value must be assignable
Returns

public JClassType getClientBundleType ()

Return the interface type of the resource bundle being generated.

public GeneratorContext getGeneratorContext ()

Return the GeneratorContext in which the overall resource generation framework is being run. Implementations of ResourceGenerator should prefer deploy(String, String, byte[], boolean) over tryCreateResource(TreeLogger, String) in order to take advantage of serving optimizations that can be performed by the bundle architecture.

public String getImplementationSimpleSourceName ()

Returns the simple source name of the implementation of the bundle being generated. This can be used during code-generation to refer to the instance of the bundle (e.g. via SimpleSourceName.this).

public boolean putCachedData (String key, T value)

Store data in the ResourceContext. ResourceGenerators may reduce the amount of recomputation performed by caching data the ResourceContext. This cache will be invalidated when the compiler's TypeOracle is refreshed or replaced. Each ResourceGenerator has an isolated view of the cache.

Parameters
key a string key to locate the data
value the value to store
Returns
  • true if the cache did not previously contain the key-value pair

Protected Methods

protected GeneratorContext getContext ()

protected TreeLogger getLogger ()

protected static String toBase64 (byte[] data)