You are on page 1of 49

SUDHARSAN ENGINEERING COLLEGE

SATHIYAMANGALAM 622 501


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
LAB MANUAL
NAME :G.DINESH KUMAR
DESIGNATION :ASST. PROFESSOR / CSE
SUBJECT CODE :IT1404
SUBJECT NAME :MIDDLEWARE TECHNOLOGY LAB
YEAR/SEM : IV/07

LIST OF EXPERIMENTS
1. Create a distributed application to download various files from various servers using
RMI.
2. Create a java bean to draw various graphical shapes and display it using or without using
BDK.
3. Develop an Enterprise Java Bean for banking operations.
4. Develop an Enterprise Java Bean for Library operations.
5. Create an Active- X control for file operations.
6. Develop a component for converting the currency values using COM/. NET
7. Develop a component for encryption and decryption using COM/. NET
8. Develop a component for retrieving information from message box using DCOM/.NET
9. Develop a middleware component for retrieving Stock Market Exchange information
using CORBA
10. Develop a middleware component for retrieving Weather Forecast information using
CORBA.
2
Ex.No: 1
DOWNLOAD FILES FROM VARIOUS SERVERS USING RMI
AIM: To Create a program to download files from various servers using RMI
DESCRIPTION:
1. Define the interface.
2. Interface must extend Remote
3. All methods must throw an exception RemoteException individually
4. Implement the interface.
5. Create a server program.
6. Create a Client Program.
7. Generate stubs and skeletons using rmic tool.
8. Start the server.
9. Start the client.
10. Once the process is over stop the client and server respectively.
PROGRAM:
Part 1 : Interface Defintion:
import java.rmi.*;
public interface fileinterface extends Remote
{
public byte[] downloadfile(String s) throws RemoteException;
}
Part 2. Interface Implementation:
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
public class fileimplement extends UnicastRemoteObject implements fileinterface
{
private String name;
public fileimplement(String s)throws RemoteException {
super();
name=s;
} public byte[] downloadfile(String fn)
{
try{
File fi=new File(fn);
byte buf[]=new byte[(int)fi.length()];
BufferedInputStream bis=new BufferedInputStream(new FileInputStream(fn));
3
bis.read(buf,0,buf.length);
bis.close();
return(buf); }
catch(Exception ee) {
System.out.println("Error:"+ee.getMessage());
ee.printStackTrace();
return(null);}}}
Part 3 : Server Part:
import java.rmi.*;
import java.io.*;
import java.net.*;
public class fileserver
{
public static void main(String args[])
{
try{
fileimplement fi=new fileimplement("fileserver");
Naming.rebind("//127.0.0.1/fileserver",fi);}
catch(Exception e){
System.out.println(" "+e.getMessage());
e.printStackTrace();
}}
}
Part 4: Client Part:
import java.net.*;
import java.rmi.*;
import java.io.*;
public class fileclient
{
public static void main(String[] args)
{
try{
InetAddress addr=InetAddress.getLocalHost();
String address=addr.toString().substring(addr.toString().indexOf("/")+1);
String url="rmi://"+ address + "/fileserver";
fileinterface f1=(fileinterface)Naming.lookup(url);
byte[] data=f1.downloadfile(args[0]);
File ff=new File("f1.txt");

BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(ff.getName()));
bos.write(data,0,data.length);
bos.flush();
4
bos.close();}
catch(Exception e){
System.out.println(" "+e.getMessage());
e.printStackTrace();
}}}
Part 5 Compile all the files as follows
C:\sowmi\rmi>javac *.java
C:\sowmi\rmi>
Part 6 Generate stubs and skeletons as follows
C:\sowmi\rmi>rmic fileimplement
C:\sowmi\rmi>
Part 7 : Start rmiregistry as given below . If registry is properly started, a window will be
opened
C:\sowmi\rmi>start rmiregistry
C:\sowmi\rmi>
Part 8 : Start the server
C:\sowmi\rmi>java fileserve
r
Part 9: Start the client
C:\sowmi\rmi>java fileclient c:\devi\corba\StockMarketClient.java
C:\sowmi\rmi>type f1.txt
RESULT:
Thus the RMI Program was created and executed successfully.
5
Ex. No: 2
CREATE A JAVA BEAN TO DRAW VARIOUS GRAPHICAL SHAPES
USING BDK OR WITHOUT BDK
AIM:
To Create a Java Bean to draw various graphical shapes using BDK or without Using
BDK.
DESCRIPTION:
1. Start the Process.
2. Set the classpath for java as given below
C:\devi\bean>set path=%path%;c:\j2sdk1.4.1\bin;
3. Write the Source code as given below.
PROGRAM:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code="shapes" width=400 height=400></applet>*/
public class shapes extends Applet implements ActionListener
{
List list;
Label l1;
Font f;
public void init()
{
Panel p1=new Panel();
Color c1=new Color(255,100,230);
setForeground(c1);
f=new Font("Monospaced",Font.BOLD,20);
setFont(f);
l1=new Label("D R A W I N G V A R I O U S G R A P H I C A L S H A P E
S",Label.CENTER);
p1.add(l1);
add(p1,"NORTH");
Panel p2=new Panel();
list=new List(3,false);
list.add("Line");
6
list.add("Circle");
list.add("Ellipse");
list.add("Arc");
list.add("Polygon");
list.add("Rectangle");
list.add("Rounded Rectangle");
list.add("Filled Circle");
list.add("Filled Ellipse");
list.add("Filled Arc");
list.add("Filled Polygon");
list.add("Filled Rectangle");
list.add("Filled Rounded Rectangle");
p2.add(list);
add(p2,"CENTER");
list.addActionListener(this); }
public void actionPerformed(ActionEvent ae) {
repaint(); }
public void paint(Graphics g) {
int i;
Color c1=new Color(255,120,130);
Color c2=new Color(100,255,100);
Color c3=new Color(100,100,255);
Color c4=new Color(255,120,130);
Color c5=new Color(100,255,100);
Color c6=new Color(100,100,255);
if (list.getSelectedIndex()==0) {
g.setColor(c1);
g.drawLine(150,150,200,250); }
if (list.getSelectedIndex()==1) {
g.setColor(c2);
g.drawOval(150,150,190,190); }
if (list.getSelectedIndex()==2)
{ g.setColor(c3); g.drawOval(290,100,190,130); }
if (list.getSelectedIndex()==3) {
g.setColor(c4);
g.drawArc(100,140,170,170,0,120); }
if (list.getSelectedIndex()==4) {
g.setColor(c5);
int x[]={130,400,130,300,130};
int y[]={130,130,300,400,130};
g.drawPolygon(x,y,5); }
if (list.getSelectedIndex()==5) {
g.setColor(Color.cyan);
g.drawRect(100,100,160,150); }
if (list.getSelectedIndex()==6) {
g.setColor(Color.blue) g.drawRoundRect(190,110,160,150,85,85);
}
7
if (list.getSelectedIndex()==7)
{
g.setColor(c2);
g.fillOval(150,150,190,190);
}
if (list.getSelectedIndex()==8) {
g.setColor(c3);
g.fillOval(290,100,190,130); }
if (list.getSelectedIndex()==9) {
g.setColor(c4);
g.fillArc(100,140,170,170,0,120); }
if (list.getSelectedIndex()==10) {
g.setColor(c5);
int x[]={130,400,130,300,130};
int y[]={130,130,300,400,130};
g.fillPolygon(x,y,5); }
if (list.getSelectedIndex()==11)
{
g.setColor(Color.cyan);
g.fillRect(100,100,160,150);
}
if (list.getSelectedIndex()==12)
{
g.setColor(Color.blue);
g.fillRoundRect(190,110,160,150,85,85);
}}}

4. Save the above file as shapes. java
5. compile the file as
C:\devi\bean>javac shapes.java
C:\devi\bean>
6. If BDK is not used then execute the file as
C:\devi\bean>appletviewer shapes.java
7. Stop the process
RESULT:
Thus the java jean was created and executed successfully.
8
Ex. No:3 Date:
DEVELOP A COMPONENT USING EJB FOR BANKING OPERATIONS
AIM: To create a component for banking operations using EJB.
DESCRIPTION:
1. Start the process
2. Set path as C:\devi\atm>set path=%path%;c:\j2sdk1.4.1\bin;
3. Set class path as C:\devi\atm>set classpath=%classpath%;c:\j2sdkee1.2.1\lib\j2ee.jar;
SOURCE CODE:
4. Define the home interface
import javax.ejb.*;
import java.io.Serializable;
import java.rmi.*;
public interface atmhome extends EJBHome
{
public atmremote create(int accno,String name,String type,float balance)throws
RemoteException,CreateException;
}
Save the above interface as atmhome.java
5. Define the Remote Interface.
import java.io.Serializable;
import javax.ejb.*;
import java.rmi.*;
public interface atmremote extends EJBObject
{
public float deposit(float amt) throws RemoteException;
public float withdraw(float amt) throws RemoteException;
}
Save the remote interface as atmremote.java
6. Write the implementation.
import javax.ejb.*;
import java.rmi.*;
public class atm implements SessionBean
{
9
int acno;
String name1;
String tt;
float bal;
public void ejbCreate(int accno,String name,String type,float balance)
{
acno=accno;
name1=name;
tt=type;
bal=balance;}
public float deposit(float amt)
{
return(bal+amt);
}
public float withdraw(float amt)
{
return(bal-amt);
}
public atm()
{}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}

public void setSessionContext(SessionContext sc){}
}

