330 RPC Remote Procedure Call DCOM Distributed COM
3/30 Съдържание Клиент-сървър модела RPC (Remote Procedure Call) DCOM (Distributed COM) RMI (Remote Method Invocation) CORBA
12/30 RMI пример public interface Warehouse extends Remote { double get. Price(String product. Name) throws Remote. Exception; } public class Warehouse. Impl extends Unicast. Remote. Object implements Warehouse { public double get. Price(String product. Name) throws Remote. Exception { return 69. 0; } }
13/30 RMI пример // Warehouse. Application Warehouse. Impl wwf = new Warehouse. Impl(); Context naming. Ctx = new Initial. Context(); naming. Ctx. bind("rmi: cw", wwf); // Warehouse. Client String url = "rmi: //localhost: 1099/cw"; Warehouse cw = (Warehouse) naming. Context. lookup(url); double price = cw. get. Price("Kindle");
19/30 CORBA и Java: IDL Hello. idl module Hello. App { interface Hello { string say. Hello(); oneway void shutdown(); }; }; Hello. idlj Hello. POA. java
20/30 CORBA и Java: Servant class Hello. Impl extends Hello. POA { private ORB orb; public void set. ORB(ORB orb_val) { orb = orb_val; } public String say. Hello() { return "Hello world !"; } public void shutdown() { orb. shutdown(false); } }
21/30 CORBA и Java: Server public static void main(String args[]) { ORB orb = ORB. init(args, null); POA rootpoa = POAHelper. narrow(orb. resolve_initial_references("Root. POA")); rootpoa. the_POAManager(). activate(); Hello. Impl hello. Impl = new Hello. Impl(); hello. Impl. set. ORB(orb); org. omg. CORBA. Object ref = rootpoa. servant_to_reference(hello. Impl); Hello href = Hello. Helper. narrow(ref); org. omg. CORBA. Object obj. Ref = orb. resolve_initial_references("Name. Service"); Naming. Context. Ext nc. Ref = Naming. Context. Ext. Helper. narrow(obj. Ref); Name. Component path[] = nc. Ref. to_name("Hello"); nc. Ref. rebind(path, href); orb. run(); }
22/30 CORBA и Java: Client ORB orb = ORB. init(args, null); org. omg. CORBA. Object obj. Ref = orb. resolve_initial_references("Name. Service"); Naming. Context. Ext nc. Ref = Naming. Context. Ext. Helper. narrow(obj. Ref); hello. Impl = Hello. Helper. narrow(nc. Ref. resolve_str("Hel lo")); hello. Impl. say. Hello(); hello. Impl. shutdown();
25/30 Coming soon…
27/30 Coming soon…
28/30 Термини в разпределените системи • cohesion • loose coupling • availability • scalability • portability • interoperability • maintainability • reusability/ composability
- Slides: 30