Class AutoServiceProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
com.google.auto.service.processor.AutoServiceProcessor
- All Implemented Interfaces:
Processor
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
FieldsModifier and TypeFieldDescription(package private) static final StringMaps the class names of service provider interfaces to the class names of the concrete classes which implement them.Fields inherited from class AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancheckImplementer(TypeElement providerImplementer, TypeElement providerType, AnnotationMirror annotationMirror) Verifiesconstraints on the concrete provider class.invalid reference
ServiceProviderprivate voiderror(String msg, Element element, AnnotationMirror annotation) private voidfatalError(String msg) private voidprivate StringgetBinaryName(TypeElement element) Returns the binary name of a reference type.private StringgetBinaryNameImpl(TypeElement element, String className) com.google.common.collect.ImmutableSet<String> private com.google.common.collect.ImmutableSet<DeclaredType> getValueFieldOfClasses(AnnotationMirror annotationMirror) Returns the contents of aClass[]-typed "value" field in a givenannotationMirror.private voidbooleanprocess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) For each class annotated withAutoServiceVerify theAutoServiceinterface value is correct Categorize the class by its service interface For eachAutoServiceinterface Create a file namedMETA-INF/services/<interface>For eachAutoServiceannotated class for this interface Create an entry in the fileprivate voidprocessAnnotations(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) private voidprocessImpl(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) private static booleanrawTypesSuppressed(Element element) private voidwarning(String msg, Element element, AnnotationMirror annotation) Methods inherited from class AbstractProcessor
getCompletions, getSupportedOptions, init, isInitialized
-
Field Details
-
MISSING_SERVICES_ERROR
- See Also:
-
providers
Maps the class names of service provider interfaces to the class names of the concrete classes which implement them.For example,
"com.google.apphosting.LocalRpcService" -> "com.google.apphosting.datastore.LocalDatastoreService"
-
-
Constructor Details
-
AutoServiceProcessor
public AutoServiceProcessor()
-
-
Method Details
-
getSupportedAnnotationTypes
- Specified by:
getSupportedAnnotationTypesin interfaceProcessor- Overrides:
getSupportedAnnotationTypesin classAbstractProcessor
-
getSupportedSourceVersion
- Specified by:
getSupportedSourceVersionin interfaceProcessor- Overrides:
getSupportedSourceVersionin classAbstractProcessor
-
process
- For each class annotated with
AutoService- Verify the
AutoServiceinterface value is correct - Categorize the class by its service interface
- Verify the
- For each
AutoServiceinterface- Create a file named
META-INF/services/<interface> - For each
AutoServiceannotated class for this interface- Create an entry in the file
- Create a file named
- Specified by:
processin interfaceProcessor- Specified by:
processin classAbstractProcessor
- For each class annotated with
-
processImpl
-
processAnnotations
-
generateConfigFiles
private void generateConfigFiles() -
checkImplementer
private boolean checkImplementer(TypeElement providerImplementer, TypeElement providerType, AnnotationMirror annotationMirror) Verifiesconstraints on the concrete provider class. Note that these constraints are enforced at runtime via the ServiceLoader, we're just checking them at compile time to be extra nice to our users.invalid reference
ServiceProvider -
rawTypesSuppressed
-
getBinaryName
Returns the binary name of a reference type. For example,com.google.Foo$Bar, instead ofcom.google.Foo.Bar. -
getBinaryNameImpl
-
getValueFieldOfClasses
private com.google.common.collect.ImmutableSet<DeclaredType> getValueFieldOfClasses(AnnotationMirror annotationMirror) Returns the contents of aClass[]-typed "value" field in a givenannotationMirror. -
log
-
warning
-
error
-
fatalError
-