Class ServiceID

java.lang.Object
io.inverno.mod.discovery.ServiceID
All Implemented Interfaces:
Serializable

public final class ServiceID extends Object implements Serializable

A service ID identifies a service.

It basically comes down to a service URI with particular constraints:

  • It must be absolute (i.e. have a scheme).
  • It must have an authority component when not opaque.

A service ID can be created with two kinds of service URI: when the URI is an opaque URI, the service ID is obtained from the scheme and the scheme specific part (e.g. scheme:service-name), otherwise it is obtained from the scheme and the authority (e.g. scheme://service-name).

A service URI conveys two information: the service ID and the request target. In case of a an opaque URI, the request target is specified in the fragment component (e.g. scheme:service-name#/path/to/resource?k1=v1&k2=v2), otherwise, the resource target is specified by the path and query components (e.g. scheme://service-name/path/to/resource?k1=v1&k2=v2).

When creating a service ID from a service URI, the request target is evicted because it doesn't identify the service.

Since:
1.12
Author:
Jeremy Kuhn
See Also:
  • Method Details

    • getRequestTarget

      public static String getRequestTarget(URI uri) throws IllegalArgumentException

      Returns the request target in the specified service URI.

      Parameters:
      uri - a service URI
      Returns:
      a request target
      Throws:
      IllegalArgumentException - if the specified URI is not a valid service URI
    • of

      public static ServiceID of(String uri) throws IllegalArgumentException

      Creates a service ID from the specified service URI.

      Parameters:
      uri - a service URI
      Returns:
      a service ID
      Throws:
      IllegalArgumentException - if the specified URI is not a valid service URI
    • of

      public static ServiceID of(URI uri) throws IllegalArgumentException

      Creates a service ID from the specified service URI.

      Parameters:
      uri - a service URI
      Returns:
      a service ID
      Throws:
      IllegalArgumentException - if the specified URI is not a valid service URI
    • getScheme

      public String getScheme()

      Returns the service ID scheme.

      Returns:
      the service ID scheme
    • getURI

      public URI getURI()

      Return the service ID URI.

      Note that the service ID URI doesn't contain the request target.

      Returns:
      the service ID URI
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object