Department of Informatics
Plan
- 1. Application Servers
- 2. Servlets, JSP, JDBC
- 3. J2EE: Vue d’ensemble
- 4. Distributed Programming
- 5. Enterprise JavaBeans
- 6. Prise de recul critique
Plan 1. Application Servers 2. Servlets, JSP, JDBC 3. J2EE: Vue - - PowerPoint PPT Presentation
Plan 1. Application Servers 2. Servlets, JSP, JDBC 3. J2EE: Vue densemble 4. Distributed Programming 5. Enterprise JavaBeans 6. Prise de recul critique Department of Informatics 3. J2EE: Vue d'ensemble J2EE: Vue d'ensemble 1. Repositionnement
Department of Informatics
Department of Informatics
Department of Informatics
For consumer devices, small memory devices like
Contains the J2SDK (Software Development Kit)
Programming platform aimed at networked-
For multi-tier server-oriented enterprise
3.1 Repositionnement de la plateforme Java
Department of Informatics
3.2 Vue d'ensemble de J2EE
Department of Informatics
3.2 Vue d'ensemble de J2EE
Department of Informatics
2.
Enterprise JavaBeans 2.0: spécification complète des composants
3.
Servlets 2.3: Servlets
4.
JavaServer Pages 1.2
5.
JDBC 2.0: connectivité bases de données
6.
Java Naming and Directory Service (JNDI) 1.2: service de nommage
7.
JavaMail 1.2: courrier électronique
8.
Java Message Service (JMS) 1.0.2: service messagerie
9.
Java API for XML Processing (JAXP) 1.1
10.
Java Connector Architecture (JCA) 1.0: intégration à des SI existants
11.
Java Authentication and Authorization Service (JAAS) 1.0: authentification et autorisation
12.
Java Transaction API (JTA) 1.0.1: service de transactions
3.3 Service garantis par J2EE
Department of Informatics
An Enterprise JavaBeans (EJB) component or
There are three kind of enterprise beans:
3.3 Service garantis par J2EE
Department of Informatics
Java Servlet technology lets you define HTTP-
A servlet class extends the capabilities of servers
Although servlets can respond to any type of
3.3 Service garantis par J2EE
Department of Informatics
JavaServer Pages technology lets you put snippets
A JSP page is a text-based document that contains
3.3 Service garantis par J2EE
Department of Informatics
The JDBC API lets you invoke SQL
The JDBC API has two parts:
3.3 Service garantis par J2EE
Department of Informatics
provides applications with methods for performing standard directory operations, such as associating attributes with
JNDI, a J2EE application can store and retrieve any type of named Java object.
applications can use JNDI to access multiple naming and directory services, including existing naming and directory services such as LDAP, NDS, DNS, and NIS. This allows J2EE applications to coexist with legacy applications and systems.
3.3 Service garantis par J2EE
Department of Informatics
Annuaire hiérarchique distribué Accès unifié au DNS, LDAP, NIS, système de
Nécessaire pour trouver des objets à distance Accès au EJB home uniquement par JNDI Permet reconfiguration des EJB sans modification
3.3 Service garantis par J2EE
Department of Informatics
3.3 Service garantis par J2EE
Department of Informatics
J2EE applications can use the JavaMail API to send
The J2EE platform includes JavaMail with a service
3.3 Service garantis par J2EE
Department of Informatics
The JMS is a messaging standard that allows
3.3 Service garantis par J2EE
Department of Informatics
XML is a language for representing text-based data
The Java API for XML Processing ("JAXP") supports
3.3 Service garantis par J2EE
Department of Informatics
vendors and system integrators to create resource adapters that support access to enterprise information systems that can be plugged into any J2EE product.
application components to access and interact with the underlying resource manager.
manager, there is typically a different resource adapter for each type of database or enterprise information system.
3.3 Service garantis par J2EE
Department of Informatics
The Java Authentication and Authorization Service
JAAS is a Java programming language version of
3.3 Service garantis par J2EE
Department of Informatics
interface for demarcating transactions.
handle transaction commits and rollbacks. An auto commit means that any other applications viewing data will see the updated data after each database read or write operation.
access operations that depend on each other, you will want to use the JTA API to demarcate where the entire transaction, including both operations, begins, rolls back, and commits.
3.3 Service garantis par J2EE
Department of Informatics
3.5 Déploiement XML
Department of Informatics
Department of Informatics
Department of Informatics
4.1 General Concepts of RMI
Department of Informatics
Interface
Interface
4.1 General Concepts of RMI
Department of Informatics
+request() Proxy +request() «interface» Subject realSubject.request(); +request() RealSubject
Client
Subject RealSubject
+myOperation() MyObjectImpl_Stub
Proxy
+myOperation() «interface» MyObject invokes myOperation(a,b) on the remote MyObjectImpl object, then it has an indirect reference "host ID and local host address on host" +myOperation() MyObjectImpl
Client
Pattern found in the original "Desing Patterns" book.
proxy as it is applied in RMI. The stub object is a proxy for the real object.
4.1 General Concepts of RMI
Department of Informatics
Pointers are related to an address space Composite types: embedded pointers need
4.1 General Concepts of RMI
Department of Informatics
Done by client (i.e. the caller / stub) Packing the parameters into a message Flatten structures (e.g. objects) Perform representation conversions if necessary Also done by server (i.e. callee) for returning the
Done by receiver of message (skeleton on server
4.1 General Concepts of RMI
Department of Informatics
Communication code has many details Structure of code is very mechanical
A separated Interface Definition Language (IDL) A description automatically generated from the
4.1 General Concepts of RMI
Department of Informatics
each server object
starts, it registers with a naming service using the name
find the server object, it asks the naming service
4.1 General Concepts of RMI
Department of Informatics
the business object class, by using the rmic compiler.
Naming Service. The registry runs on the host that is serving
Serialization provides a means of writing/reading the state of an
java.io.Serializable.
where the classes needed for deserialization can be downloaded from.
4.2 Java RMI
Department of Informatics
Remote object, i.e., implementing
Non-remote objects
4.2 Java RMI
Department of Informatics
method.
that it implements as a parameter.
client stub, this results in a callback to original client.
4.2 Java RMI
Department of Informatics
Serializable
Object identity(Object o) { return o; }
4.2 Java RMI
Department of Informatics
RMI Registry
2 5
HTTP Server
Interface + Stub Class files
(on hard disk)
1 6
Client
(knows the remote interface of the server)
4
1.
HTTP server must be running and serving the correct classes
2.
The RMI Registry must be running
3.
Server object is registered with RMI Registry
Naming.rebind(o,"a");
4.
Clients looks up the server object
Naming.lookup("a");
5.
Thanks to the codebase annotation, the client requests the stub class file to the HTTP server
6.
The HTTP server sends the class file.
7.
The client can now invoke methods remotely 7
4.2 Java RMI
Server
(implements a remote interface)
3
Department of Informatics
anArithServerMain anArithApp aNaming
anArithImpl
rebind("a", obj);
4.3 Concrete Code Examples
single method to add two ints.
example works.
Department of Informatics
public interface ArithInterface extends java.rmi.Remote { int add(int a, int b) throws java.rmi.RemoteException; }
4.3 Concrete Code Examples
Department of Informatics
import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class ArithImpl extends UnicastRemoteObject implements ArithInterface { public ArithImpl() throws RemoteException {} public int add(int a, int b) throws RemoteException { return a+b; } }
4.3 Concrete Code Examples
Department of Informatics
import java.rmi.Naming; public class ArithServerMain { public static void main(String argv[]) { try { ArithImpl obj = new ArithImpl(); Naming.rebind("//"+134.21.9.144+"/ArithServer", obj); } catch (Exception e) { System.out.println("ArithErr: " + e.getMessage()); } } }
4.3 Concrete Code Examples
Department of Informatics
import java.rmi.RMISecurityManager; import java.rmi.Naming; public class ArithApp { public static void main(String argv[]) { System.setSecurityManager(new RMISecurityManager()); int result = 0; try { ArithInterface obj = (ArithInterface) Naming.lookup("//"+134.21.9.144+"/ArithServer"); result = obj.add(10, 7); } catch (Exception e) { System.out.println("ArithAppErr: "+e.getMessage()); } System.out.println("+a+" + "+b+" is: "+result); } }
4.3 Concrete Code Examples
Department of Informatics
1.
Compile all your stuff
2.
Generate the stub, with the rmic compiler:
rmic –v1.2 ArithImpl
3.
Make the files ArithInterface.class and ArithImpl_Stub.class accessible through an HTTP Server
4.
Launch rmiregistry
5.
Start the server application indicating the right codebase (the
java –Djava.rmi.server.codebase=http//134.21.9.144:2001/ ArithServerMain
6.
Start the client application
java –Djava.security.policy=java.policy ArithApp
4.3 Concrete Code Examples