База ответов ИНТУИТ

Построение распределенных систем на Java

<<- Назад к вопросам

Класс BillingServiceImpl:

(Ответ считается верным, если отмечены все правильные варианты ответов.)

Варианты ответа
является классом, методы экземпляра которого могут быть вызваны удаленно(Верный ответ)
реализовывает методы, определенные для интерфейса BillingService в файле idl-описания(Верный ответ)
наследует от класса BillingServicePOA, который был сформирован автоматически утилитой idlj из idl-описания
Похожие вопросы
Класс BillingServiceImpl:
В хэштаблице _cards (класс BillingServiceImpl) хранятся:
В классе BillingServiceImpl для удаленного вызова посредством Java RMI доступны следующие методы:
Для запуска системы из клиента и сервера (BillingServiceImpl и BillingClient), необходим запуск:
В классе BillingServiceImpl для удаленного вызова доступны следующие методы:
Почему в коде BillingServiceImpl отсутствуют операторы чтения данных из сети?
В какой строке кода BillingServiceImpl происходит чтение из сети аргументов, передаваемых в метод processOperations:
1  // BillingServiceImpl.java2  // BillingServiceImpl реализует удаленный интерфейс BillingService для 3  // предоставления удаленного объекта BillingService4  package com.asw.rmi.ex2;5   6  // Набор базовых пакетов Java7  import java.rmi.*;8  import java.util.*;9  import java.rmi.server.*;10   11  public class BillingServiceImpl extends UnicastRemoteObject 12  implements BillingService {13   14  private  Hashtable hash;  // хэш-таблица для хранения карт15  // инициализация сервера16  public BillingServiceImpl() throws RemoteException{17  super();18  hash = new Hashtable();19  }20   21  // реализация метода addNewCard интерфейса BillingService22  public void addNewCard(Card card) throws RemoteException {23   24  hash.put(card.cardNumber, card);25  }26   27  // реализация метода processOperations интерфейса BillingService28  public void processOperations(CardOperation[] operations) 29  throws RemoteException {30  for (int i=0;i<operations.length;i++){31  Card c = (Card)hash.get(operations[i].card);32  if (c==null) throw new NotExistsCardOperation();33  c.balance+=operations[i].amount;34  hash.put(operations[i].card,c);35  }36  }37   38  // реализация метода getCard интерфейса BillingService39  public Card getCard(String card) throws RemoteException{40  Card c = (Card)hash.get(card);41  return c;42  };43   44  // запуск удаленного объекта BillingService45  public static void main (String[] args) throws Exception {46  System.out.println("Initializing BillingService...");47   48  // создание удаленного объекта49  BillingService service = new BillingServiceImpl();50   51  //задание имени удаленного объекта52  String serviceName = "rmi://localhost/BillingService";53  // регистрация удаленного объекта BillingService в реестре rmiregistry54  Naming.rebind(serviceName, service);55  }56   57  }
В какой строке кода BillingServiceImpl происходит чтение из сети аргументов, передаваемых в метод addNewCard:
1  // BillingServiceImpl.java2  package com.asw.corba.ex1;3   4  // базовые пакеты Java5  import java.util.Hashtable;6   7  import com.asw.corba.ex1.BillingServiceModule.*;8   9  // пакеты OMG CORBA10  import org.omg.CORBA.*;11   12  public class BillingServiceImpl  extends BillingServicePOA {13  private ORB orb;14  private  Hashtable hash = new Hashtable();15   16  public void setORB(ORB orb_val) {17  orb = orb_val;18  }19   20  public void addNewCard(String personName, String card) {21  hash.put(card, new Double(0.0));22  }23   24  public void addMoney(String card, double money) {25  Double d = (Double)hash.get(card);26   27  if (d!=null) hash.put(card,new Double(d.doubleValue()+money));28  }29   30  public void subMoney(String card, double money) {31  Double d = (Double)hash.get(card);32   33  if (d!=null) hash.put(card,new Double(d.doubleValue()-money));34  }35   36  public double getCardBalance(String card) {37  Double d = (Double)hash.get(card);38   39  if (d!=null) return d.doubleValue();40  else return 0;41  }42  }
В строке 54, в классе BillingServiceImpl:
1  // BillingServiceImpl.java2  // BillingServiceImpl реализует удаленный интерфейс BillingService для 3  // предоставления удаленного объекта BillingService4  package com.asw.rmi.ex2;5   6  // Набор базовых пакетов Java7  import java.rmi.*;8  import java.util.*;9  import java.rmi.server.*;10   11  public class BillingServiceImpl extends UnicastRemoteObject 12  implements BillingService {13   14  private  Hashtable hash;  // хэш-таблица для хранения карт15  // инициализация сервера16  public BillingServiceImpl() throws RemoteException{17  super();18  hash = new Hashtable();19  }20   21  // реализация метода addNewCard интерфейса BillingService22  public void addNewCard(Card card) throws RemoteException {23   24  hash.put(card.cardNumber, card);25  }26   27  // реализация метода processOperations интерфейса BillingService28  public void processOperations(CardOperation[] operations) 29  throws RemoteException {30  for (int i=0;i<operations.length;i++){31  Card c = (Card)hash.get(operations[i].card);32  if (c==null) throw new NotExistsCardOperation();33  c.balance+=operations[i].amount;34  hash.put(operations[i].card,c);35  }36  }37   38  // реализация метода getCard интерфейса BillingService39  public Card getCard(String card) throws RemoteException{40  Card c = (Card)hash.get(card);41  return c;42  };43   44  // запуск удаленного объекта BillingService45  public static void main (String[] args) throws Exception {46  System.out.println("Initializing BillingService...");47   48  // создание удаленного объекта49  BillingService service = new BillingServiceImpl();50   51  //задание имени удаленного объекта52  String serviceName = "rmi://localhost/BillingService";53  // регистрация удаленного объекта BillingService в реестре rmiregistry54  Naming.rebind(serviceName, service);55  }56   57  }
Создание класс BillingServiceServer с параметром при регистрации LifespanPolicyValue.PERSISTENT обеспечивает: