To
write a program to develop a middle-ware component for retrieving Stock Market
Exchange information using CORBA.
- Creating a module which contains a set of interface program and save it as a SimpleStocks.idl makes sure that module and interface name is different.
- Next declare the implementation file with ImplBase concept & contains details about stock maintenance.
- 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 server object and client object declared resembles the frame.
- Then provide the input to the client program and obtain the suitable output corresponding to it.
Compile & Execution Steps:
- idlj -fall -oldImplBase SimpleStocks.idl
- javac StockMarketImpl.java SimpleStocks\*.java
- javac StockMarket server.java SimpleStocks\*.java
- javac StockMarket client.java SimpleStocks\*.java
- start orbd -ORBInitialPort 1050
- start java StockMarket Server -ORBInitialPort 1050
- java StockMarket client -ORBInitialPort 1050 50.
Simplestock.idl
// Comment module Simplestock { interface stockmarket { float get_price(in string symbol); }; };
stockmarketimpl.java
// Comment import org.omg.CORBA.*; import simplestocks.*; public class stockmarketimpl extends _stockmarketImplBase { public float get_price(String symbol) { float price=0; for(int i=0;i<symbol.length();i++) { price+=(int)symbol.charAt(i); } price/=5; return price; } public stockmarketimpl() { super(); } }
Stockmarketserv.java
// Comment import org.omg.CORBA.*; import org.omg.CosNaming.*; import simplestocks.*; public class stockmarketserv { public static void main(String args[]) { try { ORB orb=ORB.init(args,null); stockmarketimpl stockmarketimpl=new stockmarketimpl(); orb.connect(stockmarketimpl); 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,stockmarketimpl); System.out.println("Stockmarket server is ready"); Thread.currentThread().join(); } catch(Exception e) { e.printStackTrace(); } } }
stockmarketcli.java
// Comment import org.omg.CORBA.*; import org.omg.CosNaming.*; import simplestocks.*; public class stockmarketcli { public static void main(String args[]) { try { ORB orb=ORB.init(args,null); NamingContext ncRef=NamingContextHelper.narrow(orb.resolve_initial_references("NameService")); NameComponent path[]={new NameComponent("NASDAQ"," ")}; stockmarket market=stockmarketHelper.narrow(ncRef.resolve(path)); System.out.println("Rate of the company is"+market.get_price(args[2])); } catch(Exception e) { e.printStackTrace(); } } }
Output Screen
First of all let me tell you, you have got a great blog .I am interested in looking for more of such topics and would like to have further information. Hope to see the next blog soon.
ReplyDeleteIt is a well executed post. I like the diagram most. It is a helpful informative post. Thanks for sharing this great information.
ReplyDeletehelp ful post and very best for article data stock tips and share tips
ReplyDeleteIf you are looking for more information about flat rate locksmith Las Vegas check that right away. aprende la bolsa malaga
ReplyDeleteWe offer the best stock alert service with swing trade alerts, day trade alerts, and penny stock alerts Profitable Trading Strategies
ReplyDelete