org.openide.util.lookup.implspi

## Class AbstractServiceProviderProcessor

- java.lang.Object
- - javax.annotation.processing.AbstractProcessor
  - - org.openide.util.lookup.implspi.AbstractServiceProviderProcessor

- All Implemented Interfaces:
    Processor
  Direct Known Subclasses:
    NamedServiceProcessor, ServiceProviderProcessor

      public abstract class AbstractServiceProviderProcessor
      extends AbstractProcessor

  Infrastructure for generating `META-INF/services/*` and `META-INF/namedservices/*` registrations from annotations. From version 8.40, it is not necessary (and is not recommended) to declare
  Since:
    8.1

- - ### Field Summary

    - ### Fields inherited from class javax.annotation.processing.AbstractProcessor

      `processingEnv`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractServiceProviderProcessor()` Throws IllegalStateException.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `SourceVersion` | `getSupportedSourceVersion()` If the subclass itself does not define SupportedSourceVersion, assume latest().
    `protected abstract boolean` | `handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)` The regular body of `process(java.util.Set<? extends javax.lang.model.element.TypeElement>, javax.annotation.processing.RoundEnvironment)`.
    `boolean` | `process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)`
    `protected void` | `register(Element el, Class<? extends Annotation> annotation, TypeMirror type, String path, int position, String... supersedes)` Register a service.
    `protected void` | `register(Element el, String path)`
    `protected void` | `register(TypeElement el, Class<? extends Annotation> annotation, TypeMirror type, String path, int position, String[] supersedes)` Deprecated.

    - ### Methods inherited from class javax.annotation.processing.AbstractProcessor

      `getCompletions, getSupportedAnnotationTypes, getSupportedOptions, init, isInitialized`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractServiceProviderProcessor

          protected AbstractServiceProviderProcessor()

      Throws IllegalStateException. For access by selected subclasses.

  - ### Method Detail

    - #### process

          public final boolean process(Set<? extends TypeElement> annotations,
                                       RoundEnvironment roundEnv)

      Specified by:
        `process` in interface `Processor`
      Specified by:
        `process` in class `AbstractProcessor`

    - #### handleProcess

          protected abstract boolean handleProcess(Set<? extends TypeElement> annotations,
                                                   RoundEnvironment roundEnv)

      The regular body of `process(java.util.Set<? extends javax.lang.model.element.TypeElement>, javax.annotation.processing.RoundEnvironment)`. Called during regular rounds if there are no outstanding errors. In the last round, one of the processors will write out generated registrations.
      Parameters:
        `annotations` - as in `process(java.util.Set<? extends javax.lang.model.element.TypeElement>, javax.annotation.processing.RoundEnvironment)`
        `roundEnv` - as in `process(java.util.Set<? extends javax.lang.model.element.TypeElement>, javax.annotation.processing.RoundEnvironment)`
      Returns:
        as in `process(java.util.Set<? extends javax.lang.model.element.TypeElement>, javax.annotation.processing.RoundEnvironment)`

    - #### register

          protected final void register(Element el,
                                        Class<? extends Annotation> annotation,
                                        TypeMirror type,
                                        String path,
                                        int position,
                                        String... supersedes)

      Register a service. If the class does not have an appropriate signature, an error will be printed and the registration skipped.
      Parameters:
        `clazz` - the service implementation type (an error will be reported if not a `TypeElement`)
        `annotation` - the (top-level) annotation registering the service, for diagnostic purposes
        `type` - the type to which the implementation must be assignable
        `path` - a path under which to register, or "" if inapplicable
        `position` - a position at which to register, or `Integer.MAX_VALUE` to skip
        `supersedes` - possibly empty list of implementation to supersede
      Since:
        8.8

    - #### register

          protected final void register(Element el,
                                        String path)

    - #### register

          @Deprecated
          protected final void register(TypeElement el,
                                                    Class<? extends Annotation> annotation,
                                                    TypeMirror type,
                                                    String path,
                                                    int position,
                                                    String[] supersedes)

      Deprecated.

    - #### getSupportedSourceVersion

          public SourceVersion getSupportedSourceVersion()

      If the subclass itself does not define SupportedSourceVersion, assume latest(). If it does (was recommended prior to 8.40), returns the subclass' value.
      Specified by:
        `getSupportedSourceVersion` in interface `Processor`
      Overrides:
        `getSupportedSourceVersion` in class `AbstractProcessor`
      Returns:
        max supported source version.
      Since:
        8.40

Copyright © 2025 API Design. All Rights Reserved.