Annotation Interface Service


@Qualifier @Documented @Retention(RUNTIME) @Target({PARAMETER,FIELD}) public @interface Service
This annotation enables the use of registered services from the service registry in an injection context.

Instead of doing something like:


  @Inject
  public TestClass(ServiceRegistry registry) {
    var playerManager = registry.defaultInstance(PlayerManager.class);
    playerManager.onlineCount();
  }

Using this annotation you can do something like:

  @Inject
  public TestClass(@Service PlayerManager playerManager) {
    playerManager.onlineCount();
  }

Note: If a service or a service name is requested that the service registry does not know null is passed as parameter value.

Since:
4.0
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The name of the registered provider in the service registry.
  • Element Details

    • name

      The name of the registered provider in the service registry. Leave empty if the name of the provider is not important and any provider with a matching class is accepted.
      Returns:
      name of the registered provider in the service registry.
      Default:
      ""