Class AutoServiceProcessor

  • All Implemented Interfaces:
    javax.annotation.processing.Processor

    @SupportedOptions({"debug","verify"})
    public class AutoServiceProcessor
    extends javax.annotation.processing.AbstractProcessor
    Processes AutoService annotations and generates the service provider configuration files described in ServiceLoader.

    Processor Options:

    • -Adebug - turns on debug statements
    • -Averify=true - turns on extra verification
    • Field Summary

      • Fields inherited from class javax.annotation.processing.AbstractProcessor

        processingEnv
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.common.collect.ImmutableSet<java.lang.String> getSupportedAnnotationTypes()  
      javax.lang.model.SourceVersion getSupportedSourceVersion()  
      boolean process​(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations, javax.annotation.processing.RoundEnvironment roundEnv)
      For each class annotated with AutoService Verify the AutoService interface value is correct Categorize the class by its service interface For each AutoService interface Create a file named META-INF/services/<interface> For each AutoService annotated class for this interface Create an entry in the file
      • Methods inherited from class javax.annotation.processing.AbstractProcessor

        getCompletions, getSupportedOptions, init, isInitialized
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AutoServiceProcessor

        public AutoServiceProcessor()
    • Method Detail

      • getSupportedAnnotationTypes

        public com.google.common.collect.ImmutableSet<java.lang.String> getSupportedAnnotationTypes()
        Specified by:
        getSupportedAnnotationTypes in interface javax.annotation.processing.Processor
        Overrides:
        getSupportedAnnotationTypes in class javax.annotation.processing.AbstractProcessor
      • getSupportedSourceVersion

        public javax.lang.model.SourceVersion getSupportedSourceVersion()
        Specified by:
        getSupportedSourceVersion in interface javax.annotation.processing.Processor
        Overrides:
        getSupportedSourceVersion in class javax.annotation.processing.AbstractProcessor
      • process

        public boolean process​(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations,
                               javax.annotation.processing.RoundEnvironment roundEnv)
        1. For each class annotated with AutoService
          • Verify the AutoService interface value is correct
          • Categorize the class by its service interface
        2. For each AutoService interface
          • Create a file named META-INF/services/<interface>
          • For each AutoService annotated class for this interface
            • Create an entry in the file
        Specified by:
        process in interface javax.annotation.processing.Processor
        Specified by:
        process in class javax.annotation.processing.AbstractProcessor