1
play

1 Corba Architecture Functions of ORB Communication between client - PDF document

CS 242 Topic Interoperability Many systems built using multiple languages Fortran calls to C code, vice versa Microsoft: VBasic, C, C++ Communication between modules John Mitchell Function call with primitive-type arg and


  1. CS 242 Topic Interoperability � Many systems built using multiple languages • Fortran calls to C code, vice versa • Microsoft: VBasic, C, C++ � Communication between modules John Mitchell • Function call with primitive-type arg and result? • Shared objects? • Error handling and exceptions? Topic Three basic approaches � Many systems built using multiple languages � Client-Implementation Intermediary • Fortran calls to C code, vice versa • Convert messages from one implementation to another • Microsoft: VBasic, C, C++ • Example: Corba � Binary compatibility � Communication between modules • Compatible values passed between implementations • Example: COM • Function call with primitive-type arg and result? Yes � Neutral platform • Shared objects? Focus of this lecture • Error handling and exceptions? Still evolving • Run on multiple languages on virtual machine • Example: .Net Background: some related issues Corba Concept � Dynamic linking � Insert “broker” between client and server • Update parts of a system independently – C++: Link compiled code to stub ORB – Stub contains code to interact with DLL request • Share components among different applications � Implementation compatibility SERVER/OBJECT CLIENT • Can C++ component compiled with one compiler be IMPLEMENTATION dynamically linked with component from another? � Inter-language interoperability ORB • Two languages ∼ two compilers Result/ error 1

  2. Corba Architecture Functions of ORB � Communication between client and server Object Client • Insulates application system configuration details Implementation � Specific steps • Intercepts calls • Finds object • Invokes method IDL ORB IDL Object Stub Interface Skeleton Adapter • Passes parameters • Returns results or error messages ORB Core Interface description language CORBA application development Object � Write the IDL interface Client Implementation � Map .idl file to target language (C++, Java, …) • IDL Compiler IDL ORB IDL Object � Develop a Client application Stub Interface Skeleton Adapter � Develop the Server ORB Core � Compile and run the application Interface Description • IDL generates ‘stubs’ and ‘skeleton’ programs for each interface • ‘Stub’ acts like a local function call, providing interface to ORB • ‘Skeleton’ yields server side implementation of IDL interface IDL Example Interface translation Hello.idl � IDL Statement Java Statement module HelloApp package HelloApp; module HelloApp { interface Hello { interface Hello public interface Hello string sayHello(); string sayHello(); String sayHello(); }; }; /* Hello.java as generated by idltojava */ module HelloApp { package HelloApp; HelloHolder.java Hello.java public interface Hello interface Hello { (delegates r/w methods) (IDL interface in Java) string sayHello(); extends org.omg.CORBA.Object { HelloHelper.java String sayHello(); _HelloStub.java }; (auxiliary functionality) (client stub) }; } _HelloImplBase.java (server skeleton) 2

  3. Just to give you some idea of what this looks like … IDL Compiler Output Implementing the Client import HelloApp.*; � _HelloImplBase.java public class HelloClient { import org.omg.CosNaming.*; static Hello helloImpl; • Abstract class provides the server skeleton, basic CORBA functionality import org.omg.CosNaming.NamingContextPackage.*; public static void main(String args[]) { • Implements Hello.java interface import org.omg.CORBA.*; try{ // create and initialize the ORB • server class HelloServant extends _HelloImplBase ORB orb = ORB.init(args, null); � _HelloStub.java // get the root naming context • Client stub, with CORBA functionality for the client org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); • Implements Hello.java interface. // Use NamingContextExt instead of NamingContext; part of Interoperable naming Service � Hello.java NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // resolve the Object Reference in Naming • Interface containing Java version of IDL interface, extends String name = "Hello"; org.omg.CORBA.Object helloImpl = HelloHelper.narrow(ncRef.resolve_str(name)); � HelloHelper.java System.out.println("Obtained a handle on server object: " + helloImpl); • Final class provides auxiliary functionality, including a narrow method System.out.println(helloImpl.sayHello()); to cast CORBA object references to proper type helloImpl.shutdown(); � HelloHolder.java } • Final class has public instance member of type Hello catch (Exception e) { System.out.println("ERROR : " + e) ; e.printStackTrace(System.out); • Provides operations for out and in/out arguments, which CORBA } } } assumes but do not map immediately to Java Hello World Architecture Inter-ORB Communication Client HelloServer.java Implementation Code Interface Application (Hello Description IDL ORB (Hello Servant.java in IDL Stub Interface Client.java) (Hello.idl) Server Skeleton Client Stubs (_HelloImplBase.java) ORB Core (_HelloStub.java) (Hello.java) Implementation ORB (LINUX) ORB (WNT) TCP/IP IDL IDL TCP/IP Internet Compiler Compiler LINUX Windows NT ORB IDL Object Inter-ORB Protocol Interface Skeleton Adapter Network Hardware Hardware (IIOP) ORB Core See http://java.sun.com/j2se/1.4.2/docs/guide/idl/jidlExample.html Corba Summary Corba ORB Architecture: more details � Interface definition language (IDL) • Define interface in “neutral language” • Compiler generates several related files automatically � Object request broker (ORB) • System intermediary handles requests, response 3

  4. COM: Component Object Model Central ideas in COM � Clients program using interfaces, not classes � Purpose (marketing page) � Implementation code is dynamically linked • “COM is used by developers to create re-usable � Manage requirements at run time software components, link components together to • Object implementors declare runtime requirements build applications, and take advantage of Windows services. …” • System ensures that these requirements are met � Current incarnations � Evolution • COM+, Distributed COM (DCOM) , ActiveX Controls • Interfaces and dynamic linking are classic COM � References • Runtime requirements handled using Microsoft • Don Box, Essential COM Transaction Server (MTS) and COM+ • MS site: http://www.microsoft.com/com/ Motivation Evolution in appreciation for abstraction � 1980s: classes and objects � Build dynamically composable systems • Classes used for object implementation • Not all parts of application are statically linked • Classes also used for consumer/client type hierarchy � Independence of components � Dependencies between client and object • One change should not propagate to all source code • Client assumes complete knowledge of public interface • New components usable in place of old • Client may know even more under certain languages � Compatibility of components (C++) • Use components with different runtime requirements � 1990s: separate interface from implementation • Mix heterogeneous objects in a single process • Client to program in terms of abstract types • Completely hides implementation class from client Interface-Based Programming Interoperability � Define interfaces for classes � Use of interfaces separates implementation • C++ : use abstract base classes as interfaces • Different implementations can coexist � Associate implementations with interfaces • C++: inheritance • These can be built in different languages – Class FastString : public IFastString {...}; � Create implementation objects without exposing layout • Usually a creator or factory function • Manipulate object indirectly through intermediate structure • Class unsuitable for declaring variables – Want to avoid dependence on class � Client must be able delete object • Since new operator not used by the client, cannot call delete • Reference counting can be used 4

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend