Weather Forecast Information Using CORBA


To develop the application program in CORBA to illustrate the temperature server.

  •  Creating a module which contains a set of interface program and save it as a Simple Temperature.idl makes sure that module and interface name is different.
  • Next declare the implementation file with IMPL Base concepts & contains details about temperature display.
  • Create a server program that initialize the ORB name the server object &bind the server object with the implementation file.
  • Now server is ready.
  • Create a client program by initialize the ORB. make sure the name of the server object and client object declared reassembles the fram.
  • Then provide the input to the client program and obtain the suitable output corresponding to it.
Compile & Execution Steps


  •    idlj -fall -oldImplBase SimpleTemperature.idl
  •    javac Temperatureimpl.java SimpleTemperature\*.java
  •    javac Temperatureserver.java SimpleTemperature\*.java
  •     javac Temperatureclient.java SimpleTemperature\*.java
  •       start orbd -ORBInitialPort 1050
  •      start java Temperature server -ORBInitialport 1050
  •       server is ready.
  •   java Temperature client -ORBInitialport 1050 30
 
SimpleTemperature.idl

// Comment
module SimpleTemperature
{
interface Temperature
{
string get_tmp(in float a);
};
}; 

Temperatureimpl.java

// Comment

import org.omg.CORBA.*;
import SimpleTemperature.*;
public class Temperatureimpl extends _TemperatureImplBase
{
public String get_tmp(float a)
{
String c;
if (a<0)
c="----------Too cool----------";
else if(a<=10)
c="----------cool----------";
else if(a<=20)
c="----------MODERATE----------";
else if(a<=30)
c="----------HOT----------";
else
c="----------TOO HOT----------";
return c;
}

public Temperatureimpl()
{
super();
}
}

Temperatureserver.java

// Comment
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import SimpleTemperature.*;
public class Temperatureserver
{
public static void main(String args[])
{
try
{
ORB orb=ORB.init(args,null);
Temperatureimpl temperatureImpl=new Temperatureimpl();
orb. connect(temperatureImpl);
org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService");
NamingContext ncRef=NamingContextHelper.narrow(objRef);
NameComponent nc=new NameComponent("NASDAQ","");
NameComponent path[]={nc};
ncRef.rebind(path,temperatureImpl);
System.out.println("Temperature SERVER is Ready");
Thread.currentThread().join();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

Temperatureclient.java

// Comment
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import SimpleTemperature.*;
public class Temperatureclient
{
public static void main(String args[])
{
try
{
float e=Float.parseFloat(args[2]);
ORB orb=ORB.init(args,null);
NamingContext ncRef=NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));
NameComponent path[]={new NameComponent("NASDAQ","")};
Temperature tempr=TemperatureHelper.narrow(ncRef.resolve(path));
System.out.println("\t\t Weather Casting");
System.out.println("\t\t_ _ _ _ _ _ _ _ _ _ _ _");
System.out.println("Input is:"+e);
System.out.println("WEATHER is:"+tempr.get_tmp(e));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}


Output Screen
raja P Web Developer

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...