The Common Object Request Broker Architecture CORBA 1202022
The Common Object Request Broker Architecture (CORBA) 1/20/2022 1
CORBA The Common Object Request Broker Architecture (CORBA) is a standard architecture for a distributed objects system. n CORBA is designed to allow distributed objects to interoperate in a heterogeneous environment, where objects can be implemented in different programming languages and/or deployed on different platforms. n 1/20/2022 2
CORBA vs. Java RMI n CORBA differs from the architecture of Java RMI in one significant aspect: n n RMI is a proprietary facility developed by Sun Micro. Systems, Inc. , and supports objects written in the Java programming langugage only. CORBA is an architecture that was developed by the Object Management Group (OMG), an industrial consortium. 1/20/2022 3
CORBA is not a distributed objects facility; instead, it is a set of protocol standards. n A distributed object facility (e. g. , Orbix and Visi. Broker) that adheres to these standard protocols is said to be CORBA-compliant, n CORBA is a very rich set of protocols. We will focus on the key concepts of CORBA related to the distributed objects paradigm. We will also study a facility based on CORBA: the Java IDL. n 1/20/2022 4
The Basic Architecture 1/20/2022 5
CORBA Object Interface n n Since CORBA is language independent, the CORBA object interface is defined using a universal language with a distinct syntax, known as the CORBA Interface Definition Language (IDL). (like WSDL-Web Services Description Language, to Web services) A distributed object in CORBA is defined using an IDL file similar to the remote interface file in Java RMI. 1/20/2022 6
CORBA IDL n n n The syntax of CORBA IDL is similar to Java and C++. Objects defined in a CORBA IDL file can be implemented in a large number of diverse programming languages, including C, C++, Java, COBOL, Smalltalk, Ada, Lisp, Python, and IDLScript. For each of these languages, OMG has a standardized mapping from CORBA IDL to the programming language, so that an IDL compiler can be used to process a CORBA IDL interface file to generate the proxy files needed to interface with an object implementation in server side or an object in client side written in any of the CORBA-compatible languages. 1/20/2022 7
IDL Sample Code module Hello. App { interface Hello { string say. Hello(); oneway void shutdown(); }; }; Ref: http: //java. sun. com/j 2 se/1. 5. 0/docs/guide/idl/tutorial/GSIDL. html#writing 1/20/2022 8
Cross-language/vendor CORBA application 1/20/2022 9
ORB Core Feature Matrix http: //www. jetpen. com/~ben/corba/orbmatrix. html 1/20/2022 10
Inter-ORB Protocols To allow ORBs (Object Request Brokers) to be interoperable n OMG’s General Inter-ORB Protocol (GIOP) provides a general framework for protocols to be built on top of specific transport layers n Internet Inter-ORB Protocol (IIOP): GIOP applied to the TCP/IP transport layer n 1/20/2022 11
Internet Inter-ORB Protocols (IIOP) n n Transport management requirements: specifies the connection and disconnection requirements, and the roles for the object client and object server in making and unmaking connections. Definition of common data representation: a coding scheme for marshalling and unmarshalling data of each IDL data type. Message formats: different types of message format are defined. The messages allow clients to send requests to object servers and receive replies. A client invokes a method declared in a CORBA IDL interface for an object and receives a reply message from the server. 1/20/2022 12
Object Bus n n An IIOP-compliant ORB may interoperate with any other IIOP-compliant ORBs over the Internet. Object Bus: the Internet is seen as a bus that interconnects CORBA objects. 1/20/2022 13
ORB products There a large number of proprietary as well as experimental ORBs available: (See CORBA Product Profiles, http: //www. puder. org/corba/matrix/) n n n Orbix from IONA Visi. Broker from Borland Prism. Tech’s Open. Fusion Web Logic Enterprise from BEA Ada Broker from ENST Free ORBs 1/20/2022 14
Server Objects and Clients As in Java RMI, a CORBA distributed object is exported/registered by a server, similar to the server in RMI. n A client looks up a reference to a distributed object (server object) from a naming or directory service, and invokes the methods of the distributed object. n 1/20/2022 15
CORBA Object References As in Java RMI, a CORBA distributed object is located using an object reference. n CORBA is language-independent, a CORBA object reference is an abstract entity mapped to a language/vendor-specific object reference. n For interoperability, OMG specifies a protocol for the abstract CORBA object reference, known as the Interoperable Object Reference (IOR) protocol. n 1/20/2022 16
Interoperable Object Reference (IOR) An ORB compatible with the IOR protocol will allow an object reference to be registered with and retrieved from any IOR-compliant directory service. n An CORBA object reference represented in this protocol is called Interoperable Object Reference (IOR). n 1/20/2022 17
Interoperable Object Reference (IOR) An IOR is a string that contains encoding for the following information: n n The type of an object. The host where the object can be found. The port number of the server for that object. An object key, a string of bytes identifying the object. The object key is used by an object server to locate the object. 1/20/2022 18
Interoperable Object Reference (IOR) The following is an example of the string representation of an IOR: 000000210000001 f 49444 c 3 a 4 e 53505343697263756974496 e 666 f 4 96 e 71756972793 a 332 e 3300010000000200000006 b 0001005 c 000000156 e 6 f 726 d 657430392 e 6 d 63696 c 696 e 6 b 2 e 636 f 6 d 00722 b 8300 0000473 a 5 c 6 e 6 f 726 d 657430392 e 6 d 63696 c 696 e 6 b 2 e 636 f 6 d 3 a 4369726 3756974496 e 666 f 496 e 71756972793 a 303 a 3 a 49523 a 4 e 5350534369726 3756974496 e 666 f 496 e 71756972790000001000000180001005 c 0 0000001000000008000049545 f 30 The representation consists of the character prefix “IOR: ” or “IOR 2: ” followed by a series of hexadecimal numeric characters, each character representing 4 bits of binary data in the IOR. 1/20/2022 19
Generating An IOR File // server side (in C++) NSPSCircuit. Info. Inquiry_imp* Cir. Info. Imp = new NSPSCircuit. Info. Inquiry_imp(argc, argv); try { FILE *fp = fopen(". /NSPS_ckt_info. ior", "w"); if(fp) { char *ior. Ptr = CORBA: : Orbix. object_to_string( (CORBA: : Object_ptr) Cir. Info. Imp ); fputs(ior. Ptr, fp); fputs("n", fp); fclose(fp); } } // end of try // client side: file—in. IOR, is from server side CORBA: : Object_ptr ref = WLEInterface: : string_to_object(in. IOR); lec. Order = EEInt: : Lec. Order. Server: : _narrow(ref); lec. Order->set. Lec. Response. For. Lec. Order(…); 1/20/2022 20
CORBA Naming Service - 1 n n The CORBA Naming Service serves as a directory for CORBA objects The CORBA Naming service is platform independent and programming language independent. The Naming Service permits ORB-based clients to obtain references to objects they wish to use. It allows names to be associated with object references. Clients may query a naming service using a predetermined name (e. g. SWE 622_HW 5) to obtain the associated object reference. 1/20/2022 21
CORBA Naming Service - 2 n n To export a distributed object, a CORBA object server contacts a Naming Service to bind a symbolic name to the object The Naming Service maintains a database of names and the objects associated with them. To obtain a reference to an object, an object client requests the Naming Service to look up the object associated with the name--resolving the object name The Naming Service API is specified in interfaces defined in Naming Service IDL file n n servers to bind names to objects—registration clients to resolve names—look-up 1/20/2022 22
CORBA Naming Service IDL file #pragma prefix "omg. org“ // preprocessor directive module Cos. Naming { …. void bind (in Name n, in Object obj) raises (Not. Found, Cannot. Proceed, Invalid. Name, Already. Bound); void rebind (in Name n, in Object obj) raises (Not. Found, Cannot. Proceed, Invalid. Name); Object resolve (in Name n) raises (Not. Found, Cannot. Proceed, Invalid. Name); void unbind (in Name n) raises (Not. Found, Cannot. Proceed, Invalid. Name); void destroy () raises (Not. Empty); …. }; Ref: http: //www. omg. org/docs/formal/04 -10 -07. txt 1/20/2022 23
CORBA Naming Service n A standard naming hierarchy is defined in a manner similar to the naming hierarchy in a file directory. 1/20/2022 24
A Naming Context n n A naming context corresponds to a folder or directory in a file hierarchy, while object names corresponds to a file. The full name of an object, including all the associated naming contexts, is known as a compound name. n n <naming_context>. …. <naming_context>. <object name> Naming contexts and name bindings are created using methods provided in the Naming Service interface. 1/20/2022 25
Example of a Naming Hierarchy n An object representing the men’s clothing department is named store. clothing. men where the store and clothing are naming contexts, and men is an object name. 1/20/2022 26
Interoperable Naming Service n n n The Interoperable Naming Service (INS) is a URL-based Naming System based on the CORBA Naming Service. INS is an extension to the CORBA Cos. Naming service--a tree-like directory for object references. URL Formats for CORBA Object References n corbaloc: iiop: 1. 2@ise. gmu. edu: 2050/swe 622 n corbaname: : ise. gmu. edu: 2050#Personal/sched ule (to get the root naming context, and to resolve the name Personal/Schedule) Ref: http: //java. sun. com/j 2 se/1. 5. 0/docs/guide/idl/jidl. Naming. html 1/20/2022 27
CORBA Object Services n CORBA Services defined in a standard IDL file n n n n n 1/20/2022 Naming Service Concurrency Service: Event Service: for event synchronization; Logging Service: for event logging; Scheduling Service: for event scheduling; Security Service: for security management; Trading Service: for locating a service by the type (instead of by name); Time Service: a service for time-related events; Notification Service: for events notification; Object Transaction Service: for transactional processing. 28
Object Adapters n n In the basic architecture of CORBA, a distributed object interfaces with the skeleton to interact with the stub on the object client side. As the architecture evolved, a software component in addition to the skeleton is needed on the server side: an object adapter. 1/20/2022 29
Object Adapters n n n An object adapter simplifies the responsibilities of an ORB by assisting an ORB in delivering a client request to an object implementation. When an ORB receives a client’s request, it locates the object adapter associated with the object and forwards the client’s request to the adapter. The adapter interacts with the object implementation’s skeleton, which performs data marshalling and invoke the appropriate method in the servant object. 1/20/2022 30
Portable Object Adapter Interface 1/20/2022 31
Portable Object Adapter There are different types of CORBA object adapters, such as real-time object adapters (in TAO) and portable object adapters. n The Portable Object Adapter (POA) is a particular type of object adapter that is defined by the CORBA standard specification. n A POA object adapter allows an object implementation to function with other different ORBs. n 1/20/2022 32
CORBA Server n CORBA Server consists of: n A Servant class n n implements methods defined an IDL interface A Server class contains main() method n instantiates a servant object n binds/registers the servant object to an object name n 1/20/2022 33
CORBA Servant Class public class Hello. Servant extends Hello. POA { private ORB orb; public Hello. Servant( ORB orb ) { this. orb = orb; } public String say. Hello( ) { return "Hello From CORBA Server. . . "; } public void shutdown( ) { orb. shutdown( false ); } } 1/20/2022 34
CORBA Server Class - 1 q Create and initializes an ORB instance ORB orb = ORB. init(args, null); q Get a reference to the root POA and activates the POAManager POA rootpoa = POAHelper. narrow(orb. resolve_initial_references("Root. POA")); rootpoa. the_POAManager(). activate(); q Create a servant instance org. omg. CORBA. Object ref = rootpoa. servant_to_reference(hello. Impl); Hello href = Hello. Helper. narrow(ref); 1/20/2022 35
CORBA Server Class - 2 q Obtain the Initial Object Reference org. omg. CORBA. Object obj. Ref = orb. resolve_initial_references("Name. Service"); // persistent NS // orb. resolve_initial_references("TName. Service "); // transient NS // Java IDL Transient Naming Service q Narrow the Naming Context Naming. Context. Ext nc. Ref = Naming. Context. Ext. Helper. narrow(obj. Ref); q Register the new object in the naming context Name. Component path[] = nc. Ref. to_name( “swe 622” ); nc. Ref. rebind(path, href); q Wait for invocations of the object from a client orb. run(); 1/20/2022 36
CORBA Client q Create an ORB Object ORB orb = ORB. init(args, null); q Obtain the Initial Object Reference org. omg. CORBA. Object obj. Ref = orb. resolve_initial_references("Name. Service"); q Narrow the Object Reference to get Naming Context Naming. Context. Ext nc. Ref = Naming. Context. Ext. Helper. narrow(obj. Ref); q Resolve the Object Reference in Naming hello. Impl = Hello. Helper. narrow(nc. Ref. resolve-str(“swe 622”)); q Invoking the method hello. Impl. say. Hello(); 1/20/2022 37
The Java IDL (Java 1. 5 version) 1/20/2022 38
Java IDL – J 2 SE CORBA Facility n n Java IDL is part of the Java 2 Platform, Standard Edition (J 2 SE). The Java IDL facility includes n n a CORBA Object Request Broker (ORB), an IDL-to-Java compiler, and a subset of CORBA standard services. In addition to the Java IDL, J 2 SE provides a number of CORBA-compliant facilities, including RMI over IIOP, which allows a CORBA application to be written using the RMI syntax and semantics. 1/20/2022 39
Key Java IDL Packages package org. omg. CORBA – contains interfaces and classes which provides the mapping of the OMG CORBA APIs to the Java programming language n package org. omg. Cos. Naming - contains interfaces and classes which provides the naming service for Java IDL n class org. omg. CORBA. ORB - provides APIs for the Object Request Broker. n 1/20/2022 40
Java IDL Tools Java IDL provides a set of tools needed for developing a CORBA application: n n idlj - the IDL-to-Java compiler (called idl 2 java in Java 1. 2 and before) orbd - a server process which provides Naming Services and other services servertool – provides a command-line interface for application programmers to register/unregister a server (appl), and startup/shutdown a server. tnameserv – an old Transient Java IDL Naming Service 1/20/2022 41
IDL Keywords abstract double long readonly unsigned any enum module sequence union attribute exception native short Value. Base boolean factory Object string valuetype case FALSE octet struct void char fixed oneway supports wchar const float out switch wstring context in private TRUE custom inout public truncatable default interface raises typedef 1/20/2022 42
An IDL File module Persistent { interface Hello { enum Not. Found. Reason { missing_node, not_context, not_object}; exception Not. Found { Not. Found. Reason why; string name; }; string say. Hello( ); void shutdown() raises (Not. Found); // oneway void shutdown() raises (Not. Found); }; }; 1/20/2022 43
Dynamic Invocation Interface (DII) - 1 n n n The stub serves as a proxy to access a remote object. Stubs are generated at compile-time and are static. But what if the interface type of an object is not known at compile time? CORBA's Dynamic Invocation Interface (DII) offers the possibility of invoking operation calls whose signature is not known at compile time. Ref: http: //www. puder. org/corba/cg/ 1/20/2022 44
Dynamic Invocation Interface (DII) - 2 DII uses an object of class org. omg. CORBA. Request to hold everything required to a method invocation: q the object reference q the name of the operation q its parameters q space for the result. q The client builds a Request object describing an operation, then calls the request's invoke method. q The key to dynamic invocation is the ability of requests to hold self-describing data. This facility enables a Request object to represent any invocation of any operation, regardless of its parameters. q Ref: http: //java. sun. com/j 2 se/1. 5. 0/docs/guide/idl/jidl. Clients. html 1/20/2022 45
Dynamic Skeleton Interface (DSI) n n n A server uses the dynamic skeleton interface (DSI) to receive operations or attribute invocations on an object whose IDL interface is unknown to it at compile-time. The server defines a function that determines the identity of the requested object; the name of the operation and the types and values of each argument. Clients are unaware that a server is implemented with the DSI. The DSI is designed to help writing gateways that accept operation or attribute invocations on any specified set of interfaces and pass them to another system. A gateway can be written to interface between CORBA and some non-CORBA system (such as Microsoft’s COM), if a non-CORBA system does not support IIOP. Ref: http: //www. iona. com/support/docs/orbix 2000/2. 0/pguide_cpp/html/Dyn. Interfaces 3. html 1/20/2022 46
Dynamic Skeleton Interface in Java - 1 q Declare the servant class to extend org. omg. CORBA. Dynamic. Implementation. q Implement the invoke (Server. Request request) method to: - Extract the operation name via a call on op_name(). - Build an NVList of the operation parameters - Extract the parameter values via a call on params() - Perform the operation, assigning new values to out/inout parameters - Call either result() and/or except() q Implement the _ids() method. This method is inherited from org. omg. CORBA. portable. Object. Impl, the superclass of Dynamic. Implementation. It returns the repository IDs of the interfaces implemented by this dynamic server. Ref: http: //java. sun. com/j 2 se/1. 5. 0/docs/guide/idl/jidl. DSI. html 1/20/2022 47
Dynamic Skeleton Interface in Java - 2 • The Server Class: • Create an instance of the DSI Servant object using new(). (at the run time) • Register it with the ORB via a call to org. omg. CORBA. ORB. connect() • Wait for requests from clients Ref: http: //java. sun. com/j 2 se/1. 5. 0/docs/guide/idl/jidl. DSI. html 1/20/2022 48
Repository ID n n Each CORBA interface has a unique “Repository ID“. OMG formats of a Repository ID: n n n IDL style: IDL: Prefix/Module. Name/Interface. Name: Version. Number ( e. g. , IDL: Java. IDL/DSIInterface: 1. 0 ) RMI style: RMI: Class. Name: Hash. Code[: SUID] DCE-style: DCE: UUID Local: defined by the local Object Request Broker (ORB). Ref: http: //www. bayour. com/openldap/schemas/corba. schema 1/20/2022 49
Dynamic Skeleton Interface in C++ q The CORBA: : Server. Request class, which is a pseudo-object that is the serverside equivalent to the client-side CORBA: : Request. When the POA dispatches a request to a DSI servant, it passes an instance of Server. Request to communicate all information about the request needed to allow the servant to fulfill it. q The Portable. Server: : Dynamic. Implementation servant base class, from which concrete DSI servant classes inherit. This base class provides the following pure virtual methods that DSI servant classes are expected to override: - void invoke (Server. Request_ptr server_request), which is upcalled by the POA to allow the servant to handle requests. The POA passes the Server. Request representing the request being processed to this method. - Repository. Id _primary_interface (const Object. Id& id, POA_ptr poa), which is called by the ORB/POA run time when it needs the repository ID string identifying the most-derived interface of the object that the servant is incarnating. - The _primary_interface method is called when the application calls POA methods, such as servant_to_reference and id_to_reference, so that the run time can create object references containing the appropriate repository ID. 1/20/2022 50
Passed-By-Value in CORBA 2. 3 offers the feature of objects by value by using IDL valuetype. This mechanism allows CORBA objects to be passed by value in an IDL operation instead of passing objects by reference (by default). q Passing by value means passing the internal state of an object as an operation parameter or returned value, and constructing a copy of the object on the far side. q To pass a CORBA object by-value, you must first define an IDL type using a valuetype to represent the state of the object. This type is passed as an operation parameter and used to create a new instance of the object on the other side. q http: //j-integra. intrinsyc. com/support/espresso/doc/Demo/Valuetype. html 1/20/2022 51
IDL valuetype n valuetype Employee. Record { // note this is not a CORBA: : Object private string name; private string email; private string SSN; // initializer factory init(in string name, in string SSN); }; 1/20/2022 52
Object Passing within RMI Primitive types: passed by value n Remote objects: passed by reference n Non-remote object: passed by value n Java Object Serialization: save object’s state info as a sequence of bytes. n 1/20/2022 53
A Java IDL application example 1/20/2022 54
An IDL File--Hello. idl module Hello. App { interface Hello { string say. Hello(); oneway void shutdown(); }; }; 1/20/2022 55
Compiling the IDL File (using Java 1. 5) n Using the compiler idlj to compile an IDL file: unix> idlj -fall Hello. idl n n The –fall command option is necessary for the compiler to generate all the files needed for both client and server. If succeeded, the following files can be found in a Hello. App (module name) subdirectory: Hello. Operations. java Hello. Helper. java _Hello. Stub. java n Hello. java Hello. Holder. java Hello. POA. java These files require no modifications. 1/20/2022 56
The *Operations. java file Hello. Operations. java is known as a Java operations interface in general. n It is a Java interface file that is equivalent to the CORBA IDL interface file--Hello. idl. n 1/20/2022 57
Hello. App/Hello. Operations. java The file contains the methods specified in the original IDL file: in this case the methods say. Hello( ) and shutdown(). package Hello. App; 01. package Hello. App; 04. /** 05. * Hello. App/Hello. Operations. java 06. * Generated by the IDL-to-Java compiler (portable), 07. * version "3. 1" from Hello. idl 08. */ 09. 10. public interface Hello. Operations 11. { 12. String say. Hello (); 13. void shutdown (); 14. } // interface Hello. Operations 1/20/2022 58
Hello. App/Hello. java The signature interface file combines the characteristics of the Java operations interface (Hello. Operations. java) with the characteristics of the CORBA classes that it extends. 01. package Hello. App; 03. /** 04. * Hello. App/Hello. java 05. * Generated by the IDL-to-Java compiler (portable), 06. * version "3. 1" from Hello. idl 07. */ 09. public interface Hello extends Hello. Operations, 10. org. omg. CORBA. Object, 11. org. omg. CORBA. portable. IDLEntity 12. { 13. } // interface Hello 1/20/2022 59
Hello. Helper. java, the Helper class The Java class Hello. Helper provides auxiliary functionality needed to support a CORBA object in the context of the Java language. n In particular, a method, narrow, allows a CORBA object reference to be cast to its corresponding object type in Java, so that a CORBA object may be operated on using syntax for Java object. n 1/20/2022 60
Hello. Holder. java, the Holder class The Java class called Hello. Holder holds (contains) a reference to an object that implements the Hello interface. n The class is used to handle an out and/or an inout parameters in IDL in Java syntax n n In IDL, a parameter may be declared to be out if it is an output argument, and inout if the parameter contains an input value as well as carries an output value. 1/20/2022 61
_Hello. Stub. java The Java class _Hello. Stub is the stub file, the client-side proxy, which interfaces with the client object. n It extends org. omg. CORBA. portable. Object. Impl and implements the Hello. java interface. n 1/20/2022 62
Hello. POA. java, the server skeleton The Java class Hello. POA is the skeleton, the server-side proxy, combined with the portable object adapter. n It extends org. omg. Portable. Server. Servant, and implements the Invoke. Handler interface and the Hello. Operations interface. n 1/20/2022 63
The application Server-side Classes n On the server side, two classes need to be provided: a servant class and a server class. n The servant, Hello. Servant, implements the Hello IDL interface; each Hello object is an instantiation of this class. 1/20/2022 64
The Servant - Hello. App/Hello. Servant. java // The servant -- object implementation -- for the Hello // example. Note that this is a subclass of Hello. POA, // whose source file is generated from the // compilation of Hello. idl using j 2 idl. 06. import Hello. App. *; 07. import org. omg. Cos. Naming. *; 08. import java. util. Properties; … 15. class Hello. Servant extends Hello. POA { 16. private ORB orb; 18. public void set. ORB(ORB orb_val) { 19. orb = orb_val; } 22. 23. 24. 25. 27. 28. 29. 30. 31. } // implements say. Hello() method public String say. Hello() { return "n. Hello world !!n"; } // implement shutdown() method public void shutdown() { orb. shutdown(false); } //end class 1/20/2022 65
The server - Hello. App/Hello. Server. java public class Hello. Server { public static void main(String args[]) { try{ // create and initialize the ORB orb = ORB. init(args, null); // get reference to rootpoa & activate the POAManager POA rootpoa = (POA)orb. resolve_initial_references("Root. POA"); rootpoa. the_POAManager(). activate(); // create servant and register it with the ORB Hello. Servant hello. Servant = new Hello. Servant(); hello. Servant. set. ORB(orb); // get object reference from the servant org. omg. CORBA. Object ref = rootpoa. servant_to_reference(hello. Servant); // and cast the reference to a CORBA reference Hello href = Hello. Helper. narrow(ref); 1/20/2022 66
Hello. App/Hello. Server. java - continued // get the root naming context // Name. Service invokes the permanent name service org. omg. CORBA. Object obj. Ref = orb. resolve_initial_references("Name. Service"); // Use Naming. Context. Ext, which is part of the // Interoperable Naming Service (INS) specification. Naming. Context. Ext nc. Ref = Naming. Context. Ext. Helper. narrow(obj. Ref); // bind the Object Reference in Naming String name = "Hello"; Name. Component path[] = nc. Ref. to_name( name ); nc. Ref. rebind(path, href); System. out. println("Hello. Server is ready. . . "); // wait for invocations from clients orb. run(); 1/20/2022 67
Naming. Context. Ext API n n The Naming. Context. Ext interface, derived from Naming. Context provides the operations required to use URLs and stringified names. Examples: n n Java IDL: using the POA and a transient server. http: //java. sun. com/j 2 se/1. 5. 0/docs/guide/idl/jidl. Example. html Java IDL: using the POA, a persistent server, and a persistent naming service. http: //java. sun. com/j 2 se/1. 5. 0/docs/guide/idl/jidl. Example 2. html Java IDL: using the POA-Tie server-side model. http: //java. sun. com/j 2 se/1. 5. 0/docs/guide/idl/jidl. Tie. Server. html Ref: http: //java. sun. com/j 2 se/1. 5. 0/docs/guide/idl/INStutorial. html#ext. API 1/20/2022 68
A CORBA Client Application n n A client program can be a Java application, an applet, or a servlet. The client code is responsible for n n n creating and initializing the ORB looking up the object using the INS invoking the narrow method to cast the object reference to a Hello object implementation invoking remote methods using the reference The object’s say. Hello method is invoked to receive a string, and the object’s shutdown method is invoked to deactivate the service. 1/20/2022 69
Sample Client public class Hello. Client{ static Hello hello; public static void main (String args[]){ try{ 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 = Hello. Helper. narrow(nc. Ref. resolve_str (“Hello”)); System. out. println(hello. say. Hello()); hello. shutdown(); . . . 1/20/2022 70
Compiling and Running a Java IDL application 1. Create and compile the Hello. idl file on the server machine: unix> idlj -fall Hello. idl 2. Copy the directory containing Hello. idl (including the subdirectory generated by idlj) to the client machine. 3. In the Hello. App directory on the client machine: create Hello. Client. java. Compile the *. java files, including the stubs and skeletons (which are in the directory Hello. App): javac *. java Hello. App/*. java 1/20/2022 71
Compiling and Running a Java IDL application 4. In the Hello. App directory on the server machine: n n Create Hello. Server. java. Compile the. java files: javac *. java Hello. App/*. java On the server machine: Start the Java Object Request Broker Daemon, orbd, which includes a Naming Service. To do this on Unix: unix> orbd -ORBInitial. Port 1050 -ORBInitial. Host servermachinename& To do this on Windows: start orbd -ORBInitial. Port 1050 -ORBInitial. Host servermachinename 1/20/2022 72
Compiling and Running a Java IDL application 5. On the server machine, start the Hello server, as follows: unix> java Hello. Server –ORBInitial. Host <nameserver host name> -ORBInitial. Port 1050 6. On the client machine, run the Hello application client. From a DOS prompt or shell, type: unix> java Hello. Client -ORBInitial. Host nameserverhost -ORBInitial. Port 1050 all on one line. Note that nameserverhost is the host name (e. g. , mason. gmu. edu) on that the IDL name server is running. 1/20/2022 73
Compiling and Running a Java IDL application 7. Kill or stop orbd when finished. The name server will continue to wait for invocations until it is explicitly stopped. 8. Stop the object server. 1/20/2022 74
Summary-1 n You have been introduced to n n the Common Object Request Broker Architecture (CORBA), and a specific CORBA facility based on the architecture: Java IDL 1/20/2022 75
Summary-2 n The key topics introduced with CORBA are: n n n n The basic CORBA architecture and its emphasis on object interoperability and platform independence Object Request Broker (ORB) and its functionalities The Inter-ORB Protocol (IIOP) and its significance CORBA object reference and the Interoperable Object Reference (IOR) protocol CORBA Naming Service and the Interoperable Naming Service (INS) Standard CORBA object services and how they are provided. Object adapters, portable object Adapters (POA) and their significance. 1/20/2022 76
Summary-3 n The key topics introduced with Java IDL are: It is part of the Java TM 2 Platform, Standard Edition (J 2 SE) n Java packages are provided which contain interfaces and classes for CORBA support n Tools provided for developing a CORBA application include idlj (the IDL compiler) and orbd (the ORB and name server) n An example application Hello n Steps for compiling and running an application. n Client callback is achievable. CORBA toolkits and Java RMI are comparable and alternative technologies that provide distributed objects. An application may be implemented using either technology. However, there are tradeoffs between the two. n n 1/20/2022 77
- Slides: 77