Vous êtes sur la page 1sur 4

DEVELOP A MIDDLEWARECOMPONENT FOR RETRIEVING WEATHER FORECAST INFORMATION USING CORBA AIM: To Create a Component for retrieving stock

market exchange information using


CORBA

DESCRIPTION:
Steps required: 1. efine the ! " interface #. !mp$ement the ! " interface using id$% compi$er &. Create a C$ient 'rogram (. Create a Server 'rogram ). Start or*d. +. Start the Server. ,. Start the c$ient

// Define IDL Interface

modu$e -eather. interface forecast . f$oat get/min012 f$oat get/max0123232


N te: Save the a*ove modu$e as -eather.id$
Compi$e the saved modu$e using the id$% compi$er as fo$$o-s . C:!" #$i!#eat%er&i'() #eat%er*i'( After compi$ation a su* director4 ca$$ed -eather same as modu$e name -i$$ *e created and it generates the fo$$o-ing fi$es as $isted *e$o-. C:5so-mi5-eather6cd -eather C:5so-mi5-eather5-eather6dir 7o$ume in drive C has no $a*e$. 7o$ume Seria$ 8um*er is &(9A:#,B, irector4 of C:5su%i5-eather5-eather ;&<1(<#;;, ;#:)# '= > !R6 . ;&<1(<#;;, ;#:)# '= > !R6 .. ;&<1(<#;;, ;#:)) '= #?#(; forecast'OA.%ava ;&<1(<#;;, ;#:)) '= #?,#@ /forecastStu*.%ava ;&<1(<#;;, ;#:)) '= ,@+ forecastAo$der.%ava ;&<1(<#;;, ;#:)) '= 1?@#+ forecastAe$per.%ava ;&<1(<#;;, ;#:)) '= &&; forecast.%ava ;&<1(<#;;, ;#:)) '= &1@ forecastOperations.%ava ;&<1)<#;;, 1;:(# A= #?1(( forecast'OA.c$ass ;&<1)<#;;, 1;:(# A= 1+, forecastOperations.c$ass ;&<1)<#;;, 1;:(# A= #;, forecast.c$ass ;&<1)<#;;, 1;:(# A= #?,#( forecastAe$per.c$ass ;&<1)<#;;, 1;:(# A= #?(;& /forecastStu*.c$ass 11 Bi$e0s1 1)?@9) *4tes # ir0s1 1?,#+?1;&?))# *4tes free

C:5so-mi5-eather5-eather6

// I$+(e$ent t%e interface


import org.omg.CORBA.C2 import -eather.C2 import %ava.uti$.C2 pu*$ic c$ass -eatherimp$ extends forecast'OA . private ORB or*2 int rDEFne- intD1;E2 f$oat sDEFne- f$oatD1;E2 Random rrFne- Random012 pu*$ic void setORB0ORB v1.or*Fv23 pu*$ic f$oat get/min01 . for0int iF;2i>1;2iGG1 . rDiEF=ath.a*s0rr.next!nt0112 sDiEF=ath.round00f$oat1rDiEC;.;;;;;;;112 3 f$oat min2 minFsD;E2 for0int iF12i>1;2iGG1 . if 0min6sDiE1 min FsDiE2 3 f$oat mintempF=ath.a*s00f$oat10min:&#1C)<@12 return mintemp23 pu*$ic f$oat get/max01 . for0int iF;2i>1;2iGG1 . rDiEF=ath.a*s0rr.next!nt0112 sDiEF=ath.round00f$oat1rDiEC;.;;;;;;;112 f$oat max2 maxFsD;E2 for0int iF12i>1;2iGG1 . if 0max>sDiE1 max FsDiE2 3 f$oat maxtempF=ath.a*s00f$oat10max:&#1C)<@12 return maxtemp23 pu*$ic -eatherimp$01.super01233 //Ser,er Pr -ra$ import org.omg.CORBA.C2 import org.omg.Cos8aming.C2 import org.omg.Cos8aming.8amingContext'ackage.C2 import org.omg.'orta*$eServer.C2

import org.omg.'orta*$eServer.'OA.C2 import %ava.uti$.'roperties2 import -eather.C2 pu*$ic c$ass -eatherserver. pu*$ic static void main0StringDE args1 . tr4 . ORB or*FORB.init0args?nu$$12 'OA rootpoaF'OAAe$per.narro-0or*.reso$ve/initia$/references0HRoot'OAH112 rootpoa.the/'OA=anager01.activate012 -eatherimp$ ssFne- -eatherimp$012 ss.setORB0or*12 org.omg.CORBA.O*%ect refFrootpoa.servant/to/reference0ss12 forecast hrfFforecastAe$per.narro-0ref12 org.omg.CORBA.O*%ect orfFor*.reso$ve/initia$/references0H8ameServiceH12 8amingContextIxt ncrfF8amingContextIxtAe$per.narro-0orf12 8ameComponent pathDEFncrf.to/name0HforecastH12 ncrf.re*ind0path?hrf12 S4stem.out.print$n0H-eather server is read4H12 or*.run012 3 catch0Ixception e1. e.printStackTrace012333

// C(ient Pr -ra$
import org.omg.CORBA.C2 import org.omg.Cos8aming.C2 import -eather.C2 import org.omg.Cos8aming.8amingContext'ackage.C2 import %ava.uti$.C2 pu*$ic c$ass -eatherc$ient . pu*$ic static void main0StringDE args1 . String cit4DEF.HChennai H?HTrich4 H?H=adurai H?HCoim*atoreH?HSa$em H32 Ca$endar ccFCa$endar.get!nstance012 tr4 . ORB or*FORB.init0args?nu$$12 8amingContextIxt ncRefF8amingContextIxtAe$per.narro-0or*.reso$ve/initia$/references0H8ameServiceH11 2 forecast frFforecastAe$per.narro-0ncRef.reso$ve/str0HforecastH112 S4stem.out.print$n0H5t5t5tJ I A T A I R B O R I C A S TH12 S4stem.out.print$n0H5t5t5tKKKKKKKKKKKKKKKKKKKKKKKKKKKKKH12 S4stem.out.print$n012 S4stem.out.print$n0H5t ATI T!=I C!TL A!MAIST "OJIST H12 S4stem.out.print$n0H5t TI='IRATNRI TI='IRATNRIH12

for0int iF;2i>)2iGG1 . S4stem.out.print0H5tHGcc.get0Ca$endar. ATI1 Gcc.get0Ca$endar.=O8TA1Gcc.get0Ca$endar.LIAR1GH HGcc.get0Ca$endar.AONR1GH HGcit4DiEGH HGH H12 S4stem.out.print0=ath.f$oor0fr.get/min011GH5t 5tHG=ath.cei$0fr.get/max01112 S4stem.out.print$n012 33 catch0Ixception e1. e.printStackTrace012333 Compi$e the a*ove fi$es as C:5so-mi5-eather6%avac C.%ava C:5so-mi5-eather6start or*d :ORB!nitia$'ort 1;); :ORB!nitia$Aost $oca$host

C:5so-mi5cor*a6start %ava -eatherserver :ORB!nitia$'ort 1;); :ORB!nitia$Aost $oca$host C:5so-mi5-eather6 -eather server is read4 C:5so-mi5cor*a6%ava -eatherc$ient :ORB!nitia$'ort 1;); :ORB!nitia$Aost $oca$h ost C:5so-mi5-eather6%ava -eatherc$ient :ORB!nitia$'ort 1;); :ORB!nitia$Aost $oca$host

Vous aimerez peut-être aussi