Save the file as atm.java
7. Write the Client part.
import javax.rmi.*;
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import java.io.*;
import java.net.*;
import javax.naming.NamingException;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import java.util.Properties;
public class atmclient
{
public static void main(String args[]) throws Exception
{
10
float bal=0;
String tt=" ";

Properties props = new Properties();

props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialCo
ntextFactory");
props.setProperty(InitialContext.PROVIDER_URL, "t3://localhost:7001");
props.setProperty(InitialContext.SECURITY_PRINCIPAL,"");
props.setProperty(InitialContext.SECURITY_CREDENTIALS," ");
InitialContext initial = new InitialContext(props);
Object objref = initial.lookup("atm2");
atmhome home = (atmhome)PortableRemoteObject.narrow(objref,atmhome.class);
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int ch=1;
String name;
int acc;
System.out.println("Enter the Details");
System.out.println("Enter the Account Number:");
acc=Integer.parseInt(br.readLine());
System.out.println("Enter Ur Name:");
name=br.readLine();
while(ch<=4)
{
System.out.println("\t\tBANK OPERATIONS");
System.out.println("\t\t***************");
System.out.println("");
System.out.println("\t\t1.DEPOSIT");
System.out.println("\t\t2.WITHDRAW");
System.out.println("\t\t3.DISPLAY");
System.out.println("\t\t4.EXIT");
System.out.println("\t\tENTER UR OPTION:");
ch=Integer.parseInt(br.readLine());
switch(ch)
{
case 1:
System.out.println("Enter the Transaction type;");
tt=br.readLine();
atmremote bb= home.create(acc,name,tt,10000);
System.out.println("Entering");
System.out.println("Enter the transaction amt:");
float amt=Float.parseFloat(br.readLine());
bal=bb.deposit(amt);
System.out.println("Balance after deposit=" +bal);
break;
case 2:
11
System.out.println("Enter the Transaction type;");
tt=br.readLine();
bb= home.create(acc,name,tt,bal);
System.out.println("Entering");
System.out.println("Enter the transaction amt:");
amt=Float.parseFloat(br.readLine());
bal=bb.withdraw(amt);
System.out.println("Balance after withdraw" + bal);
break;
case 3:
System.out.println("Status of the Customer");
System.out.println("Account Number:"+acc);
System.out.println("Name of the Customer:"+name);
System.out.println("Transaction type:"+tt);
System.out.println("Balance"+bal);
break;
case 4:
System.exit(0); } //switch }//while }//main }//class
8. Compile all the files
C:\devi\atm\javac *.java
9. Select Start->Programs->BEA Wblogic Platform 8.1->Other Development Tools-
>Weblogic Builder.
10. Select File >Open->atm ->open
11. A window will be displayed indicating the JNDI name
12. File->Save
13. File->Archive->Save
14. After getting the successful message goto start programs->BEA weblogic platform 8.1->
user projects->my domain->start server.
15. If the server is in running mode without any exception goto internet explorer
16. Type http://localhost:7001/console
17. A window will be displayed which prompt you for the username and password as
follows.
WebLogic Server Administration Console
Sign in to work with the WebLogic Server domain mydomain
Username:
devi

12
Password:
********


Sign In

18. If the username and password is correct then the following page is displayed
Welcome to BEA WebLogic Server Home

Connected to : localhost :7001 You are logged in as : devi Logout
Information and Resources
Helpful Tools General Information
Convert weblogic.properties Read the documentation
Deploy a new Application... Common Administration Task Descriptions
Recent Task Status Set your console preferences

Domain Configurations
Network Configuration Your Deployed Resources
Your Application's Security
Settings
Domain Applications Realms
Servers EJB Modules
Clusters Web Application Modules
Machines Connector Modules
Startup & Shutdown

Services Configurations
JDBC SNMP Other Services
Connection Pools Agent XML Registries
MultiPools Proxies JTA Configuration
Data Sources Monitors Virtual Hosts
Data Source Factories Log Filters Domain-wide Logging
Attribute Changes Mail
JMS Trap Destinations FileT3
Connection Factories
Templates Connectivity Messaging Bridge
Destination Keys WebLogic Tuxedo Connector Bridges
Stores Tuxedo via JOLT JMS Bridge Destinations
Servers Tuxedo via WLEC General Bridge Destinations
Distributed Destinations
Foreign JMS Servers


Copyright (c) 2003 BEA Systems, Inc. All rights reserved.
13
19. In the above page select the link EJB Modules which leads to the next page as pictured
below.
Configuration Monitoring
An EJB module represents one or more
Enterprise JavaBeans (EJBs) contained in an
EJB JAR (Java Archive) file or exploded JAR
directory. An EJB module can be deployed
on one or more target servers or clusters.
Configuring and deploying an EJB module in
a WebLogic Server domain enables WebLogic
Server to serve the modules of the EJB to
clients.
This EJBs Modules page lists key information
about the EJB modules that have been
configured for deployment in this WebLogic
Server domain.
Deploy a new EJB Module...
Customize this view...
Name URI Deployment Order
sum sum.jar 100
_appsdir_atm_jar atm.jar 100
_appsdir_bank_jar bank.jar 100
_appsdir_hello_jar hello.jar 100
_appsdir_ss_jar ss.jar 100
20. To check for the successfulness click the required jar file.[Note:- here the file is atm.jar]
21. If the process is successful then the following message will be displayed
This page allows you to test remote EJBs to see whether they can be found via their JNDI names.
14
Session
Atm2 Test this EJB
22. Select the link Test this EJB. The following message will be displayed if successful
23. The EJB atm2 has been tested successfully with a JNDI name of atm2
Continue
24. Before running the client set the path as follows
C:\devi\atm>set path=%path%c:\j2sdk1.4.1\bin;
C:\devi\atm>set classpath=%classpath%;c:\j2sdkee1.2.1\lib\j2ee.jar;
C:\devi\atm>set classpath=weblogic.jar;%classpath%;
25. Start the client
C:\devi\atm>java atmclient


RESULT:
Thus the component was created successfully using EJB.

EX. No:4
DEVELOP A COMPONENT USING EJB FOR LIBRARY OPERATIONS
15
AIM: - To Create a component for Library Operations using EJB.
DESCRIPTION:
1. Start the Process.
2. Set the path as follows:
i. C:\devi>set path=%path%;c:\j2sdk1.4.1\bin;
ii. C:\devi>set classpath=%classpath%;c:\j2sdkee1.2.1\lib\j2ee.jar;
3. Define the Home Interface
import javax.ejb.*;
import java.io.Serializable;
import java.rmi.*;
public interface libraryhome extends EJBHome
{
public libraryremote create(int id,String title,String author,int nc)throws
RemoteException,CreateException;
} Save the above file as libraryhome.java
4. Define the Remote Interface
import java.io.Serializable;
import javax.ejb.*;
import java.rmi.*;
public interface libraryremote extends EJBObject
{ public boolean issue(int id,String title,String author,int nc) throws RemoteException;
public boolean receive(int id,String title,String author,int nc) throws RemoteException;
public int ncpy() throws RemoteException;}
Save the above file as libraryremote.java
5. Implement the EJB
import javax.ejb.*;
import java.rmi.*;
public class library implements SessionBean
{
int bkid;
String tit;
String auth;
int nc1;
boolean status=false;
public void ejbCreate(int id,String title,String author,int nc)
{
bkid=id;
tit=title;
16
auth=author;
nc1=nc; }
public int ncpy() {
return nc1; }
public boolean issue(int id,String tit,String auth,int nc) {
if(bkid==id) {
nc1--;
status=true; }
else {
status=false; }
return(status); }
public boolean receive(int id,String tit,String auth,int nc) {

if(bkid==id) {
nc1++;
status=true; }
else {
status=false; }
return(status); }
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}
public void setSessionContext(SessionContext sc){}
}
Save the above file as library.java
6. Write the Client Part
import javax.rmi.*;
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.*;
import java.util.*;
import java.io.*;
import java.net.*;
import javax.naming.*;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import java.util.Properties;
public class libraryclient {
public static void main(String args[]) throws Exception {

Properties props = new Properties();



17













Props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialCo
ntextFactory");
props.setProperty(InitialContext.PROVIDER_URL, "t3://localhost:7001");
props.setProperty(InitialContext.SECURITY_PRINCIPAL,"");
props.setProperty(InitialContext.SECURITY_CREDENTIALS,"");
InitialContext initial = new InitialContext(props);
Object objref = initial.lookup("library2");
libraryhome home= libraryhome)PortableRemoteObject.narrow(objref,libraryhome.class);
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int ch;
String tit,auth;
int id,nc;
boolean st;
System.out.println("Enter the Details");
System.out.println("Enter the Account Number:");
id=Integer.parseInt(br.readLine());
System.out.println("Enter The Book Title:");
tit=br.readLine();
System.out.println("Enter the Author:");
auth=br.readLine();
System.out.println("Enter the no.of copies");
nc=Integer.parseInt(br.readLine());
int temp=nc;
do {
System.out.println("\t\tLIBRARY OPERATIONS");
System.out.println("\t\t***************");
System.out.println("");
System.out.println("\t\t1.ISSUE");
System.out.println("\t\t2.RECEIVE");
System.out.println("\t\t3.EXIT");
System.out.println("\t\tENTER UR OPTION:");
ch=Integer.parseInt(br.readLine());
libraryremote bb= home.create(id,tit,auth,nc);
switch(ch) {
18
case 1:
System.out.println("Entering");
nc=bb.ncpy();
if(nc>0) {
if(bb.issue(id,tit,auth,nc)) {
System.out.println("BOOK ID IS:"+id);
System.out.println("BOOK TITLE IS:"+tit);
System.out.println("BOOK AUTHOR IS:"+auth);
System.out.println("NO. OF COPIES :"+bb.ncpy());
nc=bb.ncpy();
System.out.println("Sucess");
break; } }
else
System.out.println("Book is not available");
break;
case 2:
System.out.println("Entering");
if(temp>nc) {
System.out.println("temp"+temp);
if(bb.receive(id,tit,auth,nc))
{ System.out.println("BOOK ID IS:"+id);
System.out.println("BOOK TITLE IS:"+tit);
System.out.println("BOOK AUTHOR IS:"+auth);
System.out.println("NO. OF COPIES :"+bb.ncpy());
nc=bb.ncpy();
System.out.println("Sucess");
break; } }
else
System.out.println("Invalid Transaction");
break;
case 3:
System.exit(0);
} //switch }while(ch<=3 && ch>0);
}//main
}//class
Save the above file as libraryclient.java
7. Compile all the files
C:\devi>javac *.java
C:\devi>
8. Start->Programs->BEA Weblogic Platform 8.1->Other Development Tools->Weblogic
Builder
9. File ->Open->ss->Ok
10. File->save
11. File->Archive->Name the jarfile(library.jar)->Ok
12. Tools->Validate Descriptors->ejbc Successful
13. Copy the weblogic.jar(c:\bea\weblogic81\lib\weblogic.jar) to the folder where Your EJB
module is located (In the Program it is c:\ss)
19
14. Copy the Jar file created by you (here it is library. jar) to
c:\bea\userprojects\mydomain\applications.
15. Start the server(Start->programs->Bea web logic Platform8.1->User Projects->mydomain-
>Start Server
16. If the server is started successfully without any exception then go to the next step.
17. Open Internet Explorer->Type the URL (http://localhost:7001/console) in the address
box.(Type the user name and password)
18. If the username and password is correct a page will be displayed.
19. In that page click->EJB Modules
An EJB module represents one or more Enterprise
JavaBeans (EJBs) contained in an EJB JAR (Java
Archive) file or exploded JAR directory. An EJB
module can be deployed on one or more target
servers or clusters. Configuring and deploying an
EJB module in a WebLogic Server domain enables
WebLogic Server to serve the modules of the EJB
to clients.
This EJBs Modules page lists key information
about the EJB modules that have been configured
for deployment in this WebLogic Server domain.
Deploy a new EJB Module...
Customize this view...
Name URI Deployment Order
ss ss.jar 100
_appsdir_atm_jar atm.jar 100
_appsdir_hello_jar hello.jar 100
20. Click the link of the jar file that You have created (Here it is ss.jar)
21. Click the testing tab.
22. Click the link Test this EJB.The EJB library2 has been tested successfully with a JNDI
name of library2 Continue
23. In the client part set the path as
C:\devii>set classpath=weblogic.jar;%classpath%;
24. Run the client
25. Terminate the Client and server.
C:\devi>java libraryclient

20
RESULT:
Thus the program was created successfully.
Ex. No: 5
CREATE AN ACTIVEX CONTROL FOR FILE OPERATIONS
AIM:- To Create an Activex Control for File Operations
DESCRIPTION:
PART-I
1. Start the process.
2. Open Visual Studio.net
3. File->New->Project->VisualBasic Projects->Windows Control Library
4. Rename the Project as actfileoperation and click ok
5. drag and drop the following control
i. one Label box
ii. one Rich Text Box
iii. four Button
6. The following code must be included in their respective Button Click Event
Public Class FileControl
Inherits System.Windows.Forms.UserControl
Dim fname As String
//new
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
RichTextBox1.Text = ""
End Sub
//open
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim of As New OpenFileDialog
If of.ShowDialog = DialogResult.OK Then
fname = of.FileName
RichTextBox1.LoadFile(fname)
End If
End Sub
//save
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim sf As New SaveFileDialog
21
If sf.ShowDialog = DialogResult.OK Then
fname = sf.FileName
RichTextBox1.SaveFile(fname)
End If
End Sub
//font
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim fo As New FontDialog
If fo.ShowDialog = DialogResult.OK Then
RichTextBox1.Font = fo.Font
End If
End Sub
End Class
7. Build solution from the Built Menu
PART-II
1. Open Visual Studio.net
2. File->New->Project->VisualBasic Projects->Windows Application
3. Rename the Project as actref and click ok
4. Tools->Add/Remove Tool Box Item and select the tab .NET Framework Components.
5. Click the Browse Button and open the actfileoperation.dll from (locate the bin folder) and
click ok.
6. Now the user control (FileControl) will be added to Tool Box.
7. Drag and Drop the Control in the Form
8. Execute the project by hitting f5.
RESULT:
Thus the ActiveX control was created successfully.
22
.
Ex. No: 6
DEVELOP A COMPONENT FOR CURRENCY CONVERSION USING
COM/.NET
AIM: To Create an component for currency conversion using com/.net
DESCRIPTION:
PART 1
CREATE A COMPONENT

1. Start the process
2. open VS .NET
3. File-> New-> Project-> visual Basic Project -> class library, rename the class Library if
required
4. include the following coding in the class Library
Public Class Class1
Public Function dtor(ByVal rup As Double) As Double
Dim res As Double
res = rup * 47
Return (res)
End Function
Public Function etor(ByVal rup As Double) As Double
Dim res As Double
res = rup * 52
Return (res)
End Function
Public Function rtod(ByVal rup As Double) As Double
Dim res As Double
res = rup / 47
Return (res)
End Function
Public Function rtoe(ByVal rup As Double) As Double
Dim res As Double
res = rup / 52
23
Return (res)
End Function
End Class
5. Build->Build the solution
Note: Register the dll using regsvr32 tool or copy the dll to c:\windows\system32.
Part II
REFERENCING THE COMPONENT
1. Start the process
2. open VS .NET
3. File-> New-> Project-> visual Basic Project -> Windows Application, rename the
Windows Application if required
4. Project -> Add Reference choose the com tab->Browse the dollartorupees.dll and click
ok
5. drag and drop the following controls in the form
i. 2 Label Boxes
ii. 1 Text box
iii. 4 Buttons
6. Include the coding in each of the Respective Button click Event.
Imports conversion2
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim obj As New convclass
Dim ret As Double
ret = obj.dtor(CDbl(TextBox1.Text))
MsgBox("The Equivalent Rupees for the given dollar" +
ret.ToString())
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Dim obj As New convclass
Dim ret As Double
ret = obj.etor(CDbl(TextBox1.Text))
MsgBox("The Equivalent Rupees for the given euro" +
ret.ToString())
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button4.Click
Dim obj As New convclass
Dim ret As Double
ret = obj.rtod(CDbl(TextBox1.Text))
24
MsgBox("The Equivalent Dollar Amount for the given rupees" +
ret.ToString())
End Sub
Private Sub Button3_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button3.Click
Dim obj As New convclass
Dim ret As Double
ret = obj.rtoe(CDbl(TextBox1.Text))
MsgBox("The Equivalent Euro Amount for the given rupees"
+ ret.ToString())
End Sub
End Class
7. Execute the project.
RESULT:
Thus the above program was executed successfully.
25
Ex. No: 7 `
DEVELOP A COMPONENT FOR CRYPTOGRAPHY USING
COM/.NET
AIM: To Develop a component for cryptography using COM/.NET
DESCRIPTION:
PART 1
CREATE A COMPONENT

Start the process
open VS .NET
File-> New-> Project-> visual Basic Project -> class library, rename the class
Library if required
include the following coding in the class Library
Public Class Class1
Dim pa1 As String
Dim i As Integer
Dim ct As Long
Public Function enco(ByVal pa As String) As String
pa1 = pa
pa = ""
For i = 0 To pa1.Length - 1
ct = Convert.ToInt64(Convert.ToChar(pa1.Substring(i, 1)))
ct = ct + ct
pa = pa + Convert.ToChar(ct)
Next
Return (pa)
End Function
Public Function deco(ByVal pa As String) As String
pa1 = pa
26
pa = ""
For i = 0 To pa1.Length - 1
ct = Convert.ToInt64(Convert.ToChar(pa1.Substring(i, 1)))
ct = ct / 2
pa = pa + Convert.ToChar(ct)
Next
Return (pa)
End Function
End Class
iii. Build->Build the solution
Note: Register the dll using regsvr32 tool or copy the dll to c:\windows\system32.
Part II
REFERENCING THE COMPONENT
1. Start the process
2. open VS .NET
3.File-> New-> Project-> visual Basic Project -> Windows Application, rename the
Windows Application if required
4.Project -> Add Reference choose the com tab->Browse the encode.dll and click ok
5.Drag and Drop the following controls in the form
i. 2 Label Boxes
ii. 1 Text box
iii. 3 Buttons
6.Include the coding in each of the Respective Button click Event.
Imports encode
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
TextBox1.Text = ""
End Sub
Private Sub ENCRYPT_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ENCRYPT.Click
Dim obj As New encode.Class1
Dim temp As String
temp = TextBox1.Text
TextBox1.Text = obj.enco(temp)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
Dim obj As New encode.Class1
Dim temp1 As String
temp1 = TextBox1.Text
27
TextBox1.Text = obj.deco(temp1)
End Sub
End Class
8. Execute the project.
RESULT:
Thus the above program was executed suceessfully.
Ex. No: 8
DEVELOP A COMPOENNT TO RETRIEVE MESSAGE BOX
INFORMATION USING DCOM/.NET
AIM: To Create a component to retrieve message box information using DCOM/.NET
DESCRIPTION:
Part I
1. Start the process.
2. Open Visual Studio. NET.
3. Goto File->New->Project->ClassLibrary|Empty Library->OK
4. Goto Solution Explorer->Right Click->Add->Add Component|Add New Item->COM
Class-_OK
5. Add the following codings Save & Build.
Public Function test() As String
Dim str = "hai"
Return (str)
End Function
Public Function create() As String
MsgBox(test())
End Function
Part II
1. Go To Start->Microsoft Visual.Net 2003->Visual Stufio.Net tools->Command prompt
Setting environment for using Microsoft Visual Studio .NET 2003 tools.
(If you have another version of Visual Studio or Visual C++ installed and wish
to use its tools from the command line, run vcvars32.bat for that version.)
C:\Documents and Settings\mcaadministrator>sn -k ms.snk
Microsoft (R) .NET Framework Strong Name Utility Version 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
Key pair written to ms.snk
C:\Document and Settings\mcaadministrator>
28
Copy ms.snk to bin directory (locate the class library)
2. start -> settings -> control panel->administrative tools->component services-> computer-
>my computer->com + Application -> new -> application ->next -> create an empty
application-> choose the server Application -> enter the new Application name (mssg) ->
next ->choose the interactive user-> next->finish.
3. expand mssg -> click the components ->right click -> new-> component ->
next->install new event classes-> select the class library1.tlb(class library->bin->
open->next->finish.
PART III
1. Open Visual studio .net -> file-> new ->Project->Windows Application
2. Create one label box,one text box and one button in the form.
3. Include the following code in the Button click event
Imports msg
Public Class Form1
Inherits System.Windows.Forms.Form
Dim mo As New msg.ComClass1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
textbox1.text = mo.test()
End Sub
End Class
4.execute the project
RESULT:
Thus the component was created using DCOM.
29
Ex. No:9
DEVELOP A COMPONENT FOR RETRIEVING STOCK MARKET
EXCHANGE INFORMATION USING CORBA
AIM: To Create a Component for retrieving stock market exchange information using CORBA
DESCRIPTION:
Steps required:
1. Define the IDL interface
2. Implement the IDL interface using idlj compiler
3. Create a Client Program
4. Create a Server Program
5. Start orbd.
6. Start the Server.
7. Start the client
// Define IDL Interface
module simplestocks{
interface StockMarket
{
float get_price(in string symbol);
};
};
Note: Save the above module as simplestocks.idl
Compile the saved module using the idlj compiler as follows .
C:\devi\corba>idlj simplestocks.idl
After compilation a sub directory called simplestocks same as module name will be created and
it generates the following files as listed below.
C:\devi\corba>cd simplestocks
C:\devi\corba\simplestocks>dir
Volume in drive C has no label.
Volume Serial Number is 348A-27B7
Directory of C:\suji\corba\simplestocks
30
02/06/2007 11:38 AM <DIR> .
02/06/2007 11:38 AM <DIR> ..
02/06/2007 11:38 AM 2,071 StockMarketPOA.java
02/07/2007 02:15 PM 2,090 _StockMarketStub.java
02/07/2007 02:15 PM 865 StockMarketHolder.java
02/07/2007 02:15 PM 2,043 StockMarketHelper.java
02/07/2007 02:15 PM 359 StockMarket.java
02/07/2007 02:15 PM 339 StockMarketOperations.java
02/07/2007 02:08 PM 226 StockMarket.class
02/07/2007 02:08 PM 180 StockMarketOperations.class
02/07/2007 02:08 PM 2,818 StockMarketHelper.class
02/07/2007 02:08 PM 2,305 _StockMarketStub.class
02/06/2007 11:44 AM 2,223 StockMarketPOA.class
11 File(s) 15,519 bytes
2 Dir(s) 6,887,636,992 bytes free
C:\devi\corba\simplestocks>
// Implement the interface
import org.omg.CORBA.*;
import simplestocks.*;
public class StockMarketImpl extends StockMarketPOA{ private ORB orb;
public void setORB(ORB v){orb=v;}
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();}}
//Server Program
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA.*;
import java.util.Properties;
import simplestocks.*;
public class StockMarketServer{
public static void main(String[] args) {
try { ORB orb=ORB.init(args,null);
POA rootpoa=POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
StockMarketImpl ss=new StockMarketImpl();
ss.setORB(orb);
org.omg.CORBA.Object ref=rootpoa.servant_to_reference(ss);
31
StockMarket hrf=StockMarketHelper.narrow(ref);
org.omg.CORBA.Object orf=orb.resolve_initial_references("NameService");
NamingContextExt ncrf=NamingContextExtHelper.narrow(orf);
NameComponent path[]=ncrf.to_name("StockMarket");
ncrf.rebind(path,hrf);
System.out.println("StockMarket server is ready");
//Thread.currentThread().join();
orb.run();}catch(Exception e){
e.printStackTrace();}}}
// Client Program
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import simplestocks.*;
import org.omg.CosNaming.NamingContextPackage.*;
public class StockMarketClient{
public static void main(String[] args) {
try
{
ORB orb=ORB.init(args,null);

NamingContextExt
ncRef=NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"))
//NameComponent path[]={new NameComponent("NASDAQ","")};
StockMarket market=StockMarketHelper.narrow(ncRef.resolve_str("StockMarket"));
System.out.println("Price of My company is"+market.get_price("My_COMPANY"));}
catch(Exception e){
e.printStackTrace();}}}
Compile the above files as
C:\devi\corba>javac *.java
C:\devi\corba>start orbd -ORBInitialPort 1050 -ORBInitialHost localhost
C:\devi\corba>start java StockMarketServer -ORBInitialPort 1050 -ORBInitialHost
32
localhost
C:\devi\corba>
StockMarket server is ready
C:\devi\corba>java StockMarketClient -ORBInitialPort 1050 -ORBInitialHost localh
ost
RESULT:
Thus the above program was executed successfull
Ex: No: 10
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. Define the IDL interface
2. Implement the IDL interface using idlj compiler
3. Create a Client Program
4. Create a Server Program
5. Start orbd.
6. Start the Server.
7. Start the client
// Define IDL Interface
module weather{
interface forecast
{
float get_min();
float get_max();};};
Note: Save the above module as weather.idl
Compile the saved module using the idlj compiler as follows .
C:\sowmi\weather>idlj weather.idl
After compilation a sub directory called weather same as module name will be created and it
generates the following files as listed below.
C:\sowmi\weather>cd weather
C:\sowmi\weather\weather>dir
Volume in drive C has no label.
33
Volume Serial Number is 348A-27B7
Directory of C:\suji\weather\weather
03/14/2007 02:52 PM <DIR> .
03/14/2007 02:52 PM <DIR> ..
03/14/2007 02:55 PM 2,240 forecastPOA.java
03/14/2007 02:55 PM 2,729 _forecastStub.java
03/14/2007 02:55 PM 796 forecastHolder.java
03/14/2007 02:55 PM 1,926 forecastHelper.java
03/14/2007 02:55 PM 330 forecast.java
03/14/2007 02:55 PM 319 forecastOperations.java
03/15/2007 10:42 AM 2,144 forecastPOA.class
03/15/2007 10:42 AM 167 forecastOperations.class
03/15/2007 10:42 AM 207 forecast.class
03/15/2007 10:42 AM 2,724 forecastHelper.class
03/15/2007 10:42 AM 2,403 _forecastStub.class
11 File(s) 15,985 bytes
2 Dir(s) 1,726,103,552 bytes free
C:\sowmi\weather\weather>
// Implement the interface
import org.omg.CORBA.*;
import weather.*;
import java.util.*;
public class weatherimpl extends forecastPOA
{
private ORB orb;
int r[]=new int[10];
float s[]=new float[10];
Random rr=new Random();
public void setORB(ORB v){orb=v;}
public float get_min() {
for(int i=0;i<10;i++)
{
r[i]=Math.abs(rr.nextInt());
s[i]=Math.round((float)r[i]*0.00000001);
}
float min;
min=s[0];
for(int i=1;i<10;i++) {
if (min>s[i])
min =s[i]; }
float mintemp=Math.abs((float)(min-32)*5/9);

return mintemp;}
public float get_max()
{
for(int i=0;i<10;i++)
34
{
r[i]=Math.abs(rr.nextInt());
s[i]=Math.round((float)r[i]*0.00000001); }
float max;
max=s[0];
for(int i=1;i<10;i++)
{
if (max<s[i])
max =s[i]; }
float maxtemp=Math.abs((float)(max-32)*5/9);
return maxtemp;}
public weatherimpl(){super();}}
//Server Program
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA.*;
import java.util.Properties;
import weather.*;
public class weatherserver{
public static void main(String[] args) {
try {
ORB orb=ORB.init(args,null);
POA rootpoa=POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
weatherimpl ss=new weatherimpl();
ss.setORB(orb);
org.omg.CORBA.Object ref=rootpoa.servant_to_reference(ss);
forecast hrf=forecastHelper.narrow(ref);
org.omg.CORBA.Object orf=orb.resolve_initial_references("NameService");
NamingContextExt ncrf=NamingContextExtHelper.narrow(orf);
NameComponent path[]=ncrf.to_name("forecast");
ncrf.rebind(path,hrf);
System.out.println("weather server is ready");
orb.run();
}
catch(Exception e){
e.printStackTrace();}}}
// Client Program
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import weather.*;
import org.omg.CosNaming.NamingContextPackage.*;
import java.util.*;
35
public class weatherclient
{
public static void main(String[] args)
{
String city[]={"Chennai ","Trichy ","Madurai ","Coimbatore","Salem "};
Calendar cc=Calendar.getInstance();
try
{
ORB orb=ORB.init(args,null);

NamingContextExt
ncRef=NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
forecast fr=forecastHelper.narrow(ncRef.resolve_str("forecast"));
System.out.println("\t\t\tW E A T H E R F O R E C A S T");
System.out.println("\t\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println();
System.out.println("\tDATE TIME CITY HIGHEST LOWEST ");
System.out.println("\t TEMPERATURE TEMPERATURE");
for(int i=0;i<5;i++) { System.out.print("\t"+cc.get(Calendar.DATE)
+cc.get(Calendar.MONTH)+cc.get(Calendar.YEAR)+" "+cc.get(Calendar.HOUR)+" "+city[i]
+" "+" ");
System.out.print(Math.floor(fr.get_min())+"\t \t"+Math.ceil(fr.get_max()));
System.out.println(); }}
catch(Exception e){
e.printStackTrace();}}}
Compile the above files as
C:\sowmi\weather>javac *.java
C:\sowmi\weather>start orbd -ORBInitialPort 1050 -ORBInitialHost localhost
C:\sowmi\corba>start java weatherserver -ORBInitialPort 1050 -ORBInitialHost
localhost
C:\sowmi\weather>
weather server is ready
C:\sowmi\corba>java weatherclient -ORBInitialPort 1050 -ORBInitialHost localh
36
ost
C:\sowmi\weather>java weatherclient -ORBInitialPort 1050 -ORBInitialHost
localhost
RESULT:
Thus the above program was created successfully.
LIST OF MODEL QUESTIONS
1. Write a Program in java to download files from various servers using RMI.
2. Write a Program in java Bean to draw the following shapes.
i. Line
ii. Filled Arc
iii. Ellipse
iv. Circle
v. Polygon
3. Write a Program in java Bean to draw the following shapes.
i. Filled Circle
ii. Filled Ellipse
iii. Filled Polygon
iv. Arc
v. Rounded Rectangle
4. Develop an Enterprise Java Bean for banking applications.
5. Develop an Enterprise Java Bean for Library Operations.
6. Create an Active-X Control for file operations.
7. Develop a component for Currency Conversion using COM/. NET.
8. Develop a component for Encryption and Decryption using COM/. NET.
9. Develop a component for retrieving information from message using DCOM/ .NET
37
10. Develop a component for retrieving stock market exchange information using CORBA.
11. Develop a component for retrieving weather forecast information using CORBA.
12. Develop an Enterprise Java Bean for displaying Hello message from the server.
13. Develop a middleware component for displaying Hello message from the server using
CORBA.
14. Develop an Enterprise Java Bean for Student information system.
VIVA QUESTIONS
1. Define the term Middleware.
Middleware is a software component that mediates between an application
program and a network. It manages the interaction between disparate applications
across the heterogeneous computing platforms. The ORB software that manages
communication between objects is an example of a middleware program.
2. What are the types of middleware?
1. General Middleware
2. Service Specific Middleware
3. Enumerate the difference between general and service specific middleware.
General Middleware:
It is a substrate for most client/server applications.
It includes communication stacks, distributed directories, authentication
services, network time, RPC and queuing services.
Products like DCE, NetWare, LAN server and NetBIOS.
Service Specific Middleware:
It is needed to accomplish a particular client / server type of service.
It includes database specific middleware, OLTP specific middleware,
Groupware specific, object specific middleware.
4. State the roles of EJB in eco system.
The Enterprise Java Beans specification identifies the following roles that are
associated with a specific task in the development of distributed applications.
The Enterprise Bean Provider is typically an expert in the application
domain application Assembler is also a domain expert.
Deployer is specialized in the installation of applications.
EJB Server Provider is an expert in distributed systems, transactions, and
security. A Container is a runtime system for one or multiple enterprise beans. It
provides the glue between enterprise beans and the EJB server.
System Administrator is concerned with a deployed application.
5. When do you use EJB?
EJBs are a good fit if your application has any of these requirements:
38
Scalability: If you have a growing number of users, EJBs let you distribute your
applications components across multiple machines with location transparency to
clients.
Data integrity: EJBs give you easy to use distributed transactions.
Variety of clients: If your application will be accessed by a variety of clients,
EJBs can be used for storing the business model, and a variety of clients can be
used to access the same information.
6. List any four exception raised in EJB?
1. System Exception- java.rmi.Remote Exception.
2. Application Exception- java.lang. Exception.
3. EJB specific Exception
4. Create Exception
5. Finder Exception.
7. What do you meant by ACL?
A list of which entities are allowed to invoke which objects and methods.
8. What is use of EJBObject?
A proxy object on the server side that implements a bean remote interface. The
EJBObject receives calls from the skeleton and forwards them to the EJB bean
implementation.
9. Define EJB server.
An execution environment for EJB containers. The EJB server provides the
container with access to network services and any other services it needs to
perform its tasks. The EJB 1.0 specification does not define the interface between
the server and the container, but the basic relationship is that an EJB server
contains one or more EJB containers, and each container can contain one or more
beans.
10. Write short note on Entity Beans.
Can be used concurrently by several clients.
Are relatively long lived they are intended to exist beyond the lifetime of
any single client.
Will survive a server crash
Directly represent data in a database.
11. What is the purpose of Finder method?
For entity EJBs, a method used to look up existing Entity EJB objects. The
finsByPrimaryKey () method takes a primary key as its argument and returns
a single reference to an Entity EJB. Other finder methods can take arbitrary
arguments and return either a single reference or set of references. If a set of
references is returned, the finder method will return a set of primary keys in a data
structure that implements the java.util.Enumeration interface.
12. Define the term Handle.
A serializable reference to a bean. A handle can be stored to a file or other
persistence store and used later to re obtain a reference to a remote bean.
13. Define the term Servlet.
A Java replacement for CGI. Servlets are java classes that are invoked by a web
server in response to HTTP requests and generate HTML as their output.
14. Define Skeleton.
39
In CORBA, a server side proxy object that is responsible for retrieving arguments
from the network and passing them to the program.
15. List out the characteristics of stateful session bean.
A bean that preserves information about the state of its conversation with
the client. This conversation may consists of several calls that modify the
conversation state, followed by a final call that writes the result to a database.
16. List out the characteristics of stateless session bean.
A bean that does not save information about the state of its conversation with a
client.
17. Define stub.
A client-side proxy for a remote routine. The stub takes the arguments that are
passed to it by the client, passes them over the network to the server, retrieves any
return value, and passes the return value back to the client.
18. Give the software architecture of EJB.
1. A remote interface (a client interact with it)
2. A Home interface (used for creating objects and for declaring business methods)
3. A bean object (which performs business logic and EJB specific operations)
4. A deployment descriptor (XML descriptor or some container specific features)
5. A primary Key class (only for entity bean)
19. What is the need of Remote and Home interface? Why cant it be in one?
The Home interface is the way to communicate with the container that is
responsible of creating, locating and removing one or more beans.
The remote interface is your link to the bean that will allow you to
remotely access to all its methods and members.
As you can see there are two distinct elements (the Container and the
Beans.)
20. Define the term EJB.
Enterprise Java Beans. EJBs are written once, run any-where, middleware
components.
21. List out the EJBs Role.
1. EJB specifies an execution environment
2. EJB exists in the middle tier
3. EJB supports transaction processing
4. EJB can maintain state.
5. EJB is simple.
22. Give the Logical architecture of EJB.
1. The Client
2. The server
3. The database (or other persistent store).
23. List out the services of EJB container.
Support for transactions
Support for management of multiple instances
Support for persistence
Support for security.
24. List out the Possible modes of transaction management.
TX_NOT_SUPPORTED
40
TX_BEAN_MANAGED
TX_REQUIRED
TX_SUPPORTS
TX_REQUIRES_NEW
TX_MANDATORY
25. Differentiate between Session and Entity bean.
Session Bean:
Short-lived.
Accessed by single client
Shared by multiple clients
No primary key.
Entity Bean:
o Long-lived
o Accessed by multiple clients
o No sharing
o It must have a primary key
26. What are tasks of Client?
Finding the bean
Getting access to a bean
Calling the beans methods
Getting rid of the bean.
27. List out the information available in deployment descriptor.
1. The name of the EJB class
2. The name of the EJB home interface
3. The name of the EJB remote interface
4. ACLs of entities authorized to use each class or method
5. For Entity beans, a list of container-managed fields.
6. For session beans, a value denoting whether the bean is stateful or stateless.
28. List out the Roles in EJB.
1. Enterprise Bean Provider
2. Deployer
3. Application Assembler
4. EJB Server Provider
5. EJB Container Provider
6. System Administrator
29. What are the steps are needed to design a EJB?
1. Find the Beans home interface
2. Get access to the Bean
3. Call the beans method with a string as argument and save the return value.
4. Display the return value to the user.
30. What are the steps are needed to implement the EJB program?
1. Create the remote interface for the bean
2. Create the beans home interface
3. Create the beans implementation class
4. Compile the remote interface, home, implementation class
5. Create a session descriptor
6. Create a manifest
41
7. Create an ejb-jar file
8. Deploy the ejb-jar file
9. Write a client
10. Run the client
31. Define Manifest file.
A Manifest is a text document that contains information about the contents of a
jar- file. Actually, the jar utility will automatically create a manifest file even if
none exists.
32. When to use EJB beans?
1. Where you might currently use RPC mechanism such as RMI or CORBA.
2. Session Beans are intended to allow the application author to easily implement
portions of application code in middleware and to simplify access to this code.
33. List out the constraints in Session Beans.
1. EJB cannot start new threads or use thread synchronization primitives.
2. EJB, cannot directly access the underlying transaction manager.
3. EJBs are not allowed to change their java.security.Identity at runtime.
4. If the Session beans timeout value expires.
5. If the server crashes and is restarted.
6. If the server is shut down and restarted.
34. Differentiate between Stateless Session and Stateful session beans.
Stateless session bean:
1. It have no states
2. It have only one create () method and takes no arguments.
Stateful session bean:
1. It has states.
2. It has more than one create () and have different arguments.
35. List out the transitions of stateful session bean.
The bean can enter a transaction
It can be passivated
It can be removed.
36. Define CORBA.
CORBA is a Standard defined by the Object Management Group (OMG) that enables
software components written in multiple computer languages and running on multiple
computers to work together, i.e. it supports multiple platforms.
CORBA is a mechanism in software for normalizing the method-call semantics
between application objects that reside either in the same address space
(application) or remote address space (same host, or remote host on a network).
37. Differentiate Between RMI and CORBA.
RMI is completely Java based, where CORBA is language independent. There
are many adapters for CORBA, and programs can call processes written in
any language that has a CORBA interface. CORBA has many more features
documented in the specification than just process communication. RMI is easier
to implement if you already know Java - it looks just the same as calling a process
locally - but it's limited to only calling other Java applications.
38. List out the characteristics of CORBA.
1. CORBA IDL
2. Dynamic invocation
42
3. Portable object adapter
4. Interoperability
5. COM/ CORBA Bridging
6. Multiple Programming Mapping.
39. What is the advantage of using CORBA?
v Language Independence
v OS Independence
v Freedom from Technologies
v Strong data typing
v High tune ability
v Freedom from data transfer details
v Compression
40. What is the use of ORB ?
It provides a mechanism for communication between client request and server
response. It is responsible for finding object implementation, deliver, request of
object and retrieving and responding to caller.
41. Define DII.
DII stands for Dynamic Innovation Interface.
42. What is the use of ORB Interface?
It is use to converts object reference to string and string to object reference.
43. What is the use of IDL Compiler?
It is used to transformation between IDL definition and target programming
language.
44. What do you meant by GIOP?
The GIOP stands for General Inter-ORB Protocol. It is a high level standard
protocol for communication between ORBs.
45. What do you meant by IIOP?
IIOP stands for Internet Inter-ORB Protocol. It is standard protocol for
communication between ORBs on TCP/IP based networks.
46. Define Object Adapter.
The Object Adapter is used to register instances of the generated code classes.
Generated Code Classes are the result of compiling the user IDL code which translates
the high-level interface definition into an OS- and language-specific class base for use by
the user application.
47. List out the types of Adapter.
Basic Object Adapter
Portable Object Adapter
Library Object Adapter
Object Oriented Data base Adapter
48. List out the types of Activation Polices in BOA.
i. Shared Server
ii. Unshared server
iii. Server-per-method
iv. Persistent server
49. What do you meant by socket?
Socket is an object; it used to communicate between client and server.
43
50. What is the use of object handles?
Object handles are used to reference object instances in a programming language
context.
In C++ - The handles are called Object reference.
51. Define Naming service.
It is an application that runs as a background process on a remote server at well-
known end points. This service is responsible for maintaining a look up table for
all of the services running in the distributed computer.
52. Define Marshalling.
It refers to the process of translating input parameters to a format that can be
transmitted across a network.
53. Define unmarshalling.
It is the reverse of marshalling this process converts a data into output parameters.
54. What are the steps are needed to build CORBA Application?
1. Define the servers interfaces using IDL.
2. Choose the implementation approach for the servers interface.
3. Use the IDL compiler to generate client stubs and server skeletons for the server
interfaces.
4. Implement the server interfaces.
5. Compile the server application.
6. Run the server application
55. What is the use of Factory method?
A Factory is a special type of distributed object whose main purpose is to create
other distributed objects.
56. What is the advantage of using .NET?
1. It is a language and platform independent.
2. It support and maps to all languages.
3. The components are created very easily.
57. List out the characteristics of .NET.
. NET framework introduce and completely a new model for the programming
and deployment of application.
. NET can be expanded.
58. What are the components of .NET?
Lit Box
Label
Textbox
Button
Static
Edit
59. Define CLR.
i. CLR Common Language Runtime
ii. It is a multi language execution environment.
iii. It described as the execution engine of .NET.
iv. It manages the execution of programs.
60. List out the goals of CLR.
44
It supplies manage code with services such as cross language integration, code
access security, object lift time management, resource management, type safety,
pre-emptive threading, meta data services and debugging & profiling support.
61. Define MSIL.
Microsoft Intermediate Language.
It defines a set of portable instructions that are independent of any specific CPU.
It is the job of the CLR to translate this intermediate code into executable code
when the program is compiled.
62. What do you meant by Meta data?
Data about the data is called Meta data.
63. What do you meant by JIT compiler?
It stands Just In Time
JIT compiler converts MSIL into native code on a demand basis, as each part of
the program is needed.
64. Define COM.
Component Object Model (COM) is a binary-interface standard for software
componentry introduced by Microsoft in 1993. It is used to enable interprocess
communication and dynamic object creation in a large range of programming languages .The
term COM is often used in the software development industry as an umbrella term that
encompasses the OLE, OLE Automation , ActiveX, COM+and DCOM technologies.
65. Define Iunknown.
All COM components must (at the very least) implement the standard Iunknown
interface, and thus all COM interfaces are derived from IUnknown. The IUnknown
interface consists of three methods: AddRef() and Release(), which implement
reference counting and controls the lifetime of interfaces; and QueryInterface()
, which by specifying an IID allows a caller to retrieve references to the different
interfaces the component implements.
66. What are the types of Iunknown methods?
AddRef()- Increments the reference count for an interface on an object.
Query Interface ()- Retrieves pointer to the supported interfaces on an object.
Release()- Decrements the reference count for an interface on an object.
67. What is the use of AddRef method?
The purpose of AddRef() is to indicate to the COM object that an additional
reference to itself has been affected and hence it is necessary to remain alive as
long as this reference is still valid.
68. What is need of Query Interface method?
It is used to specifying an IID allows a caller to retrieve references to the different
interfaces the component implements
69. What is purpose of using Release ()?
The purpose of Release () is to indicate to the COM object that a client (or a part
of the client's code) has no further need for it and hence if this reference count has
dropped to zero, it may be time to destroy itself.
70. What is use of CreateInstance()?
CreateInstance() method to create an object which exposes an interface
identified by the IID_ISomeObject GUID.
71. What is the use of CoCreateInstance()?
45
The CoCreateInstance() API can be used by an application to directly create a
COM object without acquiring the object's class factory. CoCreateInstance() API itself
will invoke the CoGetClassObject() API to obtain the object's class factory and then use
the class factory's CreateInstance() method to create the COM object.
72. Write a short note on Class Factory.
A Class Factory is itself a COM object. It is an object that must expose the
IClassFactory or IClassFactory2 (the latter with licensing support) interface. The
responsibility of such an object is to create other objects.
73. Write short note on IDL Modules.
IDL modules create separate name spaces for IDL definitions. This prevents
potential name conflicts among identifiers used in different domains.
74. What are the types of RMI Applications?
1. Client
2. Server
75. What are the steps are needed to create Distributed application by using RMI?
1. Designing and implementing the components of your distributed application.
2. Compiling sources.
3. Making classes network accessible.
4. Starting the application.
76. List out the steps for designing and implementing remote interfaces.
1. Defining the remote interface.
2. Implementing the remote objects.
3. Implementing the clients.
77. What is the use of RMI registry?
RMI Registry is used finding references to other remote objects. It is a simple
remote object naming service that enables clients to obtain a reference to a remote
object by name.
78. Define Compute Engine.
The Computing Engine is a remote object on the server that takes tasks
from clients, runs the tasks, and returns any results.
79. What are the steps are needed to write a RMI Programming?
1. Designing a remote Interface.
2. Implementing a Remote Interface.
3. Declaring the Remote Interfaces Being Implemented.
4. Defining the Constructor for the Remote Object.
Providing Implementations for each remote method
46
SUDHARSAN ENGINEERING COLLEGE
SATHIYAMANGALAM
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
MIDDLEWARE TECHNOLOGY LABORATORY
LAB MANUAL
47
YEAR/SEM: IV/VII
ACADEMIC YEAR:2010-2011 ODD SEM
PREPARED BY: RAJU.C

CONTENTS
S.No
LIST OF EXPERIMENTS
P
g.
N
o
Date
of
Perf
orma
nce
Date
of
Sub
missi
on
Asse
ssme
nt
(Ma
x.10
mar
ks)
R
e
m
ar
ks
Sign. Of
the
Lab in
charge
1
DOWNLOADING VARIOUS FILES FROM
VARIOUS SERVERS USING RMI
2
DRAW THE VARIOUS GRAPHICAL SHAPES AND
DISPLAY IT USING OR WITHOUT USING BDK.
3
DEVELOP AN ENTERPRISE JAVA BEAN FOR
BANKING OPERATIONS.
4
DEVELOP AN ENTERPRISE JAVA BEAN FOR
LIBRARY OPERATIONS.
5
CREATE AN ACTIVE- X CONTROL FOR FILE
OPERATIONS
6
DEVELOP A COMPONENT FOR CONVERTING
THE CURRENCY VALUES USING COM/. NET
7
DEVELOP A COMPONENT FOR ENCRYPTION
AND DECRYPTION USING COM/. NET
8
DEVELOP A COMPONENT FOR RETRIEVING
INFORMATION FROM MESSAGE BOX USING
DCOM/. NET
9
DEVELOP A MIDDLEWARE COMPONENT FOR
RETRIEVING STOCK MARKET EXCHANGE
INFORMATION USING CORBA.
10
DEVELOP A MIDDLEWARE COMPONENT
FOR RETRIEVING WEATHER FORECAST
48
INFORMATION USING CORBA.
QUESTION BANK
TOTAL MARKS
AVERAGE MARKS (out of 10)
49