0% found this document useful (0 votes)
16 views

J2EE Lecture

j2ee lecture notes

Uploaded by

21ucs002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

J2EE Lecture

j2ee lecture notes

Uploaded by

21ucs002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

J2EE – JAVA 2 Enterprise Edition

And Enterprise java Beans(EJB)

Application servers
What is J2EE?
Main component types
Application Scenarios
J2EE APIs and Services
What is EJB?

1
1. Application Servers
In the beginning mainframe computers
was used. It was centralized and
non-distributed

mainframe
terminals

terminals

2
Application Servers
In the 90’s, systems should be
client-server

3
Application Servers
Today, enterprise applications use
the multi-tier model

4
Application Servers
“Multi-tier applications” have several
independent components
An application server provides the
infrastructure and services to run such
applications

5
Application Servers
Application server products can be
separated into 3 categories:
■ J2EE-based solutions
■ Non-J2EE solutions (PHP, ColdFusion,
Perl, etc.)
■ And the Microsoft solution (ASP/COM and
now .NET with ASP.NET, VB.NET, C#,
etc.)

6
J2EE Application Servers
Major J2EE products:
■ BEA WebLogic
■ IBM WebSphere
■ Sun iPlanet Application Server
■ HP/Bluestone Total-e-Server
■ Borland AppServer
■ Jboss (free open source)
■ Net Beans

7
Web Server and Application Server
App Server 1
Internet Browser

Web Server
(HTTP Server)

HTTP(S)
App Server 2

8
2. What is J2EE?
It is a public specification that
embodies several technologies

J2EE defines a model for developing


multi-tier, web based, enterprise
applications with distributed
components

9
J2EE Benefits
High availability
Scalability
Integration with existing systems
Freedom to choose vendors of
application servers, tools, components
Multi-platform

10
J2EE Benefits
Flexibility of scenarios and support to several
types of clients
Programming productivity:
■ Services allow developer to focus on business
■ Component development facilitates maintenance
and reuse
■ Enables deploy-time behaviors
■ Supports division of labor

11
Main technologies
JavaServer Pages (JSP)
Servlet
Enterprise JavaBeans (EJB)

-JSPs, servlets and EJBs are application


components

12
JSP
Used for web pages with dynamic content
Processes HTTP requests (non-blocking
call-and-return)
Accepts HTML tags, special JSP tags, and
scriptlets of Java code
Separates static content from presentation
logic
Can be created by web designer using
HTML tools

13
Servlet
Used for web pages with dynamic content
Servlet is similar to JSP
Processes HTTP requests (non-blocking
call-and-return)
Written in Java; uses print statements to
render HTML
Loaded into memory once and then called
many times
Provides APIs for session management

14
EJB
EJBs are distributed components used to
implement business logic (no UI)
Developer concentrates on business logic
Availability, scalability, security,
interoperability and integrability handled by
the J2EE server
Client of EJBs can be JSPs, servlets, other
EJBs and external aplications
Clients see interfaces

15
J2EE Multi-tier(Architecture)

Copyright 2002 © Paulo Merson 16


J2EE Application Scenarios
Multi-tier typical application

17
J2EE Application Scenarios
Stand-alone client

18
J2EE Application Scenarios
Web-centric application

19
J2EE Application Scenarios
Business-to-business

20
J2EE Services and APIs
Java Message Service (JMS) it is an API is a messaging
standard that allows application components based on the Java
Platform Enterprise Edition (Java2EE) to create, send, receive,
and read messages .
■ Implicit invocation
■ Communication is loosely coupled,
reliable and asynchronous
■ Supports 2 models:
point-to-point
publish/subscribe

21
JMS
Point-to-point
■ Destination is “queue”

22
JMS
Publish-subscribe
■ Destination is “topic”

23
J2EE Services and APIs
JNDI- Java Naming and Directory Interface is a Java API for a directory service that
allows Java software clients to discover and look up data and resources (in the
form of Java objects) via a name Naming and directory services

■ Applications use JNDI to locate objects, such as


environment entries, EJBs, datasources, message
queues
■ JNDI is implementation independent
■ Underlying implementation varies: LDAP, DNS,
DBMS, etc.

24
J2EE Services and APIs
Transaction service:
■ Controls transactions automatically
■ You can demarcate transactions explicitly
■ Or you can specify relationships between
methods that make up a single transaction

25
J2EE Services and APIs
Security
■ Java Authentication and Authorization Service
(JAAS) is the new (J2EE 1.3) standard for J2EE
security
■ Authentication via userid/password or digital
certificates
■ Role-based authorization limits access of users to
resources (URLs, EJB methods)
■ Embedded security realm

26
J2EE Services and APIs
J2EE Connector Architecture
■ Integration to non-J2EE systems, such as
mainframes and ERPs.
■ Standard API to access different EIS
■ Vendors implement EIS-specific resource
adapters
Support to Corba clients

27
J2EE Services and APIs
JDBC
JavaMail
Java API for XML Parsing (JAXP)
Web services APIs

28
3. EJB – outlook

29
Home Interface
Methods to create, remove or locate
EJB objects
The home interface implementation is
the home object (generated)
The home object is a factory

30
Remote Interface
Business methods available to clients
The remote interface implementation
is the EJB object (generated)
The EJB object acts as a proxy to the
EJB instance

31
EJB – The Big Picture

32
EJB at runtime

Client can be local or remote

33
EJB at runtime

34
Types of EJB

35
Session Bean
Stateful session bean:
■ Retains conversational state (data) on
behalf of an individual client
■ If state changed during this invocation,
the same state will be available upon the
following invocation
■ Example: shopping cart

36
Session Bean
Stateless session bean:
■ Contains no user-specific data
■ Business process that provides a generic
service
■ Container can pool stateless beans
■ Example: shopping catalog

37
Entity Bean
Represents business data stored in a
database persistent object
Underlying data is normally one row of a
table
A primary key uniquely identifies each bean
instance
Allows shared access from multiple clients
Can live past the duration of client’s session
Example: shopping order

38
Entity Bean
Bean-managed persistence (BMP): bean
developer writes JDBC code to access the
database; allows better control for the
developer
Container-managed persistence (CMP):
container generates all JDBC code to access
the database; developer has less code to
write, but also less control

39
Message-Driven Bean
Message consumer for a JMS queue or
topic
Benefits from EJB container services
that are not available to standard JMS
consumers
Has no home or remote interface
Example: order processing – stock
info

40
Servlet example
public class HelloWorldServlet extends HttpServlet {

public void service(HttpServletRequest req,


HttpServletResponse res) throws IOException {

res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<html><head><title>Hello
World Servlet</title></head>");
out.println("<body><h1>Hello
World!</h1></body></html>");
}

41

You might also like