Package com.google.gwt.core.ext

Examples of com.google.gwt.core.ext.GeneratorContext


  }

  public String addToOutput(String suggestedFileName, String mimeType,
      byte[] data, boolean xhrCompatible) throws UnableToCompleteException {
    TreeLogger logger = getLogger();
    GeneratorContext context = getGeneratorContext();
    PropertyOracle propertyOracle = context.getPropertyOracle();

    // See if filename obfuscation should be enabled
    String enableRenaming = null;
    try {
      enableRenaming = propertyOracle.getPropertyValue(logger, ENABLE_RENAMING);
    } catch (BadPropertyValueException e) {
      logger.log(TreeLogger.ERROR, "Bad value for " + ENABLE_RENAMING, e);
      throw new UnableToCompleteException();
    }

    // Determine the final filename for the resource's file
    String outputName;
    if (Boolean.parseBoolean(enableRenaming)) {
      String strongName = Util.computeStrongName(data);

      // Determine the extension of the original file
      String extension;
      int lastIdx = suggestedFileName.lastIndexOf('.');
      if (lastIdx != -1) {
        extension = suggestedFileName.substring(lastIdx + 1);
      } else {
        extension = "noext";
      }

      // The name will be MD5.cache.ext
      outputName = strongName + ".cache." + extension;

    } else {
      outputName =
          suggestedFileName.substring(suggestedFileName.lastIndexOf('/') + 1);
    }

    // Ask the context for an OutputStream into the named resource
    OutputStream out = context.tryCreateResource(logger, outputName);

    // This would be null if the resource has already been created in the
    // output (because two or more resources had identical content).
    if (out != null) {
      try {
        out.write(data);

      } catch (IOException e) {
        logger.log(TreeLogger.ERROR, "Unable to write data to output name "
            + outputName, e);
        throw new UnableToCompleteException();
      }

      // If there's an error, this won't be called and there will be nothing
      // created in the output directory.
      context.commitResource(logger, out);

      logger.log(TreeLogger.DEBUG, "Copied " + data.length + " bytes to "
          + outputName, null);
    }
View Full Code Here


  // Verify that outputting static injections creates and dispatches to the
  // correct fragment classes.
  public void testOutputStaticInjections() throws Exception {
    PrintWriter printWriter = new PrintWriter(new ByteArrayOutputStream());

    GeneratorContext ctx = createMock(GeneratorContext.class, "ctx");
    expect(ctx.tryCreate((TreeLogger) anyObject(), (String) anyObject(), (String) anyObject()))
        .andStubReturn(printWriter);

    Capture<FieldLiteral<SuperClass>> fieldCapture = new Capture<FieldLiteral<SuperClass>>();
    Capture<MethodLiteral<SuperClass, Method>> methodCapture =
        new Capture<MethodLiteral<SuperClass, Method>>();
View Full Code Here


public class GinBridgeClassLoaderTest extends TestCase {

  public void testExceptedPackages() throws ClassNotFoundException, NoSuchMethodException {
    GeneratorContext context =
        GeneratorContextBuilder.newEmptyBuilder().add(createSimple()).buildGeneratorContext();

    GinBridgeClassLoader gwtLoader =
        new GinBridgeClassLoader(context, createLogger(), new HashSet<String>());
View Full Code Here

    assertClassVersion(javaLoader, "b", "a", "com.google.gwt.inject.rebind.types.Simple");
  }

  public void testExceptedPackagesWithDot() throws ClassNotFoundException, NoSuchMethodException {
    GeneratorContext context =
        GeneratorContextBuilder.newEmptyBuilder().add(createSimple()).buildGeneratorContext();

    GinBridgeClassLoader loader = new GinBridgeClassLoader(context, createLogger(),
        Collections.singleton("com.google.gwt.inject.rebind.types."));
View Full Code Here

    assertClassVersion(loader, "b", "a", "com.google.gwt.inject.rebind.types.Simple");
  }

  public void testJavaCoreClass() throws ClassNotFoundException {
    GeneratorContext context =
        GeneratorContextBuilder.newEmptyBuilder().add(createFakeString()).buildGeneratorContext();

    GinBridgeClassLoader loader =
        new GinBridgeClassLoader(context, createLogger(), new HashSet<String>());
View Full Code Here

        assertSame(logger1, generator.logger);
    }

    /** Test setGeneratorContext(). */
    @Test public void testSetGeneratorContext() {
        GeneratorContext context1 = mock(GeneratorContext.class);
        GeneratorContext context2 = mock(GeneratorContext.class);

        XsrfRpcProxyGenerator generator = new XsrfRpcProxyGenerator();
        assertNull(generator.generatorContext);

        generator.setGeneratorContext(context1);
View Full Code Here

      writer.println();
      writer.println("@Override");
      writer.println("public DateTimeConstants getDateTimeConstants() {");
      LocalizableGenerator localizableGenerator = new LocalizableGenerator();
      // Avoid warnings for trying to create the same type multiple times
      GeneratorContext subContext = new CachedGeneratorContext(context);
      generateConstantsLookup(logger, subContext, writer, localizableGenerator,
          runtimeLocales, locale,
          "com.google.gwt.i18n.client.constants.DateTimeConstantsImpl");
      writer.println("}");
      writer.println();
View Full Code Here

  public static void processDependencies(final DependencyControl control,
                                         final MetaClass metaClass,
                                         final InjectionContext context) {

    final GraphBuilder graphBuilder = context.getGraphBuilder();
    final GeneratorContext genCtx = context.getProcessingContext().getGeneratorContext();
    MetaClass mc = metaClass;
    do {
      for (MetaField field : mc.getDeclaredFields()) {

        if (context.isElementType(WiringElementType.InjectionPoint, field)) {
View Full Code Here

    injectionContext.mapElementType(WiringElementType.SingletonBean, Singleton.class);
    injectionContext.mapElementType(WiringElementType.SingletonBean, EntryPoint.class);

    injectionContext.mapElementType(WiringElementType.DependentBean, Dependent.class);

    final GeneratorContext genCtx = injectionContext.getProcessingContext().getGeneratorContext();
    for (final MetaClass mc : ClassScanner.getTypesAnnotatedWith(Stereotype.class, genCtx)) {
      processStereoType(injectionContext, mc.asClass().asSubclass(Annotation.class));
    }

    injectionContext.mapElementType(WiringElementType.TopLevelProvider, IOCProvider.class);
View Full Code Here

    this.testMock = context.isElementType(WiringElementType.TestMockBean, providerType);
    this.singleton = context.isElementType(WiringElementType.SingletonBean, providerType);
    this.alternative = context.isElementType(WiringElementType.AlternativeBean, type);

    GeneratorContext genCtx = context.getProcessingContext().getGeneratorContext();
    final Collection<MetaClass> toDisable = new ArrayList<MetaClass>(ClassScanner.getSubTypesOf(type, genCtx));
    toDisable.add(type);

    setRendered(true);
View Full Code Here

TOP

Related Classes of com.google.gwt.core.ext.GeneratorContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.