Sei sulla pagina 1di 3

CORBA (Common Object Request Broker Architecture)

1. CORBA allows you to make calls between Java objects and objects written in other languages. Depends on having a ORB(Object Request Broker) on both the client and server. ORB is a universal translator tasks(startup service, lifecycle servicecreate,copy,move,destroy,Naming service-allow to search objects by name)

2. Steps for implementing CORBA Objects: a. Write the interface, using IDL(Interface Definition Language). IDL is a special language used to specify interfaces in a language neutral form. b. Using IDL compiler for target language generate the stub and helper classes. c. Add the implementation code for server object(in any object). Compile the implementation code. d. Write a server program that creates and register server objects(Naming Service) e. Write the client program that locates objects and invokes the services on them. f. Start the naming service and the server program on the server and client program on the client. 3. The Interface Definition Language a. In IDL, the interface definition ends with a semicolon. b. The IDL to Java compiler(Java IDL Compiler) translates IDL definitions to definitions for java interfaces. c. Idlj product.idl The result is a file ProductOperations.java (which contains the method defined in the IDL file) and product.java(which defines the Interface) d. The IDL Compiler also generates a number of other source files- the stub class for communicating with the ORB and three helper classes. e. The rules that govern the translation from IDL to the Java programming language are collectively called the Java programming language binding. Language bindings are standardized by the OMG.

f. When defining a method , you have more choices for parameter passing. Every parameter can be declared as in,out,or inout. An in parameter is simply passed to the mothod. A method stores a value in each out parameter before it returns. For inout, then the caller needs to supply a value for the method, and the method can change that value so that the caller can retrieve the changed value. g. The IDL compiler generates a class with suffix Holder for every interface. Every holder class has a pubic instance variable called value.\ h. In IDL ,you use the sequence construct to define arrays of variable size. i. In Java, modules are translated to packages. Once you have the IDL file, you run the IDL Compiler that your ORB vendor supplies to get stubs and helper classes for your target programming language(such as java or C++). For example,to convert IDL files to Java, You run the idlj program. Supply the name of the IDL file on the command line: Idlj Product.idl The program creates five source files: Product.java, the interface definition; ProductOperations.java, the interface that contains the actual operations (Product extends ProductOperations as well as a couple of CORBA-specific interfaces); ProductHolder.java, the holder class for out parameters. ProductHelper.java,a helper class,which we use in the next session; _ProductStub.java, the stub class for communicating with the ORB. First you initialize the ORB. The ORB is simply a code library that knows how to talk to other ORBs and how to marshall and unmarshall parameters. ORB orb=ORB.init(args,null); Next you locate the naming service that helps you locate other objects. CORBA 2 ORB lets you locate certain standard services by name. The call Strins[] services=orb.list_initial_services();

Lists the name of the standard services to which the ORB can connect. The naming service has the standard name NameService. To obtain an object reference to the service, you use the resolve_initial_references method. It returns a generic CORBA object, an instance of the class org.omg.corba.Object. Org.omg.CORBA.Object object=orb,resolve_initial_references(NameService); Next,convert this reference to a NamingContext reference so that you can invoke the methods of the NamingContext interface. In RMI, you would simply cast the reference to a different type. However,in CORBA,you cannot simply cast references. NamingContext namingContext=(NamingContext) object;//error Instead,you have to use the narrow method of the helper class of the yarget interface. NamingContext namingContext=NamingContextHelper.narrow(object);

Potrebbero piacerti anche