SlideShare a Scribd company logo
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
EX NO :6 DATE : 27-8-2014 
STOCK APPLICATION USING CORBA 
NAME : M.F.JERINCE RAJA ROLLNO : 12LMC004 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
STOCK.IDL 
********* 
module stck_market 
{ 
interface stock 
{ 
const unsigned short SIZE = 20; 
typedef string name[SIZE]; 
typedef short id[6]; 
typedef short amount[10]; 
typedef long shares[SIZE]; 
typedef string addr[SIZE]; 
long buyshare(in long amt,in long share); 
long sellshare(in long amt,in long share); 
}; 
}; 
STOCKIMPL 
********** 
import stck_market.*; 
import org.omg.CORBA.*; 
class stckimpl extends stockPOA 
{ 
private ORB orb; 
public stckimpl(ORB orb) 
{ 
this.orb = orb; 
} 
public int buyshare(int amt,int share) 
{ 
return(amt*share); 
} 
public int sellshare(int amt,int share) 
{ 
return(amt*share); 
} 
} 
SERVER 
****** 
import stck_market.*; 
import org.omg.CORBA.*; 
import org.omg.CosNaming.*; 
import org.omg.PortableServer.*; 
import org.omg.PortableServer.POA; 
import org.omg.CosNaming.NamingContextPackage.*; 
public class server 
{ 
public static void main(String args[])
{ 
try 
{ 
ORB orb = ORB.init(args, null); 
stckimpl imp_obj = new stckimpl(orb); 
POA rootpoa = 
POAHelper.narrow(orb.resolve_initial_references("RootPOA")); 
rootpoa.the_POAManager().activate(); 
org.omg.CORBA.Object ref = 
rootpoa.servant_to_reference(imp_obj); 
stock href = stockHelper.narrow(ref); 
org.omg.CORBA.Object objRef = 
orb.resolve_initial_references("NameService"); 
NamingContextExt ncRef = 
NamingContextExtHelper.narrow(objRef); 
String name = "stock"; 
NameComponent path[] = ncRef.to_name( name ); 
ncRef.rebind(path, href); 
System.out.println(" Server ready... "); 
orb.run(); 
} 
catch (Exception e) 
{ 
System.err.println("ERROR: " + e); 
e.printStackTrace(System.out); 
} 
System.out.println("Server Exiting ...."); 
} 
} 
CLIENT 
******* 
import stck_market.*; 
import org.omg.CORBA.*; 
import org.omg.CosNaming.*; 
import org.omg.CosNaming.NamingContextPackage.*; 
import java.io.*; 
public class client 
{ 
public static void main(String args[]) 
{ 
try 
{ 
int cmid = 0, csid = 0, repeat = 1,n; 
int comp_id[] = new int[6]; 
String comp_name[] = new String[stck_market.stock.SIZE]; 
int shr[] = new int[stck_market.stock.SIZE]; 
int shr_pri[] = new int[stck_market.stock.SIZE]; 
String comp_addr[] = new String[stck_market.stock.SIZE]; 
int amt[] = new int[stck_market.stock.SIZE];
int cust_id[] = new int[6]; 
String cust_name[] = new String[stck_market.stock.SIZE]; 
int cust_shr[] = new int[stck_market.stock.SIZE]; 
String cust_addr[] = new String[stck_market.stock.SIZE]; 
int cust_amt[] = new int[stck_market.stock.SIZE]; 
int ctshr_pri[] = new int[stck_market.stock.SIZE]; 
BufferedReader br = new BufferedReader(new 
InputStreamReader(System.in)); 
ORB orb = ORB.init(args, null); 
org.omg.CORBA.Object objRef = 
orb.resolve_initial_references("NameService"); 
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); 
String name = "stock"; 
stock obj = stockHelper.narrow(ncRef.resolve_str(name)); 
System.out.println("Handle obtained on server object: "+obj); 
System.out.println(" CORBA APPLICATION FOR STOCK MARKET "); 
System.out.println(" ~~~~~ ~~~~~~~~~~~ ~~~ ~~~~~ ~~~~~~ "); 
System.out.println(" Enter the number of company & customer to be 
registered : "); 
n = Integer.parseInt(br.readLine()); 
for(int i=0;i<n;i++) 
{ 
System.out.println("tt Company Registration "); 
System.out.println(" Enter the company ID : "); 
comp_id[i] = Integer.parseInt(br.readLine()); 
System.out.println(" Enter the company name : "); 
comp_name[i] = br.readLine(); 
System.out.println(" Enter the company address : "); 
comp_addr[i] = br.readLine(); 
System.out.println(" Enter the company shares : "); 
shr[i] = Integer.parseInt(br.readLine()); 
System.out.println(" Enter the unit prize of shares : "); 
shr_pri[i] = Integer.parseInt(br.readLine()); 
System.out.println(" Enter the total amount of shares owned : 
"); 
amt[i] = Integer.parseInt(br.readLine()); 
System.out.println("tt Customer Registration "); 
System.out.println(" Enter the customer ID : "); 
cust_id[i] = Integer.parseInt(br.readLine()); 
System.out.println(" Enter the customer name : "); 
cust_name[i] = br.readLine(); 
System.out.println(" Enter the customer address : "); 
cust_addr[i] = br.readLine(); 
System.out.println(" Enter the number of shares owned : "); 
cust_shr[i] = Integer.parseInt(br.readLine()); 
System.out.println(" Enter the unit prize of shares : "); 
ctshr_pri[i] = Integer.parseInt(br.readLine()); 
System.out.println(" Enter the total amount of shares owned : 
"); 
cust_amt[i] = Integer.parseInt(br.readLine()); 
} 
do 
{ 
System.out.println(" 1 - > BUY SHARES 2 - > SELL SHARES 3 - > LIST 
THE DETAILS "); 
System.out.println(" Enter the choice : "); 
int ch = Integer.parseInt(br.readLine()); 
switch(ch) 
{ 
case 1: 
System.out.println("t BUY SHARES "); 
System.out.println(" Enter the company ID : "); 
cmid = Integer.parseInt(br.readLine());
System.out.println(" Enter the customer ID : "); 
csid = Integer.parseInt(br.readLine()); 
for(int i=0;i<n;i++) 
{ 
if(cmid==comp_id[i] && csid==cust_id[i]) 
{ 
System.out.println(" Enter the number of shares to buy : "); 
int share = Integer.parseInt(br.readLine()); 
int unit_price = shr_pri[i]; 
int cur_amt = obj.buyshare(unit_price,share); 
System.out.println(" Shares bought : "+share); 
System.out.println(" Total amount : "+cur_amt); 
shr[i] = shr[i] - share; 
amt[i] = amt[i] - cur_amt; 
cust_shr[i] = cust_shr[i] + share; 
cust_amt[i] = cust_amt[i] + cur_amt; 
break; 
}} 
break; 
case 2: 
System.out.println("t SELL SHARES "); 
System.out.println(" Enter the company ID : "); 
cmid = Integer.parseInt(br.readLine()); 
System.out.println(" Enter the customer ID : "); 
csid = Integer.parseInt(br.readLine()); 
for(int i=0;i<n;i++) 
{ 
if(cmid==comp_id[i] && csid==cust_id[i]) 
{ 
System.out.println(" Enter the number of shares to sell : "); 
int share = Integer.parseInt(br.readLine()); 
int unit_price = ctshr_pri[i]; 
int cur_amt = obj.sellshare(unit_price,share); 
System.out.println(" Shares sold : "+share); 
System.out.println(" Total amount : "+cur_amt); 
shr[i] = shr[i] + share; 
amt[i] = amt[i] + cur_amt; 
cust_shr[i] = cust_shr[i] - share; 
cust_amt[i] = cust_amt[i] - cur_amt; 
break; 
} 
} 
break; 
case 3: 
for(int i=0;i<n;i++) 
{ 
System.out.println("ttt Company Details "); 
System.out.println("t Company ID : "+comp_id[i]); 
System.out.println("t Company name : "+comp_name[i]); 
System.out.println("t Company Shares : "+shr[i]); 
System.out.println("t Total Amount of Shares Owned : "+amt[i]); 
System.out.println("ttt Customer Details "); 
System.out.println("t Customer ID : "+cust_id[i]); 
System.out.println("t Customer Name : "+cust_name[i]); 
System.out.println("t Total Number of Shares Owned : "+cust_shr[i]); 
System.out.println("t Total Amount of Shares Owned : "+cust_amt[i]);
} 
break; 
} 
System.out.println(" Press 1 to continue... "); 
repeat = Integer.parseInt(br.readLine()); 
}while(repeat==1); 
} 
catch (Exception e1) 
{ 
System.out.println("ERROR : " + e1) ; 
e1.printStackTrace(System.out); 
} 
} 
} 
OUTPUT 
****** 
Z:st>idlj -fall stock.idl 
Z:st>javac *.java 
Note: .stck_marketstockPOA.java uses unchecked or unsafe operations. 
Note: Recompile with -Xlint:unchecked for details. 
Z:st>javac *.java stck_market/*.java 
Note: stck_marketstockPOA.java uses unchecked or unsafe operations. 
Note: Recompile with -Xlint:unchecked for details. 
Z:st>orbd -ORBInitialPort 2500 
Z:st>java server -ORBInitialPort 2500 
Server ready... 
CORBA APPLICATION FOR STOCK MARKET 
~~~~~ ~~~~~~~~~~~ ~~~ ~~~~~ ~~~~~~ 
Enter the number of company & customer to be registered : 
1 
Company Registration 
Enter the company ID : 
1234 
Enter the company name : 
cicso 
Enter the company address : 
northstreet 
Enter the company shares : 
100 
Enter the unit priCe of shares : 
50 
Enter the total amount of shares owned : 
80 
Customer Registration 
Enter the customer ID : 
101 
Enter the customer name : 
RAJA 
Enter the customer address : 
M.G,.R nagar 
Enter the number of shares owned : 
40 
Enter the unit prize of shares :
40 
Enter the total amount of shares owned : 
10 
1 - > BUY SHARES 2 - > SELL SHARES 3 - > LIST THE DETAILS 
Enter the choice : 
1 
BUY SHARES 
Enter the company ID : 
1234 
Enter the customer ID : 
101 
Enter the number of shares to buy : 
15 
Shares bought : 15 
Total amount : 750 
Press 1 to continue...
40 
Enter the total amount of shares owned : 
10 
1 - > BUY SHARES 2 - > SELL SHARES 3 - > LIST THE DETAILS 
Enter the choice : 
1 
BUY SHARES 
Enter the company ID : 
1234 
Enter the customer ID : 
101 
Enter the number of shares to buy : 
15 
Shares bought : 15 
Total amount : 750 
Press 1 to continue...

More Related Content

Viewers also liked

HR QUESTIONS
HR QUESTIONSHR QUESTIONS
HR QUESTIONS
Senthil Kanth
 
13.IO systems
13.IO systems13.IO systems
13.IO systems
Senthil Kanth
 
4.Threads
4.Threads4.Threads
4.Threads
Senthil Kanth
 
12.mass stroage system
12.mass stroage system12.mass stroage system
12.mass stroage system
Senthil Kanth
 
7.Dead Locks
7.Dead Locks7.Dead Locks
7.Dead Locks
Senthil Kanth
 
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEEXML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
Senthil Kanth
 
2.Operating System Structures
2.Operating System Structures2.Operating System Structures
2.Operating System Structures
Senthil Kanth
 
3.Process Management
3.Process Management3.Process Management
3.Process Management
Senthil Kanth
 
RSA alogrithm
RSA alogrithmRSA alogrithm
RSA alogrithm
Senthil Kanth
 
Introduction to Mobile Application Development
Introduction to Mobile Application DevelopmentIntroduction to Mobile Application Development
Introduction to Mobile Application Development
Senthil Kanth
 
WML Script by Shanti katta
WML Script by Shanti kattaWML Script by Shanti katta
WML Script by Shanti katta
Senthil Kanth
 
Introduction to wireless application protocol (wap)ogi
Introduction to wireless application protocol (wap)ogiIntroduction to wireless application protocol (wap)ogi
Introduction to wireless application protocol (wap)ogi
Senthil Kanth
 
6.Process Synchronization
6.Process Synchronization6.Process Synchronization
6.Process Synchronization
Senthil Kanth
 
11.file system implementation
11.file system implementation11.file system implementation
11.file system implementation
Senthil Kanth
 
Markup Languages
Markup Languages Markup Languages
Markup Languages
Senthil Kanth
 
Wireless Application Protocol WAP by Alvinen
Wireless Application Protocol WAP by AlvinenWireless Application Protocol WAP by Alvinen
Wireless Application Protocol WAP by Alvinen
Senthil Kanth
 
What is WAP?
What is WAP?What is WAP?
What is WAP?
Senthil Kanth
 
Wireless Communication and Networking by WilliamStallings Chap2
Wireless Communication and Networking  by WilliamStallings Chap2Wireless Communication and Networking  by WilliamStallings Chap2
Wireless Communication and Networking by WilliamStallings Chap2
Senthil Kanth
 

Viewers also liked (19)

HR QUESTIONS
HR QUESTIONSHR QUESTIONS
HR QUESTIONS
 
1.Introduction
1.Introduction1.Introduction
1.Introduction
 
13.IO systems
13.IO systems13.IO systems
13.IO systems
 
4.Threads
4.Threads4.Threads
4.Threads
 
12.mass stroage system
12.mass stroage system12.mass stroage system
12.mass stroage system
 
7.Dead Locks
7.Dead Locks7.Dead Locks
7.Dead Locks
 
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEEXML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
 
2.Operating System Structures
2.Operating System Structures2.Operating System Structures
2.Operating System Structures
 
3.Process Management
3.Process Management3.Process Management
3.Process Management
 
RSA alogrithm
RSA alogrithmRSA alogrithm
RSA alogrithm
 
Introduction to Mobile Application Development
Introduction to Mobile Application DevelopmentIntroduction to Mobile Application Development
Introduction to Mobile Application Development
 
WML Script by Shanti katta
WML Script by Shanti kattaWML Script by Shanti katta
WML Script by Shanti katta
 
Introduction to wireless application protocol (wap)ogi
Introduction to wireless application protocol (wap)ogiIntroduction to wireless application protocol (wap)ogi
Introduction to wireless application protocol (wap)ogi
 
6.Process Synchronization
6.Process Synchronization6.Process Synchronization
6.Process Synchronization
 
11.file system implementation
11.file system implementation11.file system implementation
11.file system implementation
 
Markup Languages
Markup Languages Markup Languages
Markup Languages
 
Wireless Application Protocol WAP by Alvinen
Wireless Application Protocol WAP by AlvinenWireless Application Protocol WAP by Alvinen
Wireless Application Protocol WAP by Alvinen
 
What is WAP?
What is WAP?What is WAP?
What is WAP?
 
Wireless Communication and Networking by WilliamStallings Chap2
Wireless Communication and Networking  by WilliamStallings Chap2Wireless Communication and Networking  by WilliamStallings Chap2
Wireless Communication and Networking by WilliamStallings Chap2
 

Similar to STOCK APPLICATION USING CORBA

Below is my code- I have an error that I still have difficulty figurin.pdf
Below is my code- I have an error that I still have difficulty figurin.pdfBelow is my code- I have an error that I still have difficulty figurin.pdf
Below is my code- I have an error that I still have difficulty figurin.pdf
armanuelraj
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
Mitul Patel
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd marchRajeev Sharan
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
JumanneChiyanda
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdf
aravlitraders2012
 
#includeiostream.h#includestdlib.hstruct customers{.docx
#includeiostream.h#includestdlib.hstruct customers{.docx#includeiostream.h#includestdlib.hstruct customers{.docx
#includeiostream.h#includestdlib.hstruct customers{.docx
katherncarlyle
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
Ashwin Francis
 
Please follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdfPlease follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdf
proloyankur01
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
ssuserd6b1fd
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)
Arun Umrao
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
arjuncollection
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
Kevlin Henney
 
Fraud Detection and Neo4j
Fraud Detection and Neo4j Fraud Detection and Neo4j
Fraud Detection and Neo4j
Max De Marzi
 
i need to write a return type function that takes information about th.docx
i need to write a return type function that takes information about th.docxi need to write a return type function that takes information about th.docx
i need to write a return type function that takes information about th.docx
hendriciraida
 
i want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docxi want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docx
hendriciraida
 
Useful c programs
Useful c programsUseful c programs
Useful c programs
MD SHAH FAHAD
 
What you forgot from your Computer Science Degree
What you forgot from your Computer Science DegreeWhat you forgot from your Computer Science Degree
What you forgot from your Computer Science Degree
Stephen Darlington
 
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdfoperating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
arasanmobiles
 

Similar to STOCK APPLICATION USING CORBA (20)

Below is my code- I have an error that I still have difficulty figurin.pdf
Below is my code- I have an error that I still have difficulty figurin.pdfBelow is my code- I have an error that I still have difficulty figurin.pdf
Below is my code- I have an error that I still have difficulty figurin.pdf
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdf
 
#includeiostream.h#includestdlib.hstruct customers{.docx
#includeiostream.h#includestdlib.hstruct customers{.docx#includeiostream.h#includestdlib.hstruct customers{.docx
#includeiostream.h#includestdlib.hstruct customers{.docx
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
Please follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdfPlease follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdf
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
project3
project3project3
project3
 
Fraud Detection and Neo4j
Fraud Detection and Neo4j Fraud Detection and Neo4j
Fraud Detection and Neo4j
 
i need to write a return type function that takes information about th.docx
i need to write a return type function that takes information about th.docxi need to write a return type function that takes information about th.docx
i need to write a return type function that takes information about th.docx
 
i want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docxi want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docx
 
Lab 13
Lab 13Lab 13
Lab 13
 
Useful c programs
Useful c programsUseful c programs
Useful c programs
 
What you forgot from your Computer Science Degree
What you forgot from your Computer Science DegreeWhat you forgot from your Computer Science Degree
What you forgot from your Computer Science Degree
 
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdfoperating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
 

More from Senthil Kanth

wireless communication and networking Chapter 1
wireless communication and networking Chapter 1wireless communication and networking Chapter 1
wireless communication and networking Chapter 1
Senthil Kanth
 
WAP- Wireless Application Protocol
WAP- Wireless Application ProtocolWAP- Wireless Application Protocol
WAP- Wireless Application Protocol
Senthil Kanth
 
MOBILE APPs DEVELOPMENT PLATFORMS
MOBILE APPs DEVELOPMENT PLATFORMSMOBILE APPs DEVELOPMENT PLATFORMS
MOBILE APPs DEVELOPMENT PLATFORMS
Senthil Kanth
 
HR QUESTIONS, INTERVIEW QUESTIONS
HR QUESTIONS, INTERVIEW QUESTIONSHR QUESTIONS, INTERVIEW QUESTIONS
HR QUESTIONS, INTERVIEW QUESTIONS
Senthil Kanth
 
Zone Routing Protocol (ZRP)
Zone Routing Protocol (ZRP)Zone Routing Protocol (ZRP)
Zone Routing Protocol (ZRP)
Senthil Kanth
 
On-Demand Multicast Routing Protocol
On-Demand Multicast Routing ProtocolOn-Demand Multicast Routing Protocol
On-Demand Multicast Routing Protocol
Senthil Kanth
 
Adhoc routing protocols
Adhoc routing protocolsAdhoc routing protocols
Adhoc routing protocols
Senthil Kanth
 
DSDV VS AODV
DSDV VS AODV DSDV VS AODV
DSDV VS AODV
Senthil Kanth
 
16.Distributed System Structure
16.Distributed System Structure16.Distributed System Structure
16.Distributed System Structure
Senthil Kanth
 
15.Security
15.Security15.Security
15.Security
Senthil Kanth
 
14.Protection
14.Protection14.Protection
14.Protection
Senthil Kanth
 
10.file system interface
10.file system interface10.file system interface
10.file system interface
Senthil Kanth
 
9.Virtual Memory
9.Virtual Memory9.Virtual Memory
9.Virtual Memory
Senthil Kanth
 
5.CPU Scheduling
5.CPU Scheduling5.CPU Scheduling
5.CPU Scheduling
Senthil Kanth
 

More from Senthil Kanth (14)

wireless communication and networking Chapter 1
wireless communication and networking Chapter 1wireless communication and networking Chapter 1
wireless communication and networking Chapter 1
 
WAP- Wireless Application Protocol
WAP- Wireless Application ProtocolWAP- Wireless Application Protocol
WAP- Wireless Application Protocol
 
MOBILE APPs DEVELOPMENT PLATFORMS
MOBILE APPs DEVELOPMENT PLATFORMSMOBILE APPs DEVELOPMENT PLATFORMS
MOBILE APPs DEVELOPMENT PLATFORMS
 
HR QUESTIONS, INTERVIEW QUESTIONS
HR QUESTIONS, INTERVIEW QUESTIONSHR QUESTIONS, INTERVIEW QUESTIONS
HR QUESTIONS, INTERVIEW QUESTIONS
 
Zone Routing Protocol (ZRP)
Zone Routing Protocol (ZRP)Zone Routing Protocol (ZRP)
Zone Routing Protocol (ZRP)
 
On-Demand Multicast Routing Protocol
On-Demand Multicast Routing ProtocolOn-Demand Multicast Routing Protocol
On-Demand Multicast Routing Protocol
 
Adhoc routing protocols
Adhoc routing protocolsAdhoc routing protocols
Adhoc routing protocols
 
DSDV VS AODV
DSDV VS AODV DSDV VS AODV
DSDV VS AODV
 
16.Distributed System Structure
16.Distributed System Structure16.Distributed System Structure
16.Distributed System Structure
 
15.Security
15.Security15.Security
15.Security
 
14.Protection
14.Protection14.Protection
14.Protection
 
10.file system interface
10.file system interface10.file system interface
10.file system interface
 
9.Virtual Memory
9.Virtual Memory9.Virtual Memory
9.Virtual Memory
 
5.CPU Scheduling
5.CPU Scheduling5.CPU Scheduling
5.CPU Scheduling
 

Recently uploaded

CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 

Recently uploaded (20)

CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 

STOCK APPLICATION USING CORBA

  • 1. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ EX NO :6 DATE : 27-8-2014 STOCK APPLICATION USING CORBA NAME : M.F.JERINCE RAJA ROLLNO : 12LMC004 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ STOCK.IDL ********* module stck_market { interface stock { const unsigned short SIZE = 20; typedef string name[SIZE]; typedef short id[6]; typedef short amount[10]; typedef long shares[SIZE]; typedef string addr[SIZE]; long buyshare(in long amt,in long share); long sellshare(in long amt,in long share); }; }; STOCKIMPL ********** import stck_market.*; import org.omg.CORBA.*; class stckimpl extends stockPOA { private ORB orb; public stckimpl(ORB orb) { this.orb = orb; } public int buyshare(int amt,int share) { return(amt*share); } public int sellshare(int amt,int share) { return(amt*share); } } SERVER ****** import stck_market.*; import org.omg.CORBA.*; import org.omg.CosNaming.*; import org.omg.PortableServer.*; import org.omg.PortableServer.POA; import org.omg.CosNaming.NamingContextPackage.*; public class server { public static void main(String args[])
  • 2. { try { ORB orb = ORB.init(args, null); stckimpl imp_obj = new stckimpl(orb); POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootpoa.the_POAManager().activate(); org.omg.CORBA.Object ref = rootpoa.servant_to_reference(imp_obj); stock href = stockHelper.narrow(ref); org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); String name = "stock"; NameComponent path[] = ncRef.to_name( name ); ncRef.rebind(path, href); System.out.println(" Server ready... "); orb.run(); } catch (Exception e) { System.err.println("ERROR: " + e); e.printStackTrace(System.out); } System.out.println("Server Exiting ...."); } } CLIENT ******* import stck_market.*; import org.omg.CORBA.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import java.io.*; public class client { public static void main(String args[]) { try { int cmid = 0, csid = 0, repeat = 1,n; int comp_id[] = new int[6]; String comp_name[] = new String[stck_market.stock.SIZE]; int shr[] = new int[stck_market.stock.SIZE]; int shr_pri[] = new int[stck_market.stock.SIZE]; String comp_addr[] = new String[stck_market.stock.SIZE]; int amt[] = new int[stck_market.stock.SIZE];
  • 3. int cust_id[] = new int[6]; String cust_name[] = new String[stck_market.stock.SIZE]; int cust_shr[] = new int[stck_market.stock.SIZE]; String cust_addr[] = new String[stck_market.stock.SIZE]; int cust_amt[] = new int[stck_market.stock.SIZE]; int ctshr_pri[] = new int[stck_market.stock.SIZE]; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ORB orb = ORB.init(args, null); org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); String name = "stock"; stock obj = stockHelper.narrow(ncRef.resolve_str(name)); System.out.println("Handle obtained on server object: "+obj); System.out.println(" CORBA APPLICATION FOR STOCK MARKET "); System.out.println(" ~~~~~ ~~~~~~~~~~~ ~~~ ~~~~~ ~~~~~~ "); System.out.println(" Enter the number of company & customer to be registered : "); n = Integer.parseInt(br.readLine()); for(int i=0;i<n;i++) { System.out.println("tt Company Registration "); System.out.println(" Enter the company ID : "); comp_id[i] = Integer.parseInt(br.readLine()); System.out.println(" Enter the company name : "); comp_name[i] = br.readLine(); System.out.println(" Enter the company address : "); comp_addr[i] = br.readLine(); System.out.println(" Enter the company shares : "); shr[i] = Integer.parseInt(br.readLine()); System.out.println(" Enter the unit prize of shares : "); shr_pri[i] = Integer.parseInt(br.readLine()); System.out.println(" Enter the total amount of shares owned : "); amt[i] = Integer.parseInt(br.readLine()); System.out.println("tt Customer Registration "); System.out.println(" Enter the customer ID : "); cust_id[i] = Integer.parseInt(br.readLine()); System.out.println(" Enter the customer name : "); cust_name[i] = br.readLine(); System.out.println(" Enter the customer address : "); cust_addr[i] = br.readLine(); System.out.println(" Enter the number of shares owned : "); cust_shr[i] = Integer.parseInt(br.readLine()); System.out.println(" Enter the unit prize of shares : "); ctshr_pri[i] = Integer.parseInt(br.readLine()); System.out.println(" Enter the total amount of shares owned : "); cust_amt[i] = Integer.parseInt(br.readLine()); } do { System.out.println(" 1 - > BUY SHARES 2 - > SELL SHARES 3 - > LIST THE DETAILS "); System.out.println(" Enter the choice : "); int ch = Integer.parseInt(br.readLine()); switch(ch) { case 1: System.out.println("t BUY SHARES "); System.out.println(" Enter the company ID : "); cmid = Integer.parseInt(br.readLine());
  • 4. System.out.println(" Enter the customer ID : "); csid = Integer.parseInt(br.readLine()); for(int i=0;i<n;i++) { if(cmid==comp_id[i] && csid==cust_id[i]) { System.out.println(" Enter the number of shares to buy : "); int share = Integer.parseInt(br.readLine()); int unit_price = shr_pri[i]; int cur_amt = obj.buyshare(unit_price,share); System.out.println(" Shares bought : "+share); System.out.println(" Total amount : "+cur_amt); shr[i] = shr[i] - share; amt[i] = amt[i] - cur_amt; cust_shr[i] = cust_shr[i] + share; cust_amt[i] = cust_amt[i] + cur_amt; break; }} break; case 2: System.out.println("t SELL SHARES "); System.out.println(" Enter the company ID : "); cmid = Integer.parseInt(br.readLine()); System.out.println(" Enter the customer ID : "); csid = Integer.parseInt(br.readLine()); for(int i=0;i<n;i++) { if(cmid==comp_id[i] && csid==cust_id[i]) { System.out.println(" Enter the number of shares to sell : "); int share = Integer.parseInt(br.readLine()); int unit_price = ctshr_pri[i]; int cur_amt = obj.sellshare(unit_price,share); System.out.println(" Shares sold : "+share); System.out.println(" Total amount : "+cur_amt); shr[i] = shr[i] + share; amt[i] = amt[i] + cur_amt; cust_shr[i] = cust_shr[i] - share; cust_amt[i] = cust_amt[i] - cur_amt; break; } } break; case 3: for(int i=0;i<n;i++) { System.out.println("ttt Company Details "); System.out.println("t Company ID : "+comp_id[i]); System.out.println("t Company name : "+comp_name[i]); System.out.println("t Company Shares : "+shr[i]); System.out.println("t Total Amount of Shares Owned : "+amt[i]); System.out.println("ttt Customer Details "); System.out.println("t Customer ID : "+cust_id[i]); System.out.println("t Customer Name : "+cust_name[i]); System.out.println("t Total Number of Shares Owned : "+cust_shr[i]); System.out.println("t Total Amount of Shares Owned : "+cust_amt[i]);
  • 5. } break; } System.out.println(" Press 1 to continue... "); repeat = Integer.parseInt(br.readLine()); }while(repeat==1); } catch (Exception e1) { System.out.println("ERROR : " + e1) ; e1.printStackTrace(System.out); } } } OUTPUT ****** Z:st>idlj -fall stock.idl Z:st>javac *.java Note: .stck_marketstockPOA.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Z:st>javac *.java stck_market/*.java Note: stck_marketstockPOA.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Z:st>orbd -ORBInitialPort 2500 Z:st>java server -ORBInitialPort 2500 Server ready... CORBA APPLICATION FOR STOCK MARKET ~~~~~ ~~~~~~~~~~~ ~~~ ~~~~~ ~~~~~~ Enter the number of company & customer to be registered : 1 Company Registration Enter the company ID : 1234 Enter the company name : cicso Enter the company address : northstreet Enter the company shares : 100 Enter the unit priCe of shares : 50 Enter the total amount of shares owned : 80 Customer Registration Enter the customer ID : 101 Enter the customer name : RAJA Enter the customer address : M.G,.R nagar Enter the number of shares owned : 40 Enter the unit prize of shares :
  • 6. 40 Enter the total amount of shares owned : 10 1 - > BUY SHARES 2 - > SELL SHARES 3 - > LIST THE DETAILS Enter the choice : 1 BUY SHARES Enter the company ID : 1234 Enter the customer ID : 101 Enter the number of shares to buy : 15 Shares bought : 15 Total amount : 750 Press 1 to continue...
  • 7. 40 Enter the total amount of shares owned : 10 1 - > BUY SHARES 2 - > SELL SHARES 3 - > LIST THE DETAILS Enter the choice : 1 BUY SHARES Enter the company ID : 1234 Enter the customer ID : 101 Enter the number of shares to buy : 15 Shares bought : 15 Total amount : 750 Press 1 to continue...