Rather than go through a complete implementation of the bank example using RMI/IIOP, we’ll just focus on what changes (most of the code is the same).
The major change is that Account_Impl
can no
longer extend UnicastRemoteObject
or Activatable
. Instead, it
must extend PortableRemoteObject
(which is defined
in the javax.rmi
package). That is, the code
changes from:
public class Account_Impl extends UnicastRemoteObject implements Account
to:
public class Account_Impl extends PortableRemoteObject implements Account
The next change is that the stubs and
skeletons are generated using rmic
with the -iiop
flag:
rmic -keep -iiop -d d:\classes com.ora.rmibook.chapter23.rmiiiopaccounts.Account_Impl
The -keep
flag is still valid and allows us to look at the
stub code. As you might expect, the automatically
generated stub code is completely different. Here,
for example, is the stub implementation of
getBalance( )
:
public Money getBalance( ) throws RemoteException { if (!Util.isLocal(this)) { try { org.omg.CORBA_2_3.portable.InputStream in = null; try { OutputStream out = _request("_get_balance", true); in = (org.omg.CORBA_2_3.portable.InputStream)_invoke(out); return (Money) in.read_value(Money.class); } catch (ApplicationException ex) { in = (org.omg.CORBA_2_3.portable.InputStream) ex. getInputStream( ); String id = in.read_string( ); throw new UnexpectedException(id); } catch (RemarshalException ex) { return getBalance( ); } finally { _releaseReply(in); ...
No credit card required