Java Tutorial

 
 
 
 
// IDL

module ReverseModule
{
    interface Reverse
    {
        string reverse_string(in string str);
    };
};


// ReverseImpl
// Contains the implementation of the methods defined in the IDL file.

import ReverseModule.ReversePOA;
import java.lang.String;
class ReverseImpl extends ReversePOA
{
    ReverseImpl()
    {
        super();
        System.out.println(\"Reverse Object Created\");
    }

    public String reverse_string(String name)
    {
    StringBuffer str=new StringBuffer(name);    
    str.reverse();
        return ((\"Server Send \"+str));
    }
}


// Server

import ReverseModule.Reverse;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;

class ReverseServer
{

    public static void main(String[] args)
    {
        try
        {
            // initialize the ORB
            org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);

            // initialize the BOA/POA
            POA rootPOA = POAHelper.narrow(orb.resolve_initial_references(\"RootPOA\"));
            rootPOA.the_POAManager().activate();

            // creating the calculator object
            ReverseImpl rvr = new ReverseImpl();

            // get the object reference from the servant class
            org.omg.CORBA.Object ref = rootPOA.servant_to_reference(rvr);

            System.out.println(\"Step1\");
            Reverse h_ref = ReverseModule.ReverseHelper.narrow(ref);
            System.out.println(\"Step2\");

            org.omg.CORBA.Object objRef = orb.resolve_initial_references(\"NameService\");

            System.out.println(\"Step3\");
            NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
            System.out.println(\"Step4\");

            String name = \"Reverse\";
            NameComponent path[] = ncRef.to_name(name);
            ncRef.rebind(path,h_ref);

            System.out.println(\"Reverse Server reading and waiting....\");
            orb.run();


        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}


// Client

import ReverseModule.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import java.io.*;

class ReverseClient
{

    public static void main(String args[])
    {
        Reverse ReverseImpl=null;

        try
        {
            // initialize the ORB
            org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);

            org.omg.CORBA.Object objRef = orb.resolve_initial_references(\"NameService\");
            NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

            String name = \"Reverse\";
            ReverseImpl = ReverseHelper.narrow(ncRef.resolve_str(name));

            System.out.println(\"Enter String=\");
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str= br.readLine();

            String tempStr= ReverseImpl.reverse_string(str);

            System.out.println(tempStr);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}


// OUTPUT

Z:\\mca317\\corba\\five>java -classpath .\\ ReverseClient -ORBInitialPort 1050 -ORBInitialHost mca24
Enter String=
Hello my name is nishant
Server Send tnahsin si eman ym olleH

    Related Post:
  1. Program to read the ballots and count the votes cast for each candidate using an array variable count

  2. Program to declare, initialize and print an array of characters

  3. Program to print some text on the same line using multiple print statements

  4. Program to show the use of Nested If-Else Statements

  5. Program to extract a portion of a character string and print the extracted string

  6. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

  7. RMI servlet program to display message

  8. Game application in CORBA for which player will guess a number between 1 to 100, which will be compared to the random number generated by the class

  9. Corba program of game

  10. Program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7

  11. Corba program to Write a Echo server and client with UDP server and client

  12. Program to show the use of Bitwise Operator (|) OR

  13. Create an interface coversions. Which have the following functions Inchestomillimeters(), hptowatts(),wattstohp(),poundstogram(),gramtopounds()

  14. Socket program of HTTP Server

  15. Program to show the use of Logical or Boolean Negation i.e. NOT (!)

  16. Program to convert the given temperature in faherenhiet to celsius using the following conversion formula C= F- 32/1.8

  17. Program to display triangle of numbers

  18. An applet program that creates string dynamically and displays it

  19. Program to print triangle of numbers

  20. Write a program for restaurant

 
 
Didn't find what you were looking for? Find more on Corba program of reverse string