Exam Objective 8.4 Describe at a high level the fundamental benefits and drawbacks of using J2EE server-side technologies, and describe and compare the basic characteristics of the web-tier, business-tier, and EIS tier.
2. Understanding Java EE–Related
Tiers and Technologies
• Exam Objective 8.4 Describe at a high level the
fundamental benefits and drawbacks of using J2EE
server-side technologies, and describe and compare the
basic characteristics of the web-tier, business-tier, and
EIS tier.
2
5. • The main disadvantage to the Java EE architecture is its
complexity. To be able.
• to program with the Java EE APIs as a software maintainer
you must know the fundamentals of Java very well.
• To be able to effectively develop code in the Java EE
environment, you should understand the more advanced
object-oriented features of the language, including the various
design patterns
5
7. Understanding the Web Tier
• The web tier is the tier within an enterprise system that
contains the presentation layer. Servlets and JavaServer
Pages are part of the web tier.
• These are web application technologies used for creating
dynamic web content.
• JavaServer Pages deliver web pages from the web tier.
Servlets handle HTTP web requests from the web tier.
• There are many web containers that implement the JSP
and servlets specifications such as Apache Tomcat, Jetty,
and the Sun Java System Web Server.
7
8. • The JavaServer Faces (JSF) API and JavaServer Pages
Standard Tag Library (JSTL) provide additional web contents
solutions.
• JSF is a user-interface component framework that lets you
easily build components, add validators and converters to the
values of those components, and provides page navigation
and state management support.
• JSTL is a tag library that is built off of the JSP framework.
8
9. Understanding the Business Tier
• The business tier is the tier within an enterprise system
that contains the business logic.
• Enterprise JavaBeans is one of the major components of
the business tier.
9
10. Understanding the EIS Tier
• The Enterprise Information System (EIS) tier is the tier within
an enterprise system that contains the data layer.
• Common activities are persistence support through
database management systems.
• The EIS tier includes databases, relational databases,
legacy applications, enterprise resource planning systems,
CRM systems, and legacy data stores. The EIS tier is
typically on its own machine.
• For example, an enterprisescale Oracle database can reside
on its own server and is interfaced with remotely.
10
12. Understanding Server-Side Solutions
• Exam Objective 8.1 Describe at a high level the basic
characteristics of: EJB, servlets, JSP, JMS, JNDI, SMTP, JAXRPC, Web Services (including SOAP, UDDI, WSDL, and XML),
and JavaMail.
12
13. Java Web Services
• Java web services are XML-based messaging protocols
that enable business-tobusiness communications. XML
helps achieve the underlying goal of web services, which
is to send and receive messages in a standardized
format.
• Java web services were introduced in J2EE 1.4 as part of
the Java Web Services Development Pack (JWSDP).
13
14. •
•
•
•
•
•
•
•
•
•
JAX-WS Version 2.0 EA (Java API for XML Web Services)
Fast Infoset Version 1.0.1
Sun Java Streaming XML Parser Version 1.0 EA
XML Digital Signature Version 1.0.1
XML and Web Services Security Version 2.0 EA2
JAXB Version 2.0 EA (Java Architecture for XML Binding)
JAXP Version 1.3.1_01 (Java API for XML Processing)
JAXR Version 1.0.8_01 EA (Java API for XML Registries)
JAX-RPC Version 1.1.3_01 EA (Java API for XML-based RPC)
SAAJ Version 1.3 EA (SOAP with Attachments API for Java)
14
15. • For the SCJA exam, the only related web services
technologies you will need to know are XML, JAXRPC
(covered in the next section), and the three foundational
standards of web services (SOAP, UDDI, and WSDL).
15
16. XML
• The Extensible Markup Language (XML) is a general-purpose
specification used for creating markup languages with the
design purposes of transporting and storing data.
• Web-based solutions make common use of XML files such as
configuration, deployment descriptor, and tag libraries files.
Again, XML was designed to structure, store, and/or carry
data, not to display data.
16
17. Simple Object Access Protocol
• The Simple Object Access Protocol (SOAP) is a simple
XML-based communication protocol used for information
exchange within a decentralized and distributed
environment.
• SOAP is used in various situations such as messaging
and remote procedure calls.
17
18. • SOAP is made up of three main parts: the envelope, the
encoding rules, and the RPC.
• The envelope is the root XML element that contains the
message recipient,message content, and processing
information of the message.
• The encoding rules specify how the data-type instances
will be exchanged.
• The RPCs defines the convention for representing the
remote calls and responses procedure calls.
18
20. WSDL
• The Web Service Definition Language (WSDL) is an XML
standard for businesses and individuals to access
available services that each provide.
• The WSDL XML documents include a set of definitions.
These definitions describe network services as a set of
endpoints operating on messages containing either
document or procedureoriented information.
• These elements are described and bound to network
protocols and message formats to define an endpoint.
• More specifically, an endpoint is a WSDL port that
represents the contact point of the service.
• This endpoint consists of the protocol and location
information.
20
21. UDDI
• The Universal Description, Discovery, and Integration
(UDDI) specification is an XML-based registry that is used
by businesses to make their services and general
business descriptions available through the Internet.
• UDDI can communicate via CORBA, SOAP, or the Java
RMI protocols. UDDI makes use of WSDL in describing
interfaces to web services.
• As such, the UDDI specification includes a set of WSDL
definitions for modifying and searching its registry, and
the registry itself includes the web service’s metadata and
a pointer to the WSDL service description.
21
22. SMTP and the JavaMail API
• The Simple Mail Transfer Protocol (SMTP) and the
JavaMail API are often used together to provide e-mailing
solutions.
• use the JavaMail API to send the e-mail to the desired
recipient by connecting and sending the e-mail from an
SMTP server.
22
26. Understanding Dynamic Web Content
Solutions
• Exam Objective 8.2 Describe at a high level the basic
characteristics of servlet and JSP support for HTML thin-clients.
26
30. What is Servlet?
• Java™ objects which are based on servlet framework and
APIs and extend the functionality of a HTTP server.
• Mapped to URLs and managed by container with a simple
architecture
• Available and running on all major web servers and app
servers
• Platform and server independent
30
31. First Servlet Code
Public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response){
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<title>Hello World!</title>");
}
...
}
31
32. What is JSP Technology?
• Enables separation of business logic from
presentation
> Presentation is in the form of HTML or
XML/XSLT
> – Business logic is implemented as Java
Beans or custom tags
> – Better maintainability, reusability
• Extensible via custom tags
• Builds on Servlet technology
32
33. What is JSP page?
• A text-based document capable of returning dynamic
content to a client browser
• Contains both static and dynamic content
> Static content: HTML, XML
> Dynamic content: programming code, and
JavaBeans, custom tags
33
36. JSP Benefits
• Content and display logic are separated
• Simplify development with JSP, JavaBeans and custom
tags
• Supports software reuse through the use of components
• Recompile automatically when changes are made to the
source file
• Easier to author web pages
• Platform-independent
36
37. Should I Use Servlet or JSP?
• In practice, servlet and JSP are used together
> via MVC (Model, View, Controller) architecture
> Servlet handles Controller
> JSP handles View
37
38. What Is an Enterprise Bean?
• Written in the Java programming language, an enterprise
bean is a server-side component that encapsulates the
business logic of an application.
38
39. Benefits of Enterprise Beans
• the EJB container provides system-level services to enterprise
beans,the bean developer can concentrate on solving business
problems.
• The client developer does not have to code the routines that
implement business rules or access databases. As a result, the
clients are thinner, a benefit that is particularly important for
clients that run on small devices.
• enterprise beans are portable components, the application
assembler can build new applications from existing beans.
These applications can run on any compliant Java EE server
provided that they use the standard APIs.
39
40. When to Use Enterprise Beans
• To accommodate a growing number of users, you may need to
distribute an application’s components across multiple
machines.Not only can the enterprise beans of an application
run on different machines, but also their location will remain
transparent to the clients.
• Enterprise beans support transactions, the mechanisms that
manage the concurrent access of shared objects.
• The application will have a variety of clients. With only a few
lines of code, remote clients can easily locate enterprise
beans. These clients can be thin, various, and numerous.
40
41. Types of Enterprise Beans
• Session Performs a task for a client;
optionally may implement a web service.
• Message-Driven Acts as a listener for a
particular messaging type, such as the
Java Message Service API.
41
42. What Is a Session Bean?
• As its name suggests, a session bean is similar to an
interactive session.
• A session bean is not shared; it can have only one client,
in the same way that an interactive session can have only
one user.
• Like an interactive session, a session bean is not
persistent.
• When the client terminates, its session bean appears to
terminate and is no longer associated with the client.
42
43. State Management Modes
Stateful Session Beans :conversational state
• In a stateful session bean,the instance variables represent
the state of a unique client-bean session.
• The state is retained for the duration of the client-bean
session.
• If the client removes the bean or terminates, the session
ends and the state disappears.
43
44. Stateless Session Beans
• When a client invokes the methods of a stateless bean, the
bean’s instance variables may contain a state specific to that
client, but only for the duration of the invocation.
• Except during method invocation, all instances of a stateless
bean are equivalent, allowing the EJB container to assign an
instance to any client.
• Typically, an application requires fewer stateless session
beans than stateful session beans to support the same number
of clients.
44
45. When to Use Session Beans
In general, you should use a session bean if the following
circumstances hold:
• At any given time, only one client has access to the bean
instance.
• The state of the bean is not persistent, existing only for a
short period (perhaps a few hours).
• The bean implements a web service.
45
46. Stateful session beans are appropriate if any of the following conditions are
true:
• The bean’s state represents the interaction between the bean and a
specific client.
• The bean needs to hold information about the client across method
invocations.
• The bean mediates between the client and the other components of the
application,presenting a simplified view to the client.
• Behind the scenes, the bean manages the work flow of several enterprise
beans
To improve performance, you might choose a stateless session bean if it has
any of these traits:
• The bean’s state has no data for a specific client.
• In a single method invocation, the bean performs a generic task for all
clients. For example,you might use a stateless session bean to send an
email that confirms an online order.
46
47. What Is a Message-Driven Bean?
• A message-driven bean is an enterprise bean that allows
Java EE applications to process messages
asynchronously.
• The messages can be sent by any Java EE component
(an application client, another enterprise bean, or a web
component) or by a JMS application.
• Message-driven beans can process JMS messages or
other kinds of messages.
47
48. What Makes Message-Driven Beans
Different from Session Beans?
• The most visible difference between message-driven beans and session
beans is that clients do not access message-driven beans through
interface.
In several respects, a message-driven bean resembles a stateless session
bean.
• A message-driven bean’s instances retain no data or conversational
state for a specific client.
• All instances of a message-driven bean are equivalent, allowing the EJB
container to assign a message to any message-driven bean instance.
The container can pool these instances to allow streams of messages to
be processed concurrently.
• A single message-driven bean can process messages from multiple
clients.
48
49. Message driven beans have the following
characteristics:
They execute upon receipt of a single client
message.
• They are invoked asynchronously.
• They are relatively short-lived.
• They do not represent directly shared data in
the database, but they can access and update
this data.
• They can be transaction-aware.
• They are stateless.
49
50. Defining Client Access with Interfaces
• A client can access a session bean only through the
methods defined in the bean’s business interface(client’s
view of a bean). method implementations and deployment
settings are hidden from the client.
• Well-designed interfaces simplify the development and
maintenance of Java EE applications.
• Not only do clean interfaces shield the clients from any
complexities in the EJB tier, but they also allow the beans
to change internally without affecting the clients.
• The type of client access allowed by the enterprise beans:
remote, local, or web service?
50
51. Remote Clients
A remote client of an enterprise bean has the following
traits:
• It can run on a different machine and a different Java
virtual machine (JVM) than the enterprise bean it
accesses. (It is not required to run on a different JVM.)
• It can be a web component, an application client, or
another enterprise bean.
• To a remote client, the location of the enterprise bean is
transparent.
51
53. Local Clients
A local client has these characteristics:
• It must run in the same JVM as the enterprise bean it
accesses.
• It can be a web component or another enterprise bean.
• To the local client, the location of the enterprise bean it
accesses is not transparent
the business interface is by default a local interface.
• @Local
• public interface InterfaceName { ... }
53
54. Deciding on Remote or Local Access
• Tight or loose coupling of related beans: For example, if a
session bean that processes sales orders calls a session bean
that emails a confirmation message to the customer, these
beans are tightly coupled.
> Same logical unit local increase performance
• Type of client and Component distribution : the type of
access depends on how you want to distribute your
components, application clients, web components, other
enterprise beans.
• Performance: remote calls may be slower than local calls.
In the future you can distribute your components to accommodate
the growing demands on your applicationRemote
54