try {
if (StubAdapter.isStub( source )) {
orb = StubAdapter.getORB( source ) ;
} else {
// Is this a servant that was exported to iiop?
Tie tie = Util.getTie(source);
if (tie == null) {
/* loadTie always succeeds for dynamic RMI-IIOP
// No, can we get a tie for it? If not,
// assume that source is a JRMP object...
if (Utility.loadTie(source) != null) {
// Yes, so it is an iiop object which
// has not been exported...
throw new RemoteException(
"'source' object not exported");
}
*/
} else {
orb = tie.orb();
}
}
} catch (SystemException e) {
throw new RemoteException("'source' object not connected", e );
}
boolean targetIsIIOP = false ;
Tie targetTie = null;
if (StubAdapter.isStub(target)) {
targetIsIIOP = true;
} else {
targetTie = Util.getTie(target);
if (targetTie != null) {
targetIsIIOP = true;
} else {
/* loadTie always succeeds for dynamic RMI-IIOP
if (Utility.loadTie(target) != null) {
throw new RemoteException("'target' servant not exported");
}
*/
}
}
if (!targetIsIIOP) {
// Yes. Do we have an ORB from the source object?
// If not, we're done - there is nothing to do to
// connect a JRMP object. If so, it is an error because
// the caller mixed JRMP and IIOP...
if (orb != null) {
throw new RemoteException(
"'source' object exported to IIOP, 'target' is JRMP");
}
} else {
// The target object is IIOP. Make sure we have a
// valid ORB from the source object...
if (orb == null) {
throw new RemoteException(
"'source' object is JRMP, 'target' is IIOP");
}
// And, finally, connect it up...
try {
if (targetTie != null) {
// Is the tie already connected?
try {
ORB existingOrb = targetTie.orb();
// Yes. Is it the same orb?
if (existingOrb == orb) {
// Yes, so nothing to do...
return;
} else {
// No, so this is an error...
throw new RemoteException(
"'target' object was already connected");
}
} catch (SystemException e) {}
// No, so do it...
targetTie.orb(orb);
} else {
StubAdapter.connect( target, orb ) ;
}
} catch (SystemException e) {