CoreDeploymentInfo deploymentInfo = ejbProxyHandler.getDeploymentInfo();
String deploymentId = (String) deploymentInfo.getDeploymentID();
try {
RefGenerator refGenerator = AdapterWrapper.getRefGenerator(deploymentId);
if (refGenerator == null) {
throw new MARSHAL("Could not find RefGenerator for deployment id: " +deploymentId);
}
if (proxy instanceof EJBHome) {
return refGenerator.genHomeReference();
} else if (proxy instanceof EJBObject) {
Object primaryKey = null;
if (deploymentInfo.getComponentType() != BeanType.STATELESS) {
EJBObject ejbObject = (EJBObject) proxy;
primaryKey = ejbObject.getPrimaryKey();
}
return refGenerator.genObjectReference(primaryKey);
} else {
log.error("Encountered unknown local invocation handler of type " + proxy.getClass().getSuperclass() + ":" + deploymentId);
throw new MARSHAL("Internal server error while marshaling the reply", 0, CompletionStatus.COMPLETED_YES);
}
} catch (CORBAException e) {
log.error("Encountered unknown local invocation handler of type " + proxy.getClass().getSuperclass() + ":" + deploymentId);
throw new MARSHAL("Encountered unknown local invocation handler of type " + proxy.getClass().getSuperclass() + ":" + deploymentId, 0, CompletionStatus.COMPLETED_YES);
} catch (RemoteException e) {
log.error("Unable to get primary key from bean from bean of type " + proxy.getClass().getSuperclass() + ":" + deploymentId);
throw new MARSHAL("Unable to get primary key from bean from bean of type " + proxy.getClass().getSuperclass() + ":" + deploymentId, 0, CompletionStatus.COMPLETED_YES);
}
}