Namecomponent ncnew

Info icon This preview shows pages 16–20. Sign up to view the full content.

nobj=NamingContextHelper.narrow(orb.resolve_initial_references("NameService")); NameComponent nc=new NameComponent("EMP"," "); NameComponent[] path={nc}; nobj.rebind(path,obj); java.lang.Object oobj=new java.lang.Object(); synchronized(oobj) { oobj.wait();} } } Client Program: Client1.java import emp.*; import org.omg.CORBA.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import emp.*; import java.io.*; import java.util.*; public class Client1
Image of page 16

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

DS & ADB DCET RAHEEM UNNISA 17 160317742004 { public static void main(String args[])throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); ORB orb=ORB.init(args,null); implservent obj=new implservent(); orb.connect(obj); NamingContext nobj=NamingContextHelper.narrow(orb.resolve_initial_references("NameService")); NameComponent nc=new NameComponent("EMP"," "); NameComponent[] path={nc}; emp_intf ei=emp_intfHelper.narrow(nobj.resolve(path)); System.out.print("Enter EMP id:"); String rval=obj.getStatus(Integer.parseInt(br.readLine())); if(!rval.equals("~")) System.out.println("Current salary is : " + rval); else System.out.println("Invalid EMP id"); } } EXECUTION STEPS: 1) Run the IDL-to-Java compiler, idlj , on the IDL file to create stubs and skeletons idlj fall -oldImplBase emp_intf.idl 2) Compile the .java files, including the stubs and skeletons (which are in the directory HelloApp ) j avac *.java emp/*.java 3) Start orbd start orbd 4) Run Server Application start java Server1 4) Run Client Application java Client1
Image of page 17
DS & ADB DCET RAHEEM UNNISA 18 160317742004 OUTPUT:
Image of page 18

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

DS & ADB DCET RAHEEM UNNISA 19 160317742004 Introduction to RMI If the network is the computer, we ought to be able to put the two classes on different computers then RMI is one technology that makes this possible CORBA (Common Object Request Broker Architecture) was used for a long time CORBA supports object transmission between virtually any languages Objects have to be described in IDL (Interface Definition Language), which looks a lot like C++ data definitions CORBA is complex and flaky CORBA has fallen out of favor Microsoft supported CORBA, then COM, now .NET RMI is purely Java-specific Java to Java communications only As a result, RMI is much simpler than CORBA What is the need of RMI? Java makes RMI (Remote Method Invocation) fairly easy, but there are some extra steps To send a message to a remote “server object,” The “client object” has to find the object. The client object then has to marshal the parameters (prepare them for transmission) Java requires Serializable parameters The server object has to unmarshal its parameters, do its computation, and marshal its response The client object has to unmarshal the response Much of this is done for you by special software Remote Method Invocation (RMI) facilitates object function calls between Java Virtual Machines (JVMs). JVMs can be located on separate computers - yet one JVM can invoke methods belonging to an object stored in another JVM. Methods can even pass objects that a foreign virtual machine has never encountered before, allowing dynamic loading of new classes as required. This is a powerful feature!
Image of page 19
Image of page 20
This is the end of the preview. Sign up to access the rest of the document.
  • Winter '16
  • zeenath
  • ADB, RAHEEM UNNISA

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern