目次|| Java Remote Method Invocation


2.5リモート・インタフェースの実装

リモート・インタフェースを実装するクラスの一般的な規約は、次のとおりです。 たとえば、次に示すクラスBankAcctImplBankAccountリモート・インタフェースを実装し、java.rmi.server.UnicastRemoteObjectクラスを拡張しています。
 package mypackage; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class BankAccountImpl extends UnicastRemoteObject implements BankAccount { private float balance = 0.0; public BankAccountImpl(float initialBalance) throws RemoteException { balance = initialBalance; } public void deposit(float amount) throws RemoteException { ... } public void withdraw(float amount) throws OverdrawnException, RemoteException { ... } public float getBalance() throws RemoteException { ... } } 

ノート:


目次||
Copyright 1997, 2010, Oracle and/or its affiliates. All rights reserved.