Package javax.tools

Examples of javax.tools.FileObject


    try {
      for (Map.Entry<String, List<String>> entry : serviceProviders
          .entrySet()) {
        serviceFile = entry.getKey();
        FileObject providerFileObject = processingEnv.getFiler()
            .createResource(StandardLocation.SOURCE_OUTPUT, "",
                "META-INF/services/" + serviceFile);

        List<String> services = entry.getValue();
        BufferedWriter writer = null;

        try {
          writer = new BufferedWriter(providerFileObject.openWriter());

          for (int i = 0; i < services.size(); i++) {
            writer.append(services.get(i)).append('\n');
          }
        } finally {
View Full Code Here


       
        PackageElement packageElement = elements.getPackageOf(target);
        String templateRef = getReferencedTemplate(target);
        String templateRefError = null;
        try {
          FileObject resource = processingEnv.getFiler().getResource(StandardLocation.CLASS_PATH, packageElement.getQualifiedName(), templateRef);
          CharSequence charContent = resource.getCharContent(true);
        } catch (IllegalArgumentException e) {
          // unfortunately, Eclipse just throws IAE when we try to read files from CLASS_PATH
          // so the best we can do is ignore this error and skip validating the template reference
        } catch (IOException e) {
          templateRefError = "Could not access associated template " + templateRef;
View Full Code Here

      String metaModelPackage = entity.getPackageName();
      // need to generate the body first, since this will also update the required imports which need to
      // be written out first
      String body = generateBody( entity, context ).toString();

      FileObject fo = context.getProcessingEnvironment().getFiler().createSourceFile(
          getFullyQualifiedClassName( entity, metaModelPackage )
      );
      OutputStream os = fo.openOutputStream();
      PrintWriter pw = new PrintWriter( os );

      if ( !metaModelPackage.isEmpty() ) {
        pw.println( "package " + metaModelPackage + ";" );
        pw.println();
View Full Code Here

    String pkg = getPackage( resource );
    String name = getRelativeName( resource );
    InputStream ormStream;
    try {
      FileObject fileObject = context.getProcessingEnvironment()
          .getFiler()
          .getResource( StandardLocation.CLASS_OUTPUT, pkg, name );
      ormStream = fileObject.openInputStream();
    }
    catch ( IOException e1 ) {
      // TODO - METAGEN-12
      // unfortunately, the Filer.getResource API seems not to be able to load from /META-INF. One gets a
      // FilerException with the message with "Illegal name /META-INF". This means that we have to revert to
View Full Code Here

        try {
            Map<String, Object> model = new HashMap<>();
            model.put("modules", modules);
            model.put("properties", gwtConfigProps);

            FileObject sourceFile = filer.createResource(StandardLocation.SOURCE_OUTPUT, MODULE_PACKAGENAME,
                    MODULE_FILENAME);
            OutputStream output = sourceFile.openOutputStream();
            new TemplateProcessor().process(MODULE_TEMPLATE, model, output);
            output.flush();
            output.close();
            System.out.println("Written GWT module to " + sourceFile.toUri().toString());
        } catch (IOException e) {
            throw new RuntimeException("Failed to create file", e);
        }
    }
View Full Code Here

        try {
            Map<String, Object> model = new HashMap<>();
            model.put("modules", modules);
            model.put("properties", gwtConfigProps);

            FileObject sourceFile = filer.createResource(StandardLocation.SOURCE_OUTPUT, MODULE_PACKAGENAME,
                    MODULE_DEV_FILENAME);
            OutputStream output = sourceFile.openOutputStream();
            new TemplateProcessor().process(MODULE_DEV_TEMPLATE, model, output);
            output.flush();
            output.close();
            System.out.println("Written GWT dev module to " + sourceFile.toUri().toString());
        } catch (IOException e) {
            throw new RuntimeException("Failed to create file", e);
        }
    }
View Full Code Here

        try {
            Map<String, Object> model = new HashMap<>();
            model.put("modules", modules);
            model.put("properties", gwtConfigProps);

            FileObject sourceFile = filer.createResource(StandardLocation.SOURCE_OUTPUT, MODULE_PACKAGENAME,
                    MODULE_PRODUCT_FILENAME);
            OutputStream output = sourceFile.openOutputStream();
            new TemplateProcessor().process(MODULE_PRODUCT_TEMPLATE, model, output);
            output.flush();
            output.close();
        } catch (IOException e) {
            throw new RuntimeException("Failed to create file", e);
View Full Code Here

        try {
            Map<String, Object> model = new HashMap<>();
            model.put("modules", modules);
            model.put("properties", gwtConfigProps);

            FileObject sourceFile = filer.createResource(StandardLocation.SOURCE_OUTPUT, MODULE_PACKAGENAME,
                    MODULE_PRODUCT_DEV_FILENAME);
            OutputStream output = sourceFile.openOutputStream();
            new TemplateProcessor().process(MODULE_PRODUCT_DEV_TEMPLATE, model, output);
            output.flush();
            output.close();
        } catch (IOException e) {
            throw new RuntimeException("Failed to create file", e);
View Full Code Here

                    processingEnv.getOptions().get("console.dev.host") : "127.0.0.1";

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

            FileObject sourceFile = filer.createResource(
                    StandardLocation.SOURCE_OUTPUT, "", "gwt-proxy.properties");
            OutputStream output1 = sourceFile.openOutputStream();

            FileObject sourceFile2 = filer.createResource(
                    StandardLocation.SOURCE_OUTPUT, "", "upload-proxy.properties");
            OutputStream output2 = sourceFile2.openOutputStream();

            FileObject sourceFile3 = filer.createResource(
                    StandardLocation.SOURCE_OUTPUT, "", "logout.properties");
            OutputStream output3 = sourceFile3.openOutputStream();

            new TemplateProcessor().process("gwt.proxy.tmpl", model, output1);
            new TemplateProcessor().process("gwt.proxy.upload.tmpl", model, output2);
            new TemplateProcessor().process("gwt.proxy.logout.tmpl", model, output3);
View Full Code Here

     */
    protected InputStream getInputStream(String filename, boolean loadingPersistenceXML) {
        InputStream inputStream = null;
       
        try {
            FileObject fileObject = getFileObject(filename, processingEnv);
            inputStream = fileObject.openInputStream();
        } catch (Exception ioe) {
            // If we can't find the persistence.xml from the class output
            // we'll try from the current directory using regular IO.
            try {
                inputStream = new FileInputStream(filename);
View Full Code Here

TOP

Related Classes of javax.tools.FileObject

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.