|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.livetribe.slp.ServiceInfo
public class ServiceInfo
This class represents a service, exposed by ServiceAgents and cached by DirectoryAgents.
In SLP, services are distinguished by their ServiceURL
and by their language; these two elements
form the key
of the service. Two service registration with the same key overwrite each other.
IMPLEMENTATION NOTES:
There is an asymmetry in SLP that allows (ServiceURL1, language1)
to be registered under two different ServiceTypes (this is allowed by the format of
SrvReg
), but not deregistered from one ServiceType only (as SrvDeReg
does not support an additional ServiceType field).
Attributes
are not involved in service equality since they can contain
locale-specific information (for example: (color=Yellow)
with language English,
and (color=Giallo)
with language Italian.
ServiceURL
,
Attributes
Nested Class Summary | |
---|---|
static class |
ServiceInfo.Key
Services in SLP are identified by their ServiceURL and their language. |
Constructor Summary | |
---|---|
ServiceInfo(ServiceType serviceType,
ServiceURL serviceURL,
Scopes scopes,
Attributes attributes,
String language)
Creates a ServiceInfo from the given arguments; the ServiceInfo(ServiceURL, Scopes, Attributes, String)
constructor should be preferred to this one, as it does not introduce ambiguity between the
ServiceType argument and the ServiceType of the ServiceURL argument. |
|
ServiceInfo(ServiceURL serviceURL,
Scopes scopes,
Attributes attributes,
String language)
Creates a ServiceInfo from a the given arguments. |
Method Summary | |
---|---|
protected ServiceInfo |
clone(ServiceType serviceType,
ServiceURL serviceURL,
Scopes scopes,
Attributes attributes,
String language)
Returns a new clone of this ServiceInfo with the given arguments. |
static ServiceInfo |
from(SrvDeReg message)
Creates a ServiceInfo from a SrvDeReg message. |
static ServiceInfo |
from(SrvReg message)
Creates a ServiceInfo from a SrvReg message. |
Attributes |
getAttributes()
Returns the Attributes of this ServiceInfo . |
ServiceInfo.Key |
getKey()
Returns the key of this ServiceInfo . |
String |
getLanguage()
Returns the language of this ServiceInfo . |
long |
getRegistrationTime()
Returns the registration time of this ServiceInfo , in milliseconds since the Unix epoch. |
Scopes |
getScopes()
Returns the Scopes of this ServiceInfo . |
ServiceType |
getServiceType()
Returns the ServiceType as provided to the constructors; prefer resolveServiceType()
to get the ServiceType of this ServiceInfo . |
ServiceURL |
getServiceURL()
Returns the ServiceURL of this ServiceInfo . |
boolean |
hasAttributes()
Returns whether this ServiceInfo has attributes or not. |
boolean |
isExpiredAsOf(long time)
Returns true if the ServiceURL 's lifetime is expired, since its registration, as of the specified time. |
ServiceInfo |
merge(ServiceInfo that)
Merges the attributes of this ServiceInfo with the attributes of the given ServiceInfo ,
provided the two ServiceInfo s have the same key . |
ServiceType |
resolveServiceType()
Returns the ServiceType as provided to the
constructor ;
if this value is null, returns the ServiceType of the ServiceURL
of this ServiceInfo . |
void |
setRegistrationTime(long registrationTime)
Set the registration time of this ServiceInfo , in milliseconds since the Unix epoch. |
ServiceInfo |
unmerge(ServiceInfo that)
Unmerges the attributes of this ServiceInfo with the attributes of the given ServiceInfo ,
provided the two ServiceInfo s have the same key . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ServiceInfo(ServiceURL serviceURL, Scopes scopes, Attributes attributes, String language)
ServiceInfo
from a the given arguments.
serviceURL
- The service URL of the servicescopes
- The scopes of the serviceattributes
- The attributes of the servicelanguage
- The language of the servicepublic ServiceInfo(ServiceType serviceType, ServiceURL serviceURL, Scopes scopes, Attributes attributes, String language)
ServiceInfo
from the given arguments; the ServiceInfo(ServiceURL, Scopes, Attributes, String)
constructor should be preferred to this one, as it does not introduce ambiguity between the
ServiceType
argument and the ServiceType
of the ServiceURL
argument.
Method Detail |
---|
public static ServiceInfo from(SrvReg message)
ServiceInfo
from a SrvReg message.
public static ServiceInfo from(SrvDeReg message)
ServiceInfo
from a SrvDeReg message.
public ServiceInfo.Key getKey()
ServiceInfo
.
public ServiceType getServiceType()
ServiceType
as provided to the constructors; prefer resolveServiceType()
to get the ServiceType
of this ServiceInfo
.
resolveServiceType()
public ServiceURL getServiceURL()
ServiceURL
of this ServiceInfo
.
public Scopes getScopes()
Scopes
of this ServiceInfo
.
public Attributes getAttributes()
Attributes
of this ServiceInfo
.
public boolean hasAttributes()
ServiceInfo
has attributes or not.
public String getLanguage()
ServiceInfo
.
public ServiceType resolveServiceType()
ServiceType
as provided to the
constructor
;
if this value is null, returns the ServiceType
of the ServiceURL
of this ServiceInfo
.
public ServiceInfo merge(ServiceInfo that)
ServiceInfo
with the attributes of the given ServiceInfo
,
provided the two ServiceInfo
s have the same key
.
that
- The ServiceInfo
to merge with
ServiceInfo
, result of the merge, or null if this ServiceInfo
and the given ServiceInfo
do not have the same key
.Attributes.merge(Attributes)
public ServiceInfo unmerge(ServiceInfo that)
ServiceInfo
with the attributes of the given ServiceInfo
,
provided the two ServiceInfo
s have the same key
.
that
- The ServiceInfo
to unmerge with
ServiceInfo
, result of the unmerge, or null if this ServiceInfo
and the given ServiceInfo
do not have the same key
.Attributes.unmerge(Attributes)
protected ServiceInfo clone(ServiceType serviceType, ServiceURL serviceURL, Scopes scopes, Attributes attributes, String language)
ServiceInfo
with the given arguments.
Subclasses may override to clone additional state.
public long getRegistrationTime()
ServiceInfo
, in milliseconds since the Unix epoch.
public void setRegistrationTime(long registrationTime)
ServiceInfo
, in milliseconds since the Unix epoch.
public boolean isExpiredAsOf(long time)
ServiceURL
's lifetime is expired, since its registration, as of the specified time.
time
- The time, in milliseconds, to check if the lifetime is expired.getRegistrationTime()
,
ServiceURL.getLifetime()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |