220 likes | 350 Views
AN INTRODUCTION TO ENTERPRISE APPLICATION DEVELOPMENT USING EJBs by SHREERAM IYER 08/29/2001. Why is Enterprise Application Development different and complex?. Done using components and component technology When a component fails, ensure faults are isolated and that it does not corrupt others
E N D
AN INTRODUCTION TO ENTERPRISE APPLICATION DEVELOPMENT USING EJBsbySHREERAM IYER08/29/2001
Why is Enterprise Application Development different and complex? • Done using components and component technology • When a component fails, ensure faults are isolated and that it does not corrupt others • In a distributed application, components can reside anywhere on the network • Enterprises are essentially heterogeneous environments with presence of multiple Operating Systems
What is EJB? • EJB (Enterprise Java Beans) • EJB is a server component model for Java • Specification for creating server side, scalable, transactional, multi-user and secure enterprise-level applications • Provides a consistent component architecture for creating distributed n-tier middleware
Why EJBs?… • Frees application developer to concentrate on programming only the business logic • Removes the need to write all the “plumbing” code required in any enterprise application development scenario • Clients become thin as they have to worry only about presentation logic • EJBs containing the business logic are platform independent • Support for readymade components • WORA for Server side components
Why EJBs? • EJB establishes roles for Application development • EJB takes care of Transaction Management • Helps create portable and scalable solutions • Provides for vendor-specific enhancements
JavaBeans and EJBs… DeMystified • In a nutshell, JavaBeans are Java classes with accessor methods • Much smaller than EJBs • Do not need a runtime environment like an Application Server • A JavaBean can be a visual component • JavaBeans are like ActiveX components
EJB Architecture… EJB Architecture
EJB Architecture Basic EJB Architecture consists of • An EJB Server • EJB Containers that run within the Server • Home Objects, Remote EJBObjects and Enterprise Beans that run within Containers • EJB Clients • Auxiliary systems JNDI, JTS and security services • The idea of the EJB architecture is the Server and the Container are responsible for providing the hard stuff (transactions, persistence, pooling, multiple instances, security, etc.)
EJB Servers • Analogous to the CORBA ORB • Provides Systems services like • Raw execution environment • Multiprocessing • Load balancing • Naming • Transaction Services
EJB Containers • Interface between EJB and outside world • Client never accesses a bean directly • Session containers – contain transient, non-persistent EJBs whose states are not saved • Entity containers – contains persistent EJBs whose states are saved between invocations
Home Interface and Home Object • Factory methods for locating, creating and removing instances of EJB classes • Home Object is the implementation of the Home Interface • EJB Developer defines the Home Interface for his Bean • The EJB Container Vendor provide tools that automatically generate the implementation code for the Home Interface as defined by the EJB Developer
Remote Interface and EJBObject • The Remote Interface lists the business methods available for the EJB • The EJBObject is the Client’s view of the EJB and implements the Remote Interface • The EJB Developer defines the RI • The Container Vendor provides tools to generate implementation code for EJBObject • The Client invokes the EJBObject’s methods • The EJB Container first handles the request before delegating it to the EJB…provides features of EJB like transaction, pooling, security, etc.
Naming Services and JNDI • A Naming Service is a dedicated piece of software that manages a naming system or namespace • JNDI is a client API that provides naming and directory functionality • Specified in JAVA • Designed to provide a common interface for accessing existing services like DNS, NDS, LDAP, CORBA or RMI • Provides an interface that hides the implementation details of different naming and directory services behind the JNDI API
Types of EJBs • EJBs can be transient or persistent • Two types of Enterprise Beans • Entity Beans: Generally used to model a business entity • Session Beans: General purpose server side beans
Entity Beans • Represent data in a domain model • Persistent Entity Bean • Container managed persistence • Bean managed persistence • Entity beans can share access from multiple users • Can survive EJB server crashes
Session Beans • Created by a client and in most cases, exists only for the duration of a single session • Stateless Session beans • Stateful Session beans • Execute on behalf of a single client • Relatively short-lived • May be destroyed when EJB Server crashes • Do not represent data stored in DataBase
Modeling using Session and Entity Beans… • Use Session beans for application logic • Use Session beans as the only interface to the client • Expect little reuse of Session beans • Use Session beans to control the workflow of a group of entity beans eg. Credit Card Validation
Modeling using Session and Entity Beans • Use Entity beans to develop a persistent object model • Use Entity beans to enforce accuracy / integrity of your database • Insist on reuse of Entity beans • Use Entity beans to model domain objects with a unique identity shared by multiple clients eg. Employees
Drawbacks of EJBs • Developer needs to know JAVA • EJBs are not allowed to access native libraries written in C/C++ • EJBs cannot be used to develop any kind of GUI • Learning curve and understanding of different technologies involved
Useful links • http://www.ejbportal.com/ • http://www.c2.com/cgi/wiki?EjbRoadmap • http://www.mgm-edv.de/ejbsig/ejbsig.html • http://www.jdance.com/ejb.shtm • http://www.sys-con.com/java/index2.html • http://www.nordija.com/beanbuilder/ • http://www.ejbnow.com/ • http://www.theserverside.com • http://www.beasys.com/support/newsgroup.html • http://www.ejbean.com