use of org.omg.PortableServer.Servant in project Payara by payara.
the class POARemoteReferenceFactory method preinvoke.
/**
* This is the implementation of ServantLocator.preinvoke()
* It is called from the POA before every remote invocation.
* Return a POA Servant (which is the RMI/IIOP Tie for EJBObject/EJBHome).
* @param ejbKey
* @param cookieHolder
*/
@Override
public Servant preinvoke(byte[] ejbKey, POA adapter, String operation, CookieHolder cookieHolder) throws org.omg.PortableServer.ForwardRequest {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "In preinvoke for operation:{0}", operation);
}
// get instance key
int keyLen = Utility.bytesToInt(ejbKey, INSTANCEKEYLEN_OFFSET);
byte[] instanceKey = new byte[keyLen];
System.arraycopy(ejbKey, INSTANCEKEY_OFFSET, instanceKey, 0, keyLen);
Servant servant = null;
try {
while (servant == null) {
// get the EJBObject / EJBHome
Remote targetObj = container.getTargetObject(instanceKey, (isRemoteHomeView ? null : remoteBusinessIntf));
// the looping logic the same as it has always been.
if (targetObj != null) {
// get the Tie which is the POA Servant
// fix for bug 6484935
@SuppressWarnings("unchecked") Tie tie = (Tie) AccessController.doPrivileged(new PrivilegedAction() {
@Override
public Tie run() {
return presentationMgr.getTie();
}
});
tie.setTarget(targetObj);
servant = (Servant) tie;
}
}
} catch (NoSuchObjectLocalException e) {
logger.log(Level.SEVERE, "iiop.gettie_exception", e);
throw new OBJECT_NOT_EXIST(GET_TIE_EXCEPTION_CODE, CompletionStatus.COMPLETED_NO);
} catch (RuntimeException e) {
logger.log(Level.SEVERE, "iiop.runtime_exception", e);
throw e;
}
return servant;
}
Aggregations