1 / 14

CORBA

CORBA. A CORBA example. From url: http://java.sun.com/developer/technicalArticles/releases/corba/ The transient server example. The IDL file, Add.idl. module ArithApp { interface Add { const unsigned short SIZE=10; typedef long array[SIZE];

zayit
Download Presentation

CORBA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CORBA

  2. A CORBA example From url: http://java.sun.com/developer/technicalArticles/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.

  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 serverstart server tool-this 2nd example not completed

More Related