memberimpl.java

来自「Java the UML Way 书中所有源码」· Java 代码 · 共 45 行

JAVA
45
字号
/*
 * MemberImpl.java   E.L. 2001-08-25
 * This class is mutable. All data may be changed.
 */

import java.rmi.*;
import java.rmi.server.*;
import myLibrary.Person;

class MemberImpl extends UnicastRemoteObject implements Member {
  private Person thePerson;
  private String theAddress;

  public MemberImpl(Person initPerson, String initAddress) throws RemoteException {
    thePerson = initPerson;
    theAddress = initAddress;
  }

  public synchronized Person getPerson() throws RemoteException {
    return thePerson;
  }

  public synchronized void setPerson(Person newPerson) throws RemoteException {
    thePerson = newPerson;
  }

  public synchronized String getAddress() throws RemoteException {
    return theAddress;
  }

  public synchronized void setAddress(String newAddress) throws RemoteException {
    theAddress = newAddress;
  }
}

class MemberFactoryImpl extends UnicastRemoteObject implements MemberFactory {

  public MemberFactoryImpl() throws RemoteException {
  }

  public Member instantiateMember(Person initPerson, String initAddress) 
                                      throws RemoteException {
    return new MemberImpl(initPerson, initAddress);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?