com.google.gwt.resources.rebind.context
Class AbstractResourceContext

java.lang.Object
  extended by com.google.gwt.resources.rebind.context.AbstractResourceContext
All Implemented Interfaces:
ResourceContext
Direct Known Subclasses:
MhtmlResourceContext

public abstract class AbstractResourceContext
extends java.lang.Object
implements ResourceContext

Defines base methods for ResourceContext implementations.


Method Summary
 java.lang.String deploy(java.net.URL resource, boolean xhrCompatible)
          Cause a specific collection of bytes to be available in the program's compiled output.
<T> T
getCachedData(java.lang.String key, java.lang.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.
 java.lang.String getImplementationSimpleSourceName()
          Returns the simple source name of the implementation of the bundle being generated.
<T> boolean
putCachedData(java.lang.String key, T value)
          Store data in the ResourceContext.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.gwt.resources.ext.ResourceContext
deploy, supportsDataUrls
 

Method Detail

deploy

public java.lang.String deploy(java.net.URL resource,
                               boolean xhrCompatible)
                        throws UnableToCompleteException
Description copied from interface: ResourceContext
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.

Specified by:
deploy in interface ResourceContext
Parameters:
resource - the resource to add to the compiled output
xhrCompatible - enforces 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

getCachedData

public <T> T getCachedData(java.lang.String key,
                           java.lang.Class<T> clazz)
Description copied from interface: ResourceContext
Retrieve data from the ResourceContext.

Specified by:
getCachedData in interface ResourceContext
Type Parameters:
T - the type of data to retrieve
Parameters:
key - the key value passed to ResourceContext.getCachedData(java.lang.String, java.lang.Class)
clazz - the type to which the cached value must be assignable
Returns:
the value previously passed to ResourceContext.putCachedData(java.lang.String, T) or null if the data was not found

getClientBundleType

public JClassType getClientBundleType()
Description copied from interface: ResourceContext
Return the interface type of the resource bundle being generated.

Specified by:
getClientBundleType in interface ResourceContext

getGeneratorContext

public GeneratorContext getGeneratorContext()
Description copied from interface: ResourceContext
Return the GeneratorContext in which the overall resource generation framework is being run. Implementations of ResourceGenerator should prefer ResourceContext.deploy(java.lang.String, java.lang.String, byte[], boolean) over GeneratorContext#tryCreateResource in order to take advantage of serving optimizations that can be performed by the bundle architecture.

Specified by:
getGeneratorContext in interface ResourceContext

getImplementationSimpleSourceName

public java.lang.String getImplementationSimpleSourceName()
Description copied from interface: ResourceContext
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).

Specified by:
getImplementationSimpleSourceName in interface ResourceContext

putCachedData

public <T> boolean putCachedData(java.lang.String key,
                                 T value)
Description copied from interface: ResourceContext
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.

Specified by:
putCachedData in interface ResourceContext
Type Parameters:
T - the type of data being stored
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