Title: J2EE
1J2EE
- Chris Hundersmarck
- Maria Baron
- Jeff Webb
2- Java 2 Platform, Micro Edition (J2ME)
- Java 2 Platform, Standard Edition (J2SE)
- Java 2 Platform, Enterprise Edition (J2EE)
- (J2ME) is a subset of (J2SE) and (J2EE) is a
superset of (J2SE).
3J2EE is
- A distributed multi-tiered application model for
enterprise applications. - Divided into components according to function.
- Components installed on different machines
- Client, Server, Database Server Machines
4(No Transcript)
5Containers
- Provide access to the underlying services of the
J2EE Server environment. - Different types of containers for different types
of components - The interface between a component and the
low-level functionality that supports a component.
6Containers
- For example
- EJB container
- manages the execution of enterprise beans.
- Web container
- manages the execution of JSP pages and servlet
components.
7Containers
8Client Tier
- Web clients
- HTML, XML, etc..
- Applets
- Application clients
- GUI
- Command line
9(No Transcript)
10Web Tier
- Servlets
- JSP Pages
11Web Components
12JavaServer Faces
- Lets you create user interfaces from a set of
standard, reusable server-side components - Provides a set of JSP tags to access those
components - Transparently saves state information and
repopulates forms when they redisplay
13JavaServer Faces
- Provides a framework for implementing custom
components - Encapsulates event handling and component
rendering so you can use standard JSF components
or custom components to support markup languages
other than HTML - Lets tool vendors develop IDEs for a standard Web
application framework
14JSF Components
- Each component represents one or more Web page
elements - Simple components individual components such as
a text box - Compound components comprised of multiple
elements such as a table
15Each JSF component has
- A list of child components
- A hashmap of attributes
- One or more validators
- One or more event handlers
- An identifier for an optional renderer
16Components
- All JSF components perform three fundamental
tasks - Render the component, typically by generating
markup - Handle the component's events
- Validate the component's values
17Benefits
- Foster the creation of development tools that
allow user interface designers to drag and drop
components into a layout. - Developer(s) can write event-handling code that
will allow the view components to interact with
the application model. - Faster GUI creation for prototyping and rapid
application development (RAD).
18JSP And Java
19JSF AND JSP
- JSF is not bound to JSP - strict decoupling of
components from their view rendering - Rendering is done by using a rendering kit
- JSP is a required rendering kit but developers
can also use custom rendering kits to render views
20Business Tier
- Enterprise Java Beans
- Session Beans
- Entity Beans
- Message-Driven Bean
21Java Beans vs. Enterprise Beans
- Java Beans are not considered J2EE components by
the J2EE specification - Java Beans
- Can exist on Server tier or Client tier.
- Manage communication between all three tiers.
- Enterprise Beans
- Only exist on Business Tier as part of the Server
Tier
22Business Components
23Enterprise Java Beans
- Server-side component
- Encapsulates business logic
- Simplifies development
- EJB container provides system-level services
- Separates business logic from client.
- EJB are portable components.
24Session Beans
- Represents a single client.
- Client invokes the session bean's methods.
- Performs work for the client.
- when the client finishes executing, the session
bean and its data are gone.
25Session Beans
- Two types of Session beans
- Stateless
- Stateful
26Entity Beans
- Represents persistent data stored in one row of a
database table. - If the client terminates or if the server shuts
down, the underlying services ensure that the
entity bean data is saved.
27Entity Beans
- What makes Entity Beans different from Session
Beans? - Persistence
- Shared Access
- Primary Key
- Relationships
28Message-Driven Bean
- Combines features of a session bean and a Java
Message Service (JMS) message listener - Allows a business component to receive JMS
messages asynchronously.
29Message-Driven Bean
- 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.
30Component Packaging
- .jar - Java archive classes and web content for
a J2EE application - .war - web application archive
- .ear enterprise archive
- contains the whole application along with
deployment descriptor that provides information
about the application and its assembled
components
31(No Transcript)
32Deployment
- Deployment tool provides ability to configure and
deploy a complex enterprise application onto the
- Sun Java System Application Server
- or onto other application servers
33What Is XML ?
- Text-based markup language
- As with HTML, you identify data using tags.
Collectively, the tags are known as markup. - Unlike HTML, XML tags identify the data rather
than specify how to display it.
34What Is XML ?
- ltmessagegt  Â
- lttogtyou_at_yourAddress.comlt/togt ltfromgtme_at_myAddress.c
omlt/fromgt ltsubjectgtXML Is Really Coollt/subjectgt - lttextgtHow many ways is XML cool? Let me count
the ways... lt/textgt - lt/messagegt
35Java API for XML Processing
- (JAXP) is for processing XML data using
applications written in the Java programming
language. - Leverages the parser standards
- Simple API for XML Parsing (SAX)
- parse your data as a stream of events
- OR
- Document Object Model (DOM)
- build an object representation of it.
36Java API for XML Processing
- Simple API for XML Parsing (SAX)
- It is read forward only
- SAX simply sends data to the application as it is
read - Requires much less memory than DOM, because SAX
does not construct an internal representation
(tree structure) of the XML data - Fast and efficient
37Java API for XML Processing
- Document Object Model (DOM)
- When you need to modify an XML structure
interactively - in-memory structure (Object model)
- provides many powerful capabilities for
large-scale documents - requires more complex coding
38JAX-RPC
- Java API for XML-based RPC
- Technology for building web services and clients
that use remote procedure calls (RPC) and XML - Remote procedure call is represented by an
XML-based protocol such as SOAP
39(No Transcript)
40SOAP
- SOAP specification defines the
- envelope structure
- encoding rules
- Conventions
- for representing remote procedure calls and
responses in XML. - These calls and responses are transmitted as SOAP
messages (XML files) over HTTP.
41SOAP
- SOAP messages are complex
- The JAX-RPC API hides this complexity from the
application developer.
42Web Service using JAX-RPC
- On the server side, the developer specifies the
remote procedures by defining methods in an
interface (written in the Java programming
language) - The developer also codes one or more classes that
implement those methods
43Web Service using JAX-RPC
- A client creates a proxy (a local object
representing the service) and then simply invokes
methods on the proxy. - The developer does not generate or parse SOAP
messages - The JAX-RPC runtime system converts the API calls
and responses to and from SOAP messages.
44Web Service using JAX-RPC
- JAX-RPC client can access a web service that is
not running on the Java platform, and vice versa.
- Flexibility is possible because JAX-RPC uses
World Wide Web Consortium (W3C) technologies - HTTP, SOAP, WSDL
- WSDL Web Service Description Language. WSDL
specifies an XML format for describing a service.
45Web Service using JAX-RPC
Web Client
Web Service
46Web Service using JAX-RPC
- Service Code
- Extends the java.rmi.Remote interface
- Methods must throw the java.rmi.RemoteException
or one of its subclasses - Method parameters and return types must be
supported JAX-RPC types
47Hello Web Service
- package helloservice
- import java.rmi.Remote
- import java.rmi.RemoteException
- public interface HelloIF extends Remote
- public String sayHello(String s) throws
RemoteException -
48Hello Web Service
- package helloservice
- import java.io.
- public class HelloImpl implements HelloIF
- public String message "Hello "
- public String sayHello(String s)
- return message s
-
49package staticstub import javax.xml.rpc.Stub pu
blic class HelloClient private String
endpointAddress public static void
main(String args) System.out.println("
Endpoint address " args0) Stub stub
createProxy() stub._setProperty(javax.
xml.rpc.Stub._
ENDPOINT_ADDRESS_PROPERTY, args0)
HelloIF hello (HelloIF) stub
System.out.println(hello.sayHello("Duke!"))
private static Stub createProxy()
return (Stub) (new MyHelloService_Impl().getHelloI
FPort())
50- package staticstub
- import javax.xml.rpc.Stub
- public class HelloClient
- private String endpointAddress
- public static void main(String args)
- System.out.println("Endpoint address "
args0) - Stub stub createProxy()
- stub._setProperty(javax.xml.rpc.Stub._
- ENDPOINT_ADDRESS_PROPERTY,
args0) - HelloIF hello (HelloIF) stub
- System.out.println(hello.sayHello("Duke!"))
-
- private static Stub createProxy()
- return (Stub) (new MyHelloService_Impl().ge
tHelloIFPort())