В строке 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 }
(Отметьте один правильный вариант ответа.)
Варианты ответа
создается экземпляр объекта, который может принимать удаленные вызовы
производится связывание имени сервиса с экземпляром объекта, реализующим сервис(Верный ответ)
производится останов сервиса