Example usage for com.google.gwt.resources.ext ResourceContext deploy

List of usage examples for com.google.gwt.resources.ext ResourceContext deploy

Introduction

In this page you can find the example usage for com.google.gwt.resources.ext ResourceContext deploy.

Prototype

String deploy(String suggestedFileName, String mimeType, byte[] data, boolean forceExternal)
        throws UnableToCompleteException;

Source Link

Document

Cause a specific collection of bytes to be available in the program's compiled output.

Usage

From source file:org.vectomatic.dev.svg.impl.gen.ExternalSVGResourceGenerator.java

License:Apache License

@Override
public void createFields(TreeLogger logger, ResourceContext context, ClientBundleFields fields)
        throws UnableToCompleteException {
    data.append(']');

    urlExpression = context.deploy(
            context.getClientBundleType().getQualifiedSourceName().replace('.', '_') + "_jsonbundle.txt",
            "text/plain", data.toString().getBytes(), true);

    TypeOracle typeOracle = context.getGeneratorContext().getTypeOracle();
    JClassType stringType = typeOracle.findType(String.class.getName());
    assert stringType != null;

    externalSVGUrlIdent = fields.define(stringType, "externalSVGUrl", urlExpression, true, true);

    JClassType textResourceType = typeOracle.findType(SVGResource.class.getName());
    assert textResourceType != null;
    JType textResourceArrayType = typeOracle.getArrayType(textResourceType);

    externalSVGCacheIdent = fields.define(textResourceArrayType, "externalSVGCache",
            "new " + SVGResource.class.getName() + "[" + currentIndex + "]", true, true);
}