Search in sources :

Example 1 with ObjectKey

use of com.sun.corba.ee.spi.ior.ObjectKey in project Payara by payara.

the class POAProtocolMgr method getObjectID.

@Override
public byte[] getObjectID(org.omg.CORBA.Object obj) {
    IOR ior = ((com.sun.corba.ee.spi.orb.ORB) orb).getIOR(obj, false);
    java.util.Iterator iter = ior.iterator();
    byte[] oid = null;
    if (iter.hasNext()) {
        TaggedProfile profile = (TaggedProfile) iter.next();
        ObjectKey objKey = profile.getObjectKey();
        oid = objKey.getId().getId();
    }
    return oid;
}
Also used : TaggedProfile(com.sun.corba.ee.spi.ior.TaggedProfile) ObjectKey(com.sun.corba.ee.spi.ior.ObjectKey) IOR(com.sun.corba.ee.spi.ior.IOR) ORB(com.sun.corba.ee.spi.orb.ORB)

Example 2 with ObjectKey

use of com.sun.corba.ee.spi.ior.ObjectKey in project Payara by payara.

the class POARemoteReferenceFactory method hasSameContainerID.

@Override
public boolean hasSameContainerID(org.omg.CORBA.Object obj) throws Exception {
    boolean result = false;
    try {
        IOR ior = (orb).getIOR(obj, false);
        java.util.Iterator iter = ior.iterator();
        byte[] oid = null;
        if (iter.hasNext()) {
            TaggedProfile profile = (TaggedProfile) iter.next();
            ObjectKey objKey = profile.getObjectKey();
            oid = objKey.getId().getId();
        }
        if ((oid != null) && (oid.length > INSTANCEKEY_OFFSET)) {
            long cid = Utility.bytesToLong(oid, EJBID_OFFSET);
            // To be really sure that is indeed a ref generated
            // by our container we do the following checks
            int keyLen = Utility.bytesToInt(oid, INSTANCEKEYLEN_OFFSET);
            if (oid.length == keyLen + INSTANCEKEY_OFFSET) {
                result = (cid == ejbDescriptor.getUniqueId());
            }
            if (logger.isLoggable(Level.FINE)) {
                StringBuilder sbuf = new StringBuilder();
                sbuf.append("hasSameContainerID() result: ").append(result).append("; because ==> oid.length: ").append(oid.length).append("; instance-key-length: ").append(keyLen).append("; expected oid.length: ").append(keyLen).append("+").append(INSTANCEKEY_OFFSET).append("; myContainrID: ").append(ejbDescriptor.getUniqueId()).append("; obj.containerID: ").append(cid);
                logger.log(Level.FINE, sbuf.toString());
            }
        } else {
            if (logger.isLoggable(Level.FINE)) {
                if (oid == null) {
                    logger.log(Level.FINE, "hasSameContainerID() failed because oid=null");
                } else {
                    logger.log(Level.FINE, "hasSameContainerID() failed because oid.length= " + "{0}; but INSTANCE_KEY_OFFSET= {1}", new Object[] { oid.length, INSTANCEKEY_OFFSET });
                }
            }
        }
    } catch (Exception ex) {
        logger.log(Level.FINE, "Exception while checking for same containerID", ex);
        throw ex;
    }
    return result;
}
Also used : TaggedProfile(com.sun.corba.ee.spi.ior.TaggedProfile) ObjectKey(com.sun.corba.ee.spi.ior.ObjectKey) IOR(com.sun.corba.ee.spi.ior.IOR) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException)

Aggregations

IOR (com.sun.corba.ee.spi.ior.IOR)2 ObjectKey (com.sun.corba.ee.spi.ior.ObjectKey)2 TaggedProfile (com.sun.corba.ee.spi.ior.TaggedProfile)2 ORB (com.sun.corba.ee.spi.orb.ORB)1 IOException (java.io.IOException)1 NotSerializableException (java.io.NotSerializableException)1 NoSuchObjectLocalException (javax.ejb.NoSuchObjectLocalException)1