Class Record


  • public class Record
    extends Object
    Describes a `service`. The record is the only piece of information shared between consumer and provider. It should contains enough metadata to let consumer find the service they want.
    Author:
    Clement Escoffier
    • Constructor Detail

      • Record

        public Record()
        Creates a new Record.
      • Record

        public Record​(JsonObject json)
        Creates a new Record from its json representation.
        Parameters:
        json - the json object
      • Record

        public Record​(Record other)
        Creates a new Record by copying the values from another Record.
        Parameters:
        other - the record to copy
    • Method Detail

      • toJson

        public JsonObject toJson()
        Returns:
        the JSON representation of the current Record.
      • getLocation

        public JsonObject getLocation()
        Returns:
        the json object describing the location of the service. By convention, this json object should contain the ENDPOINT entry.
      • setLocation

        public Record setLocation​(JsonObject location)
        Sets the json object describing the location of the service. By convention, this json object should contain the ENDPOINT entry.
        Parameters:
        location - the location
        Returns:
        the current Record
      • getMetadata

        public JsonObject getMetadata()
        Gets the metadata attached to the record.
        Returns:
        the metadata, cannot be null.
      • getName

        public String getName()
        Gets the name of the service. It can reflect the service name of the name of the provider.
        Returns:
        the name
      • setName

        public Record setName​(String name)
        Sets the name of the service. It can reflect the service name of the name of the provider.
        Parameters:
        name - the name
        Returns:
        the current Record
      • getStatus

        public Status getStatus()
        Gets the current status of the service.
        Returns:
        the status.
      • setStatus

        public Record setStatus​(Status status)
        Sets the status of the service. When published, the status is set toStatus.UP. When withdrawn, the status is set to Status.DOWN.
        Parameters:
        status - the status, must not be null
        Returns:
        the current Record
      • setRegistration

        public Record setRegistration​(String reg)
        Sets the registration id. This method is called when the service is published.
        Parameters:
        reg - the registration id
        Returns:
        the current Record
      • getRegistration

        public String getRegistration()
        Gets the registration id if any. Getting a null result means that the record has not been published.
        Returns:
        the registration id.
      • getType

        public String getType()
        Gets the service type. The type represents what kind of "resource" is represented by this record. For example it can be "http-endpoint", "database", "message-source"... The set of types is extensible.

        The type defines how the the service object is retrieved, and also manages the binding. Some records may have no type and let the consumer manage how the service is used.

        Returns:
        the type
      • setType

        public Record setType​(String type)
        Sets the type of service.
        Parameters:
        type - the type
        Returns:
        the current Record
      • match

        public boolean match​(JsonObject filter)
        Checks whether or not the current Record matches the filter.
        Parameters:
        filter - the filter
        Returns:
        whether or not the record matches the filter
      • equals

        public boolean equals​(Object o)
        Checks whether or not the current object is equal to the given object.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to compare to this service record
        Returns:
        true when equal, false otherwise
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
        Returns:
        the hash code of the current service record