Docsity

NLP ASSIGNMENT ENGINEERING, Lab Reports of Natural Language Processing (NLP)

Toggle sidebar
bg1
Laboratory Practice -V (414454)
Class: BE(IT)
Department of Information Technology Engineering, ZCOER, Narhe, Pune-41
Page 12
AIM: Develop any distributed application using CORBA to demonstrate object
brokering. (Calculator or String operations).
Objective:
basic implementation of a Java/CORBA application using static invocations.
Outcome:
CORBA also provides a dynamic invocation capability where clients can
discover the interfaces on-the-fly.
Explanation:
Common Object Request Broker Architecture (CORBA) could be a
specification of a regular design for middleware. It is a client-server software
development model
CORBA Reference Model:
The CORBA reference model known as Object Management design (OMA) is
shown below figure. The OMA is itself a specification (actually, a group of
connected specifications) that defines a broad vary of services for building
distributed client-server applications
Assignment No 2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download NLP ASSIGNMENT ENGINEERING and more Lab Reports Natural Language Processing (NLP) in PDF only on Docsity!

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41 AIM: Develop any distributed application using CORBA to demonstrate object brokering. (Calculator or String operations). Objective: basic implementation of a Java/CORBA application using static invocations. Outcome: CORBA also provides a dynamic invocation capability where clients can discover the interfaces on-the-fly. Explanation: Common Object Request Broker Architecture (CORBA) could be a specification of a regular design for middleware. It is a client-server software development model CORBA Reference Model: The CORBA reference model known as Object Management design (OMA) is shown below figure. The OMA is itself a specification (actually, a group of connected specifications) that defines a broad vary of services for building distributed client-server applications Assignment No 2

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41 Divide and conquer. The remote objects can be independently designed. Increase reusability. It is often possible to design the remote objects so that other systems can use them too. Increase reuse. You may be able to reuse remote objects that others have created. Design for flexibility. The broker objects can be updated as required, or you can redirect the proxy to communicate with a different remote object. Design for portability. You can write clients for new platforms while still accessing brokers and remote objects on other platforms. Design defensively. You can provide careful assertion checking in the remote objects. The Calculator sample application is a basic implementation of a Java/CORBA application using static invocations. A static invocation is when a client is aware of what interfaces and methods are available at compile time. Note: CORBA also provides a dynamic invocation capability where clients can discover the interfaces on- the-fly. The Java/COBRA development process for the Calculator example application is broken down in to ten manageable steps:

  1. Download and install a Java ORB
  2. Create IDL file
  3. Compile IDL file
  4. Create the client
  5. Create the server
  6. Create the interface implementation
  7. Compile the client
  8. Compile the server
  9. Compile the interface implementation
  10. Start the naming service (OS Agent)
  11. Start the server
  12. Start the client. Program for Calculator Application
  13. Calc.idl: module WssCalculator {

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41 import java.util.Properties; //Perform the Input-Output functionalities import java.io.; import java.util.; //Write the Servant class //It inherits the general CORBA utilities generated by the Compiler class Calcserverimpl extends CalcPOA { //orb variable is used to invoke the shutdown() private ORB orb; public void setORB(ORB orb_val) { orb = orb_val; } //Declaring and Implementing the required method public int calculate(int a,int b,int c) {

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41

//ADDITION

if(a==43) { return (b+c); } //SUBTRACTION else if(a==45) { return (b-c); } //MULTIPLICATION else if(a==42) { return (b*c); } //DIVISION else if(a==47) { return (b/c); }

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41 ORB orb=ORB.init(args,null); //Obtain the initial Naming Context //Obtain an initial object reference to the name server //orb retrieves the reference to the Root POA //Activate the POA Manager //activate() causes the POAs to process the client requests POA rootpoa=POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootpoa.the_POAManager().activate(); //The server instantiates the servant objects //The servant performs the operations defined in the idlj interface Calcserverimpl simpl=new Calcserverimpl(); simpl.setORB(orb); //Get the object reference associated with the servant //narrow() is used to cast CORBA obj ref to its proper type org.omg.CORBA.Object ref = rootpoa.servant_to_reference(simpl); Calc href=CalcHelper.narrow(ref); //Obtain the initial Naming Context //Obtain an object reference to the Name Server org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService");

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41 //Narrow the objref to its proper type NamingContextExt ncRef=NamingContextExtHelper.narrow(objRef); //Register the Servant with the Name Server String name = "Calc"; //NameComponent array contains the path to Calc NameComponent path[]=ncRef.to_name(name); //Pass the path and the servant object to the Naming Service //Bind the servant object to Calc ncRef.rebind(path,href); System.out.println("The SERVER is READY"); System.out.println("The SERVER is WAITING to receive the CLIENT requests"); //run() is called by the main thread //run() enables the ORB to perform work using the main thread //the server waits until an invocation comes from the ORB orb.run(); } catch (Exception e) { System.err.println("ERROR: " + e); e.printStackTrace(System.out); }

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41

try { //Declaring and initializing the variables int dec=1; int i=0; int j=0; int k=0; int result=0; int x=1; char c='x'; char d='y'; char f='z'; String abc="vas"; //Create and Initialize the ORB object //init() allows to set properties at run time ORB orb=ORB.init(args,null); //ORB helps the Client to locate the actual services which it needs //COS Naming Service helps the client to do so //Obtain the initial Naming Context //Obtain an object reference to the name server

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41 org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService"); //Narrow the objref to its proper type NamingContextExt ncRef=NamingContextExtHelper.narrow(objRef); //Identify a String to refer the Naming Service to Calc object String name="Calc"; //Get a reference to the CalcServer and Narrow it to Calc object cimpl=CalcHelper.narrow(ncRef.resolve_str(name)); System.out.println("Obtained a handle on the server object"); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); while(x==1) { System.out.println("Enter the string:"); abc=br.readLine(); //Separate the input string into separate characters c=abc.charAt(0); d=abc.charAt(1); f=abc.charAt(2); //Get the ASCII value of the Operator i=(int)c; //Get the Integer values of the other two characters j=Character.getNumericValue(d);

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41 Output:

Class: BE(IT) Department of Information Technology Engineering, ZCOER, Narhe, Pune- 41 Result: Successfully Created CORBA system for Timestamp application. Date: Marks obtained: Sign of course coordinator: Name of course Coordinator :