package org.jfox.ejb;
import java.io.Serializable;
import java.net.InetAddress;
public class ObjectId implements Serializable {
private static String IPAddress = "127.0.0.1";
static {
try {
IPAddress = InetAddress.getLocalHost().getHostAddress();
}
catch(Exception e){
}
};
public final static String CONTAINER_IDENTITY = IPAddress + "-" + Long.toString(System.currentTimeMillis());
private String identity = CONTAINER_IDENTITY;
private String ipAddress;
private String remoteInterf;
private String homeInterf;
private int hash;
private boolean isHome;
ObjectId(String ipAddress,String homeInterf,String remoteInterf, int hash, boolean isHome) {
this.ipAddress = ipAddress;
this.homeInterf = homeInterf;
this.remoteInterf = remoteInterf;
this.hash = hash;
this.isHome = isHome;
}
public String toString() {
StringBuffer sb = new StringBuffer();
if(isHome){
sb.append(homeInterf);
}
else {
sb.append(remoteInterf);
}
sb.append("@").append(hash);
return sb.toString();
}
public String getRemoteInterfaceName() {
return remoteInterf;
}
public String getHomeInterfName() {
return homeInterf;
}
public boolean isHome(){
return isHome;
}
public String getIpAddress() {
return ipAddress;
}
public int hashCode() {
return hash;
}
public String getStringObjectId() {
return this.toString();
}
public boolean equals(Object obj) {
if(!(obj instanceof ObjectId)) return false;
return ((ObjectId)obj).getStringObjectId().equals(this.getStringObjectId());
}
public String getIdentity(){
return identity;
}
}