FileDocCategorySizeDatePackage
EJBTargetKeyInfo.javaAPI DocGlassfish v2 API6211Thu Aug 30 23:54:18 BST 2007com.sun.enterprise.iiop

EJBTargetKeyInfo

public class EJBTargetKeyInfo extends Object

Fields Summary
protected static final Logger
_logger
public static final int
EJBID_OFFSET
public static final int
INSTANCEKEYLEN_OFFSET
public static final int
INSTANCEKEY_OFFSET
public static final byte
HOME_KEY
private byte[]
oid
private long
containerId
private int
keyLength
private boolean
local
private Object
instanceKey
private boolean
validOid
private com.sun.ejb.base.sfsb.util.SimpleKeyGenerator
gen
Constructors Summary
public EJBTargetKeyInfo(byte[] oid, boolean local)

    
         
        this.oid = oid;
        this.local = local;
        
        this.instanceKey = gen.byteArrayToKey(oid, INSTANCEKEY_OFFSET, 20);
        validate();
    
public EJBTargetKeyInfo(org.omg.CORBA.Object effective_target)

        try {
            if (StubAdapter.isStub(effective_target)) {
                if (StubAdapter.isLocal(effective_target)) {
                    this.local = true;
                }
                IOR ior = ((com.sun.corba.ee.spi.orb.ORB) ORBManager.getORB())
                    .getIOR(effective_target, false);
                java.util.Iterator iter = ior.iterator();

                if (iter.hasNext()) {
                    TaggedProfile profile = (TaggedProfile) iter.next();
                    ObjectKey objKey = profile.getObjectKey();
                    this.oid = objKey.getId().getId();
                    
                    SimpleKeyGenerator gen = new SimpleKeyGenerator();
                    this.instanceKey = gen.byteArrayToKey(oid, INSTANCEKEY_OFFSET, 20);
                    
                    validate();
                }
            }
        } catch (Exception ex) {
            _logger.log(Level.FINE,
                    "EJBTargetKeyInfo: Exception during extraction of instance key", ex);
        }
    
Methods Summary
public longgetContainerId()

        return this.containerId;
    
public java.lang.ObjectgetInstanceKey()

        return instanceKey;
    
public static intgetInstanceKeyOffset()

        return INSTANCEKEY_OFFSET;
    
public intgetKeyLength()

        return this.keyLength;
    
public byte[]getOid()

        return oid;
    
public booleanisHomeOid()

        return isValid() && (keyLength == 1) && (oid[INSTANCEKEY_OFFSET] == HOME_KEY);
    
public booleanisLocal()

        return this.local;
    
public booleanisValid()

        return this.validOid;
    
public java.lang.StringtoString()

        StringBuilder bldr = new StringBuilder(validOid ? "valid" : "invalid");
        bldr.append(" {").append(containerId).append(" : ")
            .append(isHomeOid() ? "HOME" : "EJBO").append(" ==> ")
            .append(instanceKey).append("}");
        return bldr.toString();
    
private voidvalidate()

        if ((oid != null) && (oid.length > INSTANCEKEY_OFFSET)) {
            this.containerId = Utility.bytesToLong(oid, EJBID_OFFSET);
            this.keyLength = Utility.bytesToInt(oid, INSTANCEKEYLEN_OFFSET);
            if (oid.length == keyLength + INSTANCEKEY_OFFSET) {
                validOid = true;
            } else {
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.log(Level.FINE, "[Invalid.1] oid.length: " + oid.length
                        + "; keyLength: " + keyLength);
                }
            }
        } else {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "[Invalid.2] oid: " + oid + "; "
                    + "oid.length: " + ((oid == null) ? -1 : oid.length));
            }
        }