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: write a program for changing dollar in to rupees in c, write a paragraph on scenario of the world without maths in 800 words, write a c program to recognise key words, hello project jimmysho, java program for retrieving stock market exchange information using corba, corba technology, hello kitty am,

[-]
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,625 20-04-2013, 11:59 AM
Last Post: T
  Program in “LEX” to count number of vowels and consonants seminar class 2 9,596 22-03-2013, 10:20 AM
Last Post: computer topic
  Program in “LEX” to count number of Identifiers and Keywords seminar class 1 4,822 28-01-2013, 03:21 PM
Last Post: Guest
  PROGRAM TO RECOGNIZE A STRING WITH THREE COSECUTIVE 0’s smart paper boy 0 1,653 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,390 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,513 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,758 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,934 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,885 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,767 21-07-2011, 09:50 AM
Last Post: smart paper boy

Forum Jump: