Understanding J2EE Framework and Enterprise Java Beans (EJBs) in Web Based Commerce, Study notes of Computers and Information technologies

An overview of the j2ee framework, focusing on enterprise java beans (ejbs), their component types, and their containers. It also discusses how j2ee technologies map onto tools like jboss, apache tomcat, and ejb container. The roles of various j2ee platform services, including naming, deployment, transaction, and security services.

Typology: Study notes

2010/2011

Uploaded on 09/09/2011

asdlol2
asdlol2 🇬🇧

4.4

(8)

232 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Web Based Commerce 514H3
Dr Kingsley Sage
Room 2R308, Chichester II
© University of Sussex 2009
Lecture 5
Looking at the J2EE framework in more detail
Starting to understand Enterprise Java Beans
(EJBs)
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Understanding J2EE Framework and Enterprise Java Beans (EJBs) in Web Based Commerce and more Study notes Computers and Information technologies in PDF only on Docsity!

Web Based Commerce 514H

Dr Kingsley Sage Room 2R308, Chichester II [email protected] © University of Sussex 2009

Lecture 5

 Looking at the J2EE framework in more detail  Starting to understand Enterprise Java Beans (EJBs)

J2EE framework technologies

 The J2EE embodies technologies to support multi-tier enterprise applications. These fall into 3 categories:

  • component : modules that can be reused by multiple enterprise applications
  • service :
  • communication :

Components

 An application level software unit

  • JavaBeans
  • applets
  • application clients
  • Enterprise Java Beans (EJB)
  • web components  Components rely on the run time support of a system level entity called a container

How does this map onto our tool

set?

 JBoss  Apache Tomcat  EJB Container  J2EE  Application client container

Components

 JavaBeans  Applets – Java based client components that execute within the browser  Application clients – executes in its own client container. Can directly interact with the EJB tier – thus full access to J2EE platform services such as JNDI lookups, asynchronous messaging and the JDBC API  Web components - software entity that provides a response to a request. Typically generates the user interface for a web based application. J2EE specifies two types of web components – servlets and JSPs  EJBs …

Enterprise Java Beans components

 A server side technology for developing and deploying components containing the business logic of an enterprise application  EJB components are:

  • scalable
  • transactional
  • multi-user secure  Three types of bean:
  • Entity beans
  • Session beans
  • Message driven beans

Enterprise Java Beans components

 Session and entity beans have two types of interface: component and home  Home interface defines methods to

  • create
  • find
  • remove
  • access metadata  Component interface:
  • defines the bean’s business logic methods  Message driven beans do not have component and home interfaces

Session beans

 Created to provide some service on behalf of a client and usually exists only for the duration of a single single client-server session  Performs operations such as calculations or accessing a database  May be transactional  Can be stateless or maintain conversational state across methods and transactions  If they do maintain state, EJB container manages the state  Session bean object itself must manage its own persistent data // The remote interface import javax.ejb.Remote; @Remote public interface CalculatorRemote{ public int add(int x, iny y); public int subtract(int x, int y); } // Actual stateless session bean class import javax.ejb.*; @Stateless public class CalculatorBean implements CalculatorRemote { public int add(int x, iny y) { return x+y; } publc int subtract(int x, int y) { return x-y; } }

Message driven beans

 Enables asynchronous clients to access the business logic in the EJB tier  Activated by a message received from a JMS queue  A client does not directly access a message driven bean – instead a client asynchronously sends a message to a JMS queue  Because they have no need to expose their methods to clients, they do no implement component or home interfaces  Do not maintain state on behalf of a client

Platform roles

 The J2EE platform defines several roles in the application development and deployment lifecycle:

  • Application component provider
  • Application assembler
  • Deployer
  • System administrator
  • Tool provider  These roles are defined are defined to aid in identifying the various tasks performed by various parties

Platform services

 J2EE platform services simplify application programming and allow components and applications to be customised at deployment time to use resources available in the deployment environment:

  • naming
  • deployment
  • transaction
  • security services

Naming services

 Java Naming and Directory Interface (JNDI)  JNDI naming environment allows a components to be customised without the need to access or change the component’s source code (basically late name binding)  JNDI provides a naming environment and provides it to the component as a JNDI naming context  The javax.naming.InitialContext object provides a “look up” service for a component under the name java:comp/env  Useful for things like database names and paths, and passing Java variables into low level system services (e.g. DLLs)

Deployment services

 J2EE deployment services allow components and applications to be customised at the time they are packaged and deployed  J2EE applications are deployed as a set of nested units. Each unit contains a deployment descriptor – an XML file that declaratively describes how to assemble and deploy the unit into a specific environment  J2EE application consists of one or more J2EE modules and one one J2EE application deployment descriptor  J2EE application consists of .jar files plus Resource Archive Files ( .rar ) packaged into an Enterprise Archive File ( .ear )  J2EE module consists of .jar files and web modules packaged as Web Archive files ( .war )

Transaction services

 A system that supports transactions ensures that each unit completes without interference from other processes  If the unit can be entirely completed it is committed, otherwise the system unrolls whatever work the unit has performed  J2EE platform transactions are “flat” I.e. they cannot be nested

Service technologies

 Allow applications to access a wide range of services in a uniform manner

  • JDBC: database independent connectivity between J2EE and a wide range of tabular data sources such as MySQL, Access, Oracle
  • Java Transaction API (JTA)
  • Java Naming and Directory Interface (JNDI)
  • Java API for XML processing (JAXP): supports processing of XML documents using DOM, SAX and XSLT models
  • JAAS
  • Java Messaging Service (JMS): provides a way to send and receive message asynchronously
  • JavaMail API

Next time …

 Looking at Enterprise Java Beans in more detail with some code examples …