org.isam.exehda
Class ApplicationId

java.lang.Object
  |
  +--org.isam.exehda.HierarchicalId
        |
        +--org.isam.exehda.ApplicationId
All Implemented Interfaces:
java.io.Serializable

public final class ApplicationId
extends HierarchicalId

Uniquely identifies an application in the scope os the distributed system. In order to guarantee unicity, a hierarchical approach is used to generate these identifiers. The id itself is built up of two parts:

Currently, local id is generated by taking a snapshot of the system current time, through System.currentTimeMillis(). These technique should be replaced in future by a strong-random number generation mechanism in order to improve system's security (by making harder for one to forge a valid Id).

Version:
$Date: 2004/12/16 19:46:04 $ $Revision: 1.8 $
Author:
last modified by $Author: lucc $
See Also:
Serialized Form

Constructor Summary
ApplicationId()
          Deprecated. Generating local id through System.currentTimeMillis() is not very secure.
ApplicationId(long localId)
          Creates a new ApplicationId instance using the provided id as application's local id.
 
Method Summary
 boolean equals(java.lang.Object o)
          Returns whether this ApplicationId is equals to the given object.
 HostId getBaseHost()
          Returns the host where the application referred by these ApplicationId was first started (launched).
protected  java.lang.Object getLocalId()
          Subclasses must overwrite this method and return an Object representation of the local id.
protected  java.lang.String getType()
          Subclasses must overwrite this method and return a String representation of the ID's type.
 int hashCode()
          Returns a hash code for these object suitable for the java.util.Hashtable() semantics.
 
Methods inherited from class org.isam.exehda.HierarchicalId
getParentId, isRoot, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ApplicationId

public ApplicationId(long localId)
Creates a new ApplicationId instance using the provided id as application's local id. The base host (parent ID) is set to HostId.getLocalHost().

Parameters:
localId - a long value
To do:
Perhaps localId should by a byte[]

ApplicationId

public ApplicationId()
Deprecated. Generating local id through System.currentTimeMillis() is not very secure.

Creates a new ApplicationId instance. Equivalent to using:

new ApplicationId(System.currentTimeMillis());

Such approach leads to deterministic ApplicationId generation, so it must be used for debugging purposes only. Using the ApplicationId(long) constructor combined with a strong random number generator is highly encouraged.

Method Detail

getBaseHost

public HostId getBaseHost()
Returns the host where the application referred by these ApplicationId was first started (launched).

Returns:
the HostId of the application's base host.

equals

public boolean equals(java.lang.Object o)
Returns whether this ApplicationId is equals to the given object. Two ApplicationIds are said tobe equal if and only if their base hosts and loca ids are equals.

Overrides:
equals in class HierarchicalId
Parameters:
o - an Object value
Returns:
a boolean value

hashCode

public int hashCode()
Returns a hash code for these object suitable for the java.util.Hashtable() semantics. This is currently a bitwise xor between the low 32 bits of the local id and the hash code provided by the base Host.

Overrides:
hashCode in class HierarchicalId
Returns:
a hash code.

getType

protected final java.lang.String getType()
Description copied from class: HierarchicalId
Subclasses must overwrite this method and return a String representation of the ID's type.

Specified by:
getType in class HierarchicalId
Returns:
a String value

getLocalId

protected final java.lang.Object getLocalId()
Description copied from class: HierarchicalId
Subclasses must overwrite this method and return an Object representation of the local id. Notice that, subclasses may actually store such ID using primitive types, in order to be more efficient, and just wrap such values in an Object when getLocalId() is invoked.

Specified by:
getLocalId in class HierarchicalId
Returns:
an Object value