Examples of JavaFileObject


Examples of javax.tools.JavaFileObject

        if (primary == null) {
            name.append("package-info");
        } else {
            name.append(primary.getName());
        }
        JavaFileObject source = filer.createSourceFile(name, originatingElements);
        Writer writer = source.openWriter();
        try {
            PrintWriter output = new PrintWriter(writer);
            Models.emit(unit, output);
            output.close();
        } finally {
View Full Code Here

Examples of javax.tools.JavaFileObject

    compilationHelper = CompilationTestHelper.newInstance(new ProtoFieldNullComparison());
    protoFile = compilationHelper.fileManager().source(getClass(), "proto/ProtoTest.java");
  }

  private List<JavaFileObject> getSourceFiles(String mainFileName) throws URISyntaxException {
    JavaFileObject mainFile = compilationHelper.fileManager().source(getClass(), mainFileName);
    return ImmutableList.of(mainFile, protoFile);
  }
View Full Code Here

Examples of javax.tools.JavaFileObject

                                "$METHOD_NAME$", ((ExecutableElement) ie).getSimpleName().toString()));
                    }
                }
                replace(body, "$PROPERTIES$", properties.toString());
                try {
                    JavaFileObject f = processingEnv.getFiler().
                            createSourceFile(dockPackage + "." + dockShortName);
                    Writer w = f.openWriter();
                    PrintWriter pw = new PrintWriter(w);
                    pw.print(body);
                    pw.flush();
                    pw.close();
                } catch (IOException ex) {
View Full Code Here

Examples of javax.tools.JavaFileObject

                continue;
            }

            final byte[] newClass = requestGenerator.createTokenizer(((TypeElement) element).getQualifiedName().toString(), parser.methods(), parser.protocols(), parser.headers());
            try {
                JavaFileObject file = filer.createClassFile(((TypeElement) element).getQualifiedName() + AbstractParserGenerator.CLASS_NAME_SUFFIX, element);
                final OutputStream out = file.openOutputStream();
                try {
                    out.write(newClass);
                } finally {
                    try {
                        out.close();
                    } catch (IOException e) {

                    }
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        ResponseParserGenerator responseGenerator = new ResponseParserGenerator();
        for (Element element : roundEnv.getElementsAnnotatedWith(HttpResponseParserConfig.class)) {
            final HttpResponseParserConfig parser = element.getAnnotation(HttpResponseParserConfig.class);
            if (parser == null) {
                continue;
            }
            final byte[] newClass = responseGenerator.createTokenizer(((TypeElement) element).getQualifiedName().toString(), new String[0], parser.protocols(), parser.headers());
            try {
                JavaFileObject file = filer.createClassFile(((TypeElement) element).getQualifiedName() + AbstractParserGenerator.CLASS_NAME_SUFFIX, element);
                final OutputStream out = file.openOutputStream();
                try {
                    out.write(newClass);
                } finally {
                    try {
                        out.close();
View Full Code Here

Examples of javax.tools.JavaFileObject

  }
 
  private void generateSourceFile(FactoryModel model) {
    try {
      String factoryName = model.declaration.getQualifiedName() + "Impl";
      JavaFileObject src = filer.createSourceFile(factoryName, model.declaration);
      PrintWriter writer = new PrintWriter(src.openWriter());
      writer.println(formatter.generate(model));
      writer.flush();
      writer.close();
    } catch (IOException e) {
      messager.printMessage(Kind.ERROR, e.getMessage(), model.declaration);
View Full Code Here

Examples of javax.tools.JavaFileObject

    private void writeAccessControlFile() throws Exception {
        Map<String, Object> model = new HashMap<>();
        model.put("metaData", accessControlDeclararions);
        model.put("operations", bootstrapOperations);

        JavaFileObject sourceFile = filer.createSourceFile(ACCESS_FILENAME);
        OutputStream output = sourceFile.openOutputStream();
        new TemplateProcessor().process(ACCESS_TEMPLATE, model, output);
        output.flush();
        output.close();
    }
View Full Code Here

Examples of javax.tools.JavaFileObject

    private void writeGinjectorFile() throws Exception {

        Map<String, Object> model = new HashMap<>();
        model.put("extensions", discoveredExtensions);

        JavaFileObject sourceFile = filer.createSourceFile(EXTENSION_FILENAME);
        OutputStream output = sourceFile.openOutputStream();
        new TemplateProcessor().process(EXTENSION_TEMPLATE, model, output);
        output.flush();
        output.close();

    }
View Full Code Here

Examples of javax.tools.JavaFileObject

        output.close();

    }

    private void writeBindingFile() throws Exception {
        JavaFileObject sourceFile = filer.createSourceFile(BINDING_FILENAME);
        Map<String, Object> model = new HashMap<>();
        model.put("extensions", discoveredBindings);

        OutputStream output = sourceFile.openOutputStream();
        new TemplateProcessor().process(BINDING_TEMPLATE, model, output);

        output.flush();
        output.close();
    }
View Full Code Here

Examples of javax.tools.JavaFileObject

    private void writeBeanFactoryFile() throws Exception {
        Map<String, Object> model = new HashMap<>();
        model.put("extensions", discoveredBeanFactories);
        model.put("categoryClasses", categoryClasses);

        JavaFileObject sourceFile = filer.createSourceFile(BEAN_FACTORY_FILENAME);
        OutputStream output = sourceFile.openOutputStream();
        new TemplateProcessor().process(BEAN_FACTORY_TEMPLATE, model, output);
        output.flush();
        output.close();
    }
View Full Code Here

Examples of javax.tools.JavaFileObject

    private void writeSubsystemFile() throws Exception {
        Map<String, Object> model = new HashMap<>();
        model.put("subsystemExtensions", subsystemDeclararions);

        JavaFileObject sourceFile = filer.createSourceFile(SUBSYSTEM_FILENAME);
        OutputStream output = sourceFile.openOutputStream();
        new TemplateProcessor().process(SUBSYSTEM_TEMPLATE, model, output);
        output.flush();
        output.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.