To write a program to print “Hello World” in CORBA.
#1

Aim:
To write a program to print “Hello World” in CORBA.

Algorithm:
Step 1: Start the process
Step 2: Create an idl class in a module Hello1and declare a
method sayHello().
Step 3: Create an implement class HelloImpl which extends
_HelloImplBase and import the module.
Step 4: Define the sayHello method and return the result.
Step 5: Define the client program named HelloClient which
imports the module
(i) Declare a static reference for interface Hello
(ii) Create and initialize the ORB and get the root naming
context.
(iii) Resolve the Object Reference in Naming.
(iv) Call the sayHello method
Step 6: Create the HelloServer which imports the module.
(i) Create and initialize the ORB.
(ii) Create servant and register it with the ORB.
(iii) Get object reference from the servant.
(iv) Bind the Object Reference in Naming.
(v) Use NamingContext.
(vi) Wait for invocations from clients
Step 7: Stop the process.
Program Code:
Code:
IDL Class:-
module Hello1
{
       interface Hello    
       {
         string sayHello();
       };
      };

Client Class:-
import Hello1.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
public class HelloClient
{
    static Hello helloImpl;
    public static void main(String args[])
     {
        try
         {
          // create and initialize the ORB
             ORB orb = ORB.init(args, null);
          // get the root naming context
             org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
               NamingContext ncRef = NamingContextHelper.narrow(objRef);
    
               // resolve the Object Reference in Naming
              NameComponent nc=new NameComponent ("Hello","");
              NameComponent path[] = {nc};
           helloImpl = HelloHelper.narrow(ncRef.resolve(path));
              System.out.println(helloImpl.sayHello());
              }
                 catch (Exception e)
                   {
              System.out.println("ERROR : " + e) ;
           }
        }
    }

Implement Class:
    import Hello1.*;
    import org.omg.CosNaming.*;
    import org.omg.CosNaming.NamingContextPackage.*;
    import org.omg.CORBA.*;
    import java.util.Properties;
    
    class HelloImpl extends _HelloImplBase
              {
        // implement sayHello() method
        public String sayHello()
                 {
           return "\nHello world !!\n";
          }
      }

Server Class:-
Code:
    import Hello1.*;
import org.omg.CosNaming.*;
    import org.omg.CosNaming.NamingContextPackage.*;
    import org.omg.CORBA.*;
    
    public class HelloServer {
      public static void main(String args[]) {
        try
                 {
           // create and initialize the ORB
           ORB orb = ORB.init(args, null);
          // create servant and register it with the ORB
          HelloImpl helloImpl = new HelloImpl();
              orb.connect(helloImpl);
    
          // get object reference from the servant
          org.omg.CORBA.Object objRef =orb.resolve_initial_references("NameService");
          // Use NamingContext
          NamingContext ncRef = NamingContextHelper.narrow(objRef);
    
          // bind the Object Reference in Naming
      NameComponent nc=new NameComponent ("Hello","");
          NameComponent path[] = {nc};
                ncRef.rebind(path, helloImpl);
    
          System.out.println("HelloServer ready and waiting ...");
          // wait for invocations from clients
          orb.run();
        }
      catch (Exception e)
                {
            System.err.println("ERROR: " + e);
         }
       System.out.println("HelloServer Exiting ...");
      }
    }
Output:
Impl Side:

Z:\Middle ware\corba1>idlj -fclient -fserver -implBase hello.idl
Z:\Middle ware\corba1>cd hello1
Z:\Middle ware\corba1\Hello1>javac *.java
Z:\Middle ware\corba1>tnameserv
Initial Naming Context:
IOR:000000000000002849444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e
67436f6e746578743a312e3000000000010000000000000054000101000000000d313732
2e31362e312e3130380000041f00000018afabcafe00000002584b271b000000080000000
000000000000000010000000100000014000000000001002000000000000101000000000
TransientNameServer: setting port for initial object references to: 900
Ready.
Server Side:
Z:\Middle ware\corba1>javac *.java
Z:\Middle ware\corba1>java HelloServer
HelloServer ready and waiting...
Client Side:
Z:\Middle ware\corba1>java HelloClient
Hello world!!
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: hello kiity, print culture and the modern world ppt, write a paragraph on scenario of the world without maths in 800 words, elokmat paper hello chalisgaon, ppt on print culture in modern world, java program for retrieving stock market exchange information using corba, hello world in corba,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  VHDL program for Booth’s Multiplier smart paper boy 2 5,668 20-04-2013, 11:59 AM
Last Post: T
  Program in “LEX” to count number of vowels and consonants seminar class 2 9,641 22-03-2013, 10:20 AM
Last Post: computer topic
  Program in “LEX” to count number of Identifiers and Keywords seminar class 1 4,858 28-01-2013, 03:21 PM
Last Post: Guest
  PROGRAM TO RECOGNIZE A STRING WITH THREE COSECUTIVE 0’s smart paper boy 0 1,671 10-08-2011, 11:44 AM
Last Post: smart paper boy
  : PROGRAM TO IDENTIFY VOWELS AND CONSONANTS GIVEN AS INPUT smart paper boy 0 2,412 10-08-2011, 11:44 AM
Last Post: smart paper boy
  Program to Encrypt and decrypt a text data using RSA algorithm smart paper boy 0 2,534 10-08-2011, 11:43 AM
Last Post: smart paper boy
  Program the CRC 12 on a data set of characters smart paper boy 0 1,774 10-08-2011, 11:42 AM
Last Post: smart paper boy
  Program to implement the data link layer framing method character stuffing smart paper boy 0 7,962 10-08-2011, 11:41 AM
Last Post: smart paper boy
  Program to implement the data link layer framing method bit stuffing smart paper boy 0 2,899 10-08-2011, 11:41 AM
Last Post: smart paper boy
  To write a C# program to perform encryption and decryption of the given data. smart paper boy 0 1,790 21-07-2011, 09:50 AM
Last Post: smart paper boy

Forum Jump: