Package org.distributeme.core
Class ServiceDescriptor
java.lang.Object
org.distributeme.core.ServiceDescriptor
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charSeparator between host part and interface part in the string representation.static final charSeparator between serviceId and instanceId.static final charSeparator between host and port.static final StringSeparator between protocol part of the descriptor and the rest of the descriptor.static final charSeparator between port and startup timestamp. -
Constructor Summary
ConstructorsConstructorDescriptionServiceDescriptor(ServiceDescriptor.Protocol aProtocol, String aServiceId) This constructor is used for the lookup.ServiceDescriptor(ServiceDescriptor.Protocol aProtocol, String aServiceId, String anInstanceId, String aHost, int aPort) This constructor is used for registration.ServiceDescriptor(ServiceDescriptor.Protocol aProtocol, String aServiceId, String anInstanceId, String aHost, int aPort, long aTimestamp) Constructor for ServiceDescriptor. -
Method Summary
Modifier and TypeMethodDescriptionchangeServiceId(String aServiceId) Changes the service id in the descriptor to another id.booleanbooleanequalsByEndpoint(ServiceDescriptor anotherDescriptor) This method is similar to equals but it ignores instance id.static final ServiceDescriptorfromRegistrationString(String registrationString) Factory method to create a service descriptor from a registration string (used for bind in the registry).static final ServiceDescriptorfromResolveString(String resolveString) Factory method to create a service descriptor from a resolve string (used for lookup in the registry).static final ServiceDescriptorfromSystemWideUniqueId(String systemWideUniqueId) Virtually the same as fromRegistrationString but better named ;-).getGlobalServiceId.getHost()Getter for the fieldhost.Getter for the fieldinstanceId.getLookupString.intgetPort()Getter for the fieldport.Getter for the fieldprotocol.getRegistrationString.Getter for the fieldserviceId.final StringgetSystemWideUniqueId.longGetter for the fieldtimestamp.static StringgetTimeString(long timestamp) getTimeString.inthashCode()static longparseTimeString.toString()
-
Field Details
-
PROTOCOL_SEPARATOR
Separator between protocol part of the descriptor and the rest of the descriptor.- See Also:
-
HOST_SEPARATOR
public static final char HOST_SEPARATORSeparator between host part and interface part in the string representation.- See Also:
-
PORT_SEPARATOR
public static final char PORT_SEPARATORSeparator between host and port.- See Also:
-
INSTANCE_SEPARATOR
public static final char INSTANCE_SEPARATORSeparator between serviceId and instanceId.- See Also:
-
TIMESTAMP_SEPARATOR
public static final char TIMESTAMP_SEPARATORSeparator between port and startup timestamp.- See Also:
-
-
Constructor Details
-
ServiceDescriptor
public ServiceDescriptor(ServiceDescriptor.Protocol aProtocol, String aServiceId, String anInstanceId, String aHost, int aPort) This constructor is used for registration.- Parameters:
aProtocol- aServiceDescriptor.Protocolobject.aServiceId- aStringobject.anInstanceId- aStringobject.aHost- aStringobject.aPort- a int.
-
ServiceDescriptor
public ServiceDescriptor(ServiceDescriptor.Protocol aProtocol, String aServiceId, String anInstanceId, String aHost, int aPort, long aTimestamp) Constructor for ServiceDescriptor.
- Parameters:
aProtocol- aServiceDescriptor.Protocolobject.aServiceId- aStringobject.anInstanceId- aStringobject.aHost- aStringobject.aPort- a int.aTimestamp- a long.
-
ServiceDescriptor
This constructor is used for the lookup.- Parameters:
aProtocol- aServiceDescriptor.Protocolobject.aServiceId- aStringobject.
-
-
Method Details
-
getGlobalServiceId
getGlobalServiceId.
- Returns:
- a
Stringobject.
-
getRegistrationString
getRegistrationString.
- Returns:
- a
Stringobject.
-
getLookupString
getLookupString.
- Returns:
- a
Stringobject.
-
toString
-
getSystemWideUniqueId
getSystemWideUniqueId.
- Returns:
- a
Stringobject.
-
getTimestamp
public long getTimestamp()Getter for the field
timestamp.- Returns:
- a long.
-
fromSystemWideUniqueId
Virtually the same as fromRegistrationString but better named ;-).- Parameters:
systemWideUniqueId- aStringobject.- Returns:
- a
ServiceDescriptorobject.
-
fromRegistrationString
Factory method to create a service descriptor from a registration string (used for bind in the registry).- Parameters:
registrationString- aStringobject.- Returns:
- a
ServiceDescriptorobject.
-
fromResolveString
Factory method to create a service descriptor from a resolve string (used for lookup in the registry).- Parameters:
resolveString- aStringobject.- Returns:
- a
ServiceDescriptorobject.
-
changeServiceId
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- aStringobject.- Returns:
- new service descriptor with altered service id.
-
hashCode
public int hashCode() -
equals
-
equalsByEndpoint
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
Getter for the field
host.- Returns:
- a
Stringobject.
-
getPort
public int getPort()Getter for the field
port.- Returns:
- a int.
-
getProtocol
Getter for the field
protocol.- Returns:
- a
Stringobject.
-
getServiceId
Getter for the field
serviceId.- Returns:
- a
Stringobject.
-
getInstanceId
Getter for the field
instanceId.- Returns:
- a
Stringobject.
-
getTimeString
getTimeString.
- Parameters:
timestamp- a long.- Returns:
- a
Stringobject.
-
parseTimeString
parseTimeString.
- Parameters:
s- aStringobject.- Returns:
- a long.
-