Download J2EE

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
J2EE
Chris Hundersmarck
Maria Baron
Jeff Webb




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).
J2EE 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
Containers



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.
Containers

For example

EJB container:


manages the execution of enterprise
beans.
Web container

manages the execution of JSP pages and
servlet components.
Containers
Client Tier
1.
Web clients
1.
2.
2.
HTML, XML, etc..
Applets
Application clients
1.
2.
GUI
Command line
Web Tier
1.
2.
Servlets
JSP Pages
Web Components
JavaServer Faces



Lets you create user interfaces from
a set of standard, reusable serverside components
Provides a set of JSP tags to access
those components
Transparently saves state
information and repopulates forms
when they redisplay
JavaServer 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
JSF 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
Each 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
Components

All JSF components perform three
fundamental tasks



Render the component, typically by
generating markup
Handle the component's events
Validate the component's values
Benefits



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).
JSP And Java
JSF 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
Business Tier
1.
Enterprise Java Beans
1.
2.
3.
Session Beans
Entity Beans
Message-Driven Bean
Java Beans vs. Enterprise
Beans
1.
2.
Java Beans are not considered J2EE
components by the J2EE specification
Java Beans:
1.
2.
3.
Can exist on Server tier or Client tier.
Manage communication between all three
tiers.
Enterprise Beans:
1.
Only exist on Business Tier as part of the
Server Tier
Business Components
Enterprise 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.
Session Beans
1.
2.
3.
4.
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.
Session Beans

Two types of Session beans:


Stateless
Stateful
Entity Beans
1.
2.
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.
Entity Beans

What makes Entity Beans different
from Session Beans?




Persistence
Shared Access
Primary Key
Relationships
Message-Driven Bean
1.
2.
Combines features of a session
bean and a Java Message Service
(JMS) message listener
Allows a business component to
receive JMS messages
asynchronously.
Message-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.
Component 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
Deployment

Deployment tool provides ability to
configure and deploy a complex
enterprise application onto the :


Sun Java System Application Server
or onto other application servers
What 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.
What Is XML ?
<message>
<to>[email protected]</to>
<from>[email protected]</from>
<subject>XML Is Really Cool</subject>
<text>How many ways is XML cool? Let me
count the ways... </text>
</message>
Java 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.
Java 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
Java 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
JAX-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
SOAP

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.
SOAP


SOAP messages are complex
The JAX-RPC API hides this
complexity from the application
developer.
Web 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
Web 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.
Web 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 JAXRPC uses World Wide Web
Consortium (W3C) technologies:
HTTP, SOAP, WSDL
WSDL: Web Service Description
Language. WSDL specifies an XML
format for describing a service.
Web Service using JAX-RPC
Web Client
Web Service
Web 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
Hello Web Service
package helloservice;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface HelloIF extends Remote {
public String sayHello(String s) throws
RemoteException;
}
Hello Web Service
package helloservice;
import java.io.*;
public class HelloImpl implements HelloIF {
public String message = "Hello ";
public String sayHello(String s) {
return message + s;
}
}
package staticstub;
import javax.xml.rpc.Stub;
public class HelloClient {
private String endpointAddress;
public static void main(String[] args) {
System.out.println("Endpoint address = " + args[0]);
Stub stub = createProxy();
stub._setProperty(javax.xml.rpc.Stub._
ENDPOINT_ADDRESS_PROPERTY, args[0]);
}
}
HelloIF hello = (HelloIF) stub;
System.out.println(hello.sayHello("Duke!"));
private static Stub createProxy() {
return (Stub) (new MyHelloService_Impl().getHelloIFPort());
}
package staticstub;
import javax.xml.rpc.Stub;
public class HelloClient {
private String endpointAddress;
public static void main(String[] args) {
System.out.println("Endpoint address = " + args[0]);
Stub stub = createProxy();
stub._setProperty(javax.xml.rpc.Stub._
ENDPOINT_ADDRESS_PROPERTY, args[0]);
}
}
HelloIF hello = (HelloIF) stub;
System.out.println(hello.sayHello("Duke!"));
private static Stub createProxy() {
return (Stub) (new MyHelloService_Impl().getHelloIFPort());
}