org.openide.util.lookup

## Annotation Type NamedServiceDefinition

-     @Retention(value=RUNTIME)
       @Target(value=ANNOTATION_TYPE)
      public @interface NamedServiceDefinition

  Annotation to simplify creation and add robustness to usage of various named service registration annotations. For example the `@` URLStreamHandlerRegistration annotation uses the `NamedServiceDefinition` as:

        @NamedServiceDefinition(path="URLStreamHandler/@protocol()", serviceType=URLStreamHandler.class)

  The above instructs the annotation processor that handles `NamedServiceDefinition`s to verify the annotated type is subclass of `URLStreamHandler` and if so, register it into `URLStreamHandler/@protocol` where the value of `@protocol()` is replaced by the value of annotation's protocol attribute. The registration can later be found by using `Lookups.forPath("URLStreamHandler/ftp")` (in case the protocol was ftp).
  Since:
    8.14
  Author:
    Jaroslav Tulach
  See Also:
    `ServiceProvider.path()`

- - ### Required Element Summary

    Required Elements
    Modifier and Type | Required Element and Description
    --- | ---
    `String` | `path` Path to register the annotation to, so it can later be found by using `Lookups.forPath(theSamePath)`.
    `Class<?>[]` | `serviceType` Type, or array of types that the registered type has to implement.

  - ### Optional Element Summary

    Optional Elements
    Modifier and Type | Optional Element and Description
    --- | ---
    `String` | `position` Name of attribute that specifies position.

- - ### Element Detail

    - #### serviceType

          public abstract Class<?>[] serviceType

      Type, or array of types that the registered type has to implement. The annotated type needs to register at least one of the enumerated classes.

  - - #### path

          public abstract String path

      Path to register the annotation to, so it can later be found by using `Lookups.forPath(theSamePath)`. The path may reference attributes of the annotated annotation by prefixing them with `@`. To reuse attribute named `location` one can for example use `"how/to/get/to/@location()s/please"` These attributes must be of type `String` or array of `String`s (then one registration is performed per each string in the array).

  - - #### position

          public abstract String position

      Name of attribute that specifies position. By default the system tries to find `int position()` attribute in the defined annotation and use it to specify the order of registrations. In case a different attribute should be used to specify the position, one can be provide its name by specifying non-default here. Should the position be ignored, specify empty string.
      Parameters:
        `name` - of attribute in the annotated annotation to use for defining position of the registration. The attribute should return int value.
      Default:
        "-"

Copyright © 2025 API Design. All Rights Reserved.