CORBA может быть использована при разработке:
(Ответ считается верным, если отмечены все правильные варианты ответов.)
Варианты ответа
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 }
1 // BillingServiceServer.java2 package com.asw.corba.ex1;3 4 // пакеты OMG CORBA5 import org.omg.CosNaming.*;6 import org.omg.CORBA.*;7 import org.omg.PortableServer.*;8 import org.omg.PortableServer.POA;9 import com.asw.corba.ex1.BillingServiceModule.*;10 11 public class BillingServiceServer {12 public static void main(String args[]) {13 try{14 // create and initialize the ORB15 ORB orb = ORB.init(args, null);16 17 // get reference to rootpoa & activate the POAManager18 POA rootpoa =19 POAHelper.narrow(orb.resolve_initial_references("RootPOA"));20 rootpoa.the_POAManager().activate();21 22 // create servant and register it with the ORB23 BillingServiceImpl BSImpl = new BillingServiceImpl();24 BSImpl.setORB(orb);25 26 // get object reference from the servant27 org.omg.CORBA.Object ref = rootpoa.servant_to_reference(BSImpl);28 BillingService href = BillingServiceHelper.narrow(ref);29 30 // get the root naming context31 // NameService invokes the name service32 org.omg.CORBA.Object objRef =33 orb.resolve_initial_references("NameService");34 // Use NamingContextExt which is part of the Interoperable35 // Naming Service (INS) specification.36 NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);37 38 // bind the Object Reference in Naming39 String name = "BillingService";40 NameComponent path[] = ncRef.to_name( name );41 ncRef.rebind(path, href);42 43 System.out.println("BillingServiceServer ready and waiting ...");44 45 // wait for invocations from clients46 orb.run();47 }48 49 catch (Exception e) {50 System.err.println("ERROR: " + e);51 e.printStackTrace(System.out);52 }53 System.out.println("BillingServer Exiting ...");54 }55 }