Class ServiceDescriptor

java.lang.Object
org.distributeme.core.ServiceDescriptor
All Implemented Interfaces:
Serializable, Cloneable

public class ServiceDescriptor extends Object implements Serializable, Cloneable
This class represents a resolvable address of a service. A server address is build up like following: <protocol>://<serviceid>.<instanceid>@<host>:<port>
Version:
$Id: $Id
Author:
lrosenberg
See Also:
  • Field Details

    • PROTOCOL_SEPARATOR

      public static final String PROTOCOL_SEPARATOR
      Separator between protocol part of the descriptor and the rest of the descriptor.
      See Also:
    • HOST_SEPARATOR

      public static final char HOST_SEPARATOR
      Separator between host part and interface part in the string representation.
      See Also:
    • PORT_SEPARATOR

      public static final char PORT_SEPARATOR
      Separator between host and port.
      See Also:
    • INSTANCE_SEPARATOR

      public static final char INSTANCE_SEPARATOR
      Separator between serviceId and instanceId.
      See Also:
    • TIMESTAMP_SEPARATOR

      public static final char TIMESTAMP_SEPARATOR
      Separator between port and startup timestamp.
      See Also:
  • Constructor Details

  • Method Details

    • getGlobalServiceId

      public String getGlobalServiceId()

      getGlobalServiceId.

      Returns:
      a String object.
    • getRegistrationString

      public String getRegistrationString()

      getRegistrationString.

      Returns:
      a String object.
    • getLookupString

      public String getLookupString()

      getLookupString.

      Returns:
      a String object.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSystemWideUniqueId

      public final String getSystemWideUniqueId()

      getSystemWideUniqueId.

      Returns:
      a String object.
    • getTimestamp

      public long getTimestamp()

      Getter for the field timestamp.

      Returns:
      a long.
    • fromSystemWideUniqueId

      public static final ServiceDescriptor fromSystemWideUniqueId(String systemWideUniqueId)
      Virtually the same as fromRegistrationString but better named ;-).
      Parameters:
      systemWideUniqueId - a String object.
      Returns:
      a ServiceDescriptor object.
    • fromRegistrationString

      public static final ServiceDescriptor fromRegistrationString(String registrationString)
      Factory method to create a service descriptor from a registration string (used for bind in the registry).
      Parameters:
      registrationString - a String object.
      Returns:
      a ServiceDescriptor object.
    • fromResolveString

      public static final ServiceDescriptor fromResolveString(String resolveString)
      Factory method to create a service descriptor from a resolve string (used for lookup in the registry).
      Parameters:
      resolveString - a String object.
      Returns:
      a ServiceDescriptor object.
    • changeServiceId

      public ServiceDescriptor changeServiceId(String aServiceId)
      Changes the service id in the descriptor to another id. This is useful if you want to access a not publicly registered service (like eventservice or lifecycle servce) via the public service id from the registry.
      Parameters:
      aServiceId - a String object.
      Returns:
      new service descriptor with altered service id.
    • hashCode

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

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

      public boolean equalsByEndpoint(ServiceDescriptor anotherDescriptor)
      This method is similar to equals but it ignores instance id. The idea is here, that two ServiceDescriptors with same service id, port and host will point to same endpoint. In some cases we want to prevent double messages to such an endpoint (i.e. event service).
      Parameters:
      anotherDescriptor - another service descriptor.
      Returns:
    • getHost

      public String getHost()

      Getter for the field host.

      Returns:
      a String object.
    • getPort

      public int getPort()

      Getter for the field port.

      Returns:
      a int.
    • getProtocol

      public String getProtocol()

      Getter for the field protocol.

      Returns:
      a String object.
    • getServiceId

      public String getServiceId()

      Getter for the field serviceId.

      Returns:
      a String object.
    • getInstanceId

      public String getInstanceId()

      Getter for the field instanceId.

      Returns:
      a String object.
    • getTimeString

      public static String getTimeString(long timestamp)

      getTimeString.

      Parameters:
      timestamp - a long.
      Returns:
      a String object.
    • parseTimeString

      public static long parseTimeString(String s)

      parseTimeString.

      Parameters:
      s - a String object.
      Returns:
      a long.