Presentation is loading. Please wait.

Presentation is loading. Please wait.

CORBA. A CORBA example From url: es/releases/corba/ The transient server example.

Similar presentations


Presentation on theme: "CORBA. A CORBA example From url: es/releases/corba/ The transient server example."— Presentation transcript:

1 CORBA

2 A CORBA example From url: http://java.sun.com/developer/technicalArticl es/releases/corba/ The transient server example

3 The IDL file, Add.idl module ArithApp { interface Add { const unsigned short SIZE=10; typedef long array[SIZE]; void addArrays(in array a, in array b, out array result); };

4 Use idl compiler to compile this file prompt> idlj -fall Add.idl This command will generate several files. Check the local directory where you run the command from to see the files. You will notice that a new subdirectory with the name ArithApp has been created. This is because an OMG IDL module is mapped to a Java package. For more information on the idlj compiler and the options you can use, please see the IDL-to-Java Compiler.IDL-to-Java Compiler

5 AddImpl.java implements the idl import ArithApp.*; import org.omg.CORBA.*; class AddImpl extends AddPOA { private ORB orb; public AddImpl(ORB orb) { this.orb = orb; } // implement the addArrays() method public void addArrays(int a[], int b[], ArithApp.AddPackage.arrayHolder result) { result.value = new int[ArithApp.Add.SIZE]; for(int i=0; i<ArithApp.Add.SIZE; i++) { result.value[i] = a[i] + b[i]; } }}

6 AddServer AddServer.java in notes section

7 AddClient AddClient.java in notes

8 Compile these files prompt> javac *.java ArithApp/*.java

9 To run the application: Start the orbd, which is a name server: prompt> orbd -ORBInitialPort 2500 The number 2500 is the port number where you want the orbd to run. Note that the -ORBInitialPort is a require command-line argument. Start the AddServer: prompt> java AddServer -ORBInitialPort 2500 Start the AddClient: prompt> java AddClient -ORBInitialPort 2500

10 Run orbd at ORBInitialPort 2500

11 Run server

12 Run client

13 Persistent server

14 Persistent server start server tool-this 2 nd example not completed


Download ppt "CORBA. A CORBA example From url: es/releases/corba/ The transient server example."

Similar presentations


Ads by Google