Professional Documents
Culture Documents
NITESH AMBASTHA
( nitesh@psyon.org )
ACM Seminar Enterprise JavaBeans ™
COVERAGE
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
EJB : Th e Jargon
Defined
What is a Bean ?
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
JavaBeans Vs EJBs :
JavaBeans are developed to act and run a certain way.
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
Sun’s Definition :
EJB architecture is a component architecture for
the development and deployment of component-
based distributed business applications.
Evolution of EJB :
T P Monitors
ORBs
•Transaction mgmt
•Mission-criticality • Object – based
•High volume of data • Plug-and-play nature
•Implicit support for • High level abstraction
services rid
b
hy
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
Advantages of EJB
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
You can take any Java class and with little effort
make it a distributed, secure, transactional class
You can take any data source and make the data
source appear to be a collection of Java objects
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
EJB™ Serv er :
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
EJB™ Co ntainer
:
Hosts the Enterprise JavaBeans
Provides services to Enterprise JavaBeans
Naming
Life cycle management
Persistence (state management)
Transaction Management
Security
Interface between Enterprise Bean and outside world
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
JNDI Architecture :
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
Elements :
• Remote Interface
Session
• Home Interface Bean
• Bean Class
• Deployment Entity
Descriptor Bean
• EJB Container
• EJB Server
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
Entity Beans :
Persistent data components, survive failures
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
EJB CONTAINER
ENTITY BEAN
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
Session Beans :
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
A. True
B. False
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
A Simple Application :
Things we need :
i. A Remote Interface
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
Remote Interface :
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface Converter extends EJBObject {
public double dollarToYen(double dollars) throws
RemoteException;
public double yenToEuro(double yen) throws
RemoteException;
}
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
Interface
jav ax.e jb.EJBH ome :
Home objects must implement this interface
Interface
jav ax.e jb.EJBH ome :
Home objects must implement this interface
Home Interface :
import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface ConverterHome extends EJBHome {
Converter create() throws RemoteException,
CreateException;
}
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
Client Class :
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.servlet.*;
import javax.servlet.http.*;
import Converter;
import ConverterHome;
public class ConverterServlet extends HttpServlet {
Converter converter;
public void init() throws ServletException {
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
System.out.println("create ok");
} catch(Exception e) {
e.printStackTrace();
}
}
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String inputString = req.getParameter("inputString");
Integer inputNumber = new Integer(inputString);
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
out.println("</head>");
out.println("<body>");
out.println("$"+inputNumber.intValue()+" = "+String.valueOf(amount)+"
yens.");
out.println(inputNumber.intValue()+" Yens =
"+String.valueOf(amount2)+" euro.");
out.println("<p>");
out.println("<form method = get action=\"ConverterAlias\">");
out.println("Please enter an integral amount :");
out.println("<input type=text name=\"inputString\">");
out.println("<p>");
out.println("<input type=submit></form></body></html>");
}
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
8th December 2000 ©2000 National Centre for Software Technology, Mumbai
ACM Seminar Enterprise JavaBeans ™
References :
www.java.sun.com/products/j2ee
www.ejbportal.com/
THANK S
8th December 2000 ! ©2000 National Centre for Software Technology, Mumbai