jvm.server
Class ServerID

java.lang.Object
  |
  +--jvm.server.ServerID

public final class ServerID
extends java.lang.Object
implements java.io.Serializable

A simple server identification information wrapping class. The server is a special entity which actually defines some subgroups of entities sharing the same server (running on the same host:port jvm server). Every EntityID has a associated ServerID defining the server it is running in.

Written: Radu Sion
Version: 0.17x
Source: ServerID.java

Visit Smart Software 

See Also:
EntityID, Serialized Form

Field Summary
static ServerID currentServerID
          This should NOT be used for direct connection purposes.
 java.lang.String Host
          The host on which this entity runs.
 long Port
          The port on which this entity's server runs.
 java.lang.String Protocol
          The protocol by which this entity is accessible.
 
Constructor Summary
ServerID()
          Fake constructor.
ServerID(java.lang.String host, long port)
          Creates a new ServerID object.
ServerID(java.lang.String host, long port, java.lang.String protocol)
          Creates a new ServerID object.
 
Method Summary
 boolean equals(java.lang.Object obj)
          We're implemeneting this in order to use properly hash facilities.
static ServerID fromString(java.lang.String descc)
          Generates a ServerID object from a string provided in a form similar to the output of .toString().
 int hashCode()
nbsp;         We're implementing this in order to use properly hash facilities.
 java.lang.String toString()
          Returns the string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

currentServerID

public static ServerID currentServerID
This should NOT be used for direct connection purposes. It may be rather used to identify the current server, after connection & login.

Host

public java.lang.String Host
The host on which this entity runs. We recomend to use inet addresses in 4 digit decimal 3 dot notation for this. (Ex. 193.226.143.17)

Port

public long Port
The port on which this entity's server runs. If 0 then it's the current server.

Protocol

public java.lang.String Protocol
The protocol by which this entity is accessible. Not used yet.
Constructor Detail

ServerID

public ServerID()
Fake constructor.

ServerID

public ServerID(java.lang.String host,
                long port,
                java.lang.String protocol)
Creates a new ServerID object. The host gets transformed into xxx.xxx.xxx.xxx notation address. The host & protocol parameter gets transformed to lowercase before storing. No parameter checkings performed.

ServerID

public ServerID(java.lang.String host,
                long port)
Creates a new ServerID object. No parameter checkings performed.
Method Detail

toString

public java.lang.String toString()
Returns the string representation of this object. A valid representation should be "jvm://my.host.com:7007". The string is trimmed upon return. (no start/end spaces)
Overrides:
toString in class java.lang.Object
See Also:
GroupID.toString()

fromString

public static ServerID fromString(java.lang.String descc)
Generates a ServerID object from a string provided in a form similar to the output of .toString(). It ignores any other text following a valid ServerID string description.
Returns:
null if error, a ServerID object otherwise

equals

public boolean equals(java.lang.Object obj)
We're implemeneting this in order to use properly hash facilities. We should work more on detecting irrelevant hostname changes that is maybe "141.85.149.2" is the same as "sunsite.pub.ro" ! (not implemented yet) For now we just test the strings ;( In this implementation we assume that two ServerID objects are equal if they have the same string representation. We recommend thus to use inet address strings instead of host names.
Overrides:
equals in class java.lang.Object
See Also:
hashCode(), EntityID

hashCode

public int hashCode()
We're implementing this in order to use properly hash facilities. In this implementation we just return the hashcode of the string representation of this object via toString().
Overrides:
hashCode in class java.lang.Object