Skip to content

@Named annotations should be used as service discriminator if present #3

Description

@cjbooms

The annotation processor should look for the presence of a javax.inject.Named annotation on the current javax.lang.model.element.Element being processed. Be that a class annotated with @ServiceExport, or a field or parameter annotated with @ServiceImport

This can easily be checked using:

javax.inject.Named named = componentClazz.getAnnotation(javax.inject.Named.class);

If present, the value should be used as a discriminator when generating the Peaberry imports and exports. For example:

                bind(export(ServiceOne.class))
                        .annotatedWith(Names.named("someBeanName"))
                        .toProvider(service(ServiceOneImpl.class)
                                .attributes(attributes)
                                .export());

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions