Interface ResourceContext

    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.String deploy​(java.lang.String suggestedFileName, java.lang.String mimeType, byte[] data, boolean forceExternal)
      Cause a specific collection of bytes to be available in the program's compiled output.
      java.lang.String deploy​(java.net.URL resource, boolean forceExternal)
      Deprecated.
      java.lang.String deploy​(java.net.URL resource, java.lang.String mimeType, boolean forceExternal)
      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.
      ClientBundleRequirements getRequirements()
      Returns a ClientBundleRequirements object, which can be used to track deferred-binding and configuration properties that are relevant to a resource context.
      <T> boolean putCachedData​(java.lang.String key, T value)
      Store data in the ResourceContext.
      boolean supportsDataUrls()
      Indicates if the runtime context supports data: urls.
    • Method Detail

      • deploy

        java.lang.String deploy​(java.lang.String suggestedFileName,
                                java.lang.String mimeType,
                                byte[] data,
                                boolean forceExternal)
                         throws UnableToCompleteException
        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:
        suggestedFileName - an unobfuscated filename to possibly use for the resource
        mimeType - the MIME type of the data being provided
        data - the bytes to add to the 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
      • deploy

        @Deprecated
        java.lang.String deploy​(java.net.URL resource,
                                boolean forceExternal)
                         throws UnableToCompleteException
        Deprecated.
        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
      • deploy

        java.lang.String deploy​(java.net.URL resource,
                                java.lang.String mimeType,
                                boolean forceExternal)
                         throws UnableToCompleteException
        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
      • getCachedData

        <T> T getCachedData​(java.lang.String key,
                            java.lang.Class<T> clazz)
        Retrieve data from the ResourceContext.
        Type Parameters:
        T - the type of data to retrieve
        Parameters:
        key - the key value passed to getCachedData(java.lang.String, java.lang.Class<T>)
        clazz - the type to which the cached value must be assignable
        Returns:
        the value previously passed to putCachedData(java.lang.String, T) or null if the data was not found
        Throws:
        java.lang.ClassCastException - if the cached data is not assignable to the specified type
      • getClientBundleType

        JClassType getClientBundleType()
        Return the interface type of the resource bundle being generated.
      • putCachedData

        <T> boolean putCachedData​(java.lang.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.
        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
      • supportsDataUrls

        boolean supportsDataUrls()
        Indicates if the runtime context supports data: urls. When data URLs are supported by the context, aggregation of resource data into larger payloads is discouraged, as it offers reduced benefit to the application at runtime.