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 show an example of Concatination of Strings

  2. Program of creating a file using text fields in windows

  3. RMI based application for login validation based on data saved in text file stored on the server and will display appropriate message to the client..

  4. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  5. Program to show an example of Polymorphism

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

  7. Program to show an example of using user-defined package in a program

  8. Program of date server and client

  9. Program to show the use of Logical OR Operator (|) in If Statements

  10. Program that takes a long sentence and a character from the client and count the occurrence of the character in the sentence at the server side

  11. Program to evaluate following investment equation V=P(1+R)^N

  12. Program of concatenating and Buffering files

  13. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

  14. Corba program of Count Client Applet, IDL,Server, Client

  15. Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side

  16. An applet program to perform merge sort

  17. An applet program to display barchart of given data

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

  19. Program of FTP client and server

  20. Program to declare, initialize and print a StringBuffer object

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