190 likes | 205 Views
Explore Enterprise JavaBeans as a vital component technology for scalable business logic development, deployment, and management within Java applications. Learn about entity and session beans, container providers, server functionalities, and deployment criteria.
E N D
Enterprise JavaBeans IST 411 Lecture 9 Spring 2004
Enterprise JavaBeans • JavaBeans – refers to a technology used to develop reusable components in Java • Sun Microsystems released an API to enable developers to produce components which could be added to an integrated development environment • Treated like normal Java widgets • They are not Enterprise JavaBeans
Enterprise JavaBeans • Enterprise JavaBeans – • One part of package of middleware software developed by Java • Known as Java 2 Enterprise Edition • Other components include: • RMI • JDBC • Servlets • JavaMail • JMS (Java Messaging System) • Java Transaction Service
Enterprise JavaBeans • Is a component technology • Large-scale components holding business logic are developed, known as business components • Need heavy transactional service to support them provided by a TP monitor, the application server • Components and software glue that connect them are deployed across one or more application servers
Enterprise JavaBeans • Allow developers to reap the benefits of rapid application development by assembling predefined software components to create powerful applications and applets.
Enterprise JavaBeans • Six parts / roles to the development process: • Bean Developer – company has expertise in a domain such as ticket reservation or airline staff scheduling. Company would produce Enterprise JavaBeans that implement application-specific logic (Java classes) • Container Provider – company that supplies low-level software which implements a run-time environment in which Enterprise JavaBeans can execute
Enterprise JavaBeans • Server Provider – company that sells an Enterprise JavaBeans-compliant server which provides transactional services. The container provider and server provider are the same company. • Application Server includes and EJB container, servlet container, provides services such as JNDI (Java Naming and Directory Interface) directories, database connection pooling, integration with distributed systems and resource management • Application Assembler – company that joins Enterprise JavaBeans together.
Enterprise JavaBeans • Deployer – given the code for the beans and glue, will deploy the code across a number of servers. Criteria for determining deployment includes performance, security, and reliability. • System Administrator – individual or collection of individuals who are responsible for ensuring the maintenance of the bean. They are responsible for tuning the bean for performance if requirements change.
From: XML and Java Developing Web Applications, 2nd Edition, H. Maruyama, et. al., Addison Wesley, 2002, pg. 402.
Enterprise JavaBeans • Server that supports EJBs should provide the following functions: • Distributed Transaction Management – administer transactions and ensure that phantom updates and inconsistent retrievals do not occur. • Security – prevent unauthorized access the Enterprise JavaBeans.
Enterprise JavaBeans • Resource Management – provide resource management such as oversight of creation and deletion of threads and file connections. • Persistence - Enterprise JavaBeans sometimes need permanent storage medium. Server should manage this process ensuring that all changes to transient data intended for permanent storage are carried out.
Enterprise JavaBeans • Multiclient Support – manage process of clients connecting to Enterprise JavaBeans and mediate their interaction with the beans. • Location Transparency – server should operate so that clients have no knowledge of physical location of Enterprise JavaBeans.
Enterprise JavaBeans • Two types of Enterprise JavaBeans: • Entity beans – represents stored entity used in an application which requires permanent storage • Examples include bank accounts, flight plans, stock portfolios, insurance policies, and hotel bookings • Normally mapped into a relational database • Map long-lived data
Enterprise JavaBeans • Session beans – performs some business logic; they do not model a stored entity like a bank account • Session bean might: process a debit on a bank account; process an order for e-commerce product; make a stock or share trade. • Only lasts for period when client interacts with the bean • Used by one client at a time
Enterprise JavaBeans • Two types of session beans: • Stateful – maintains a state across a number of method calls such as a bean used to maintain a shopping cart for an e-retailer. • Stateless – processes and then finishes.
Bean Classes • Remote Interface – interface which specifies the methods associated with a bean. • Extends the class javax.ejb.EJBObject • Throws a RemoteException • Home Interface – defines the methods for a bean’s lifecycle. It specifies methods for creating a bean, destroying a bean and locating a bean in a distributed system.
Bean Classes • Bean Class – implements the methods for the bean • Does not implement the remote interface, but must contain methods actually match methods defined in that interface • Must have some methods corresponding to methods which are in the home interface • This class and the remote interface are connected together via the server which contains the bean
Bean Classes • Primary Key Class – provides a key into the database that is used for the beans.