Java 2 Platform Enterprise Edition J 2 EE

  • Slides: 111
Download presentation
Java 2 Platform, Enterprise Edition (J 2 EE) An Overview 蔡文能 交通大學資訊 程學系 tsaiwn@csie.

Java 2 Platform, Enterprise Edition (J 2 EE) An Overview 蔡文能 交通大學資訊 程學系 tsaiwn@csie. nctu. edu. tw 1

What Is J 2 EE ? • Java 2 Enterprise Edition • There are

What Is J 2 EE ? • Java 2 Enterprise Edition • There are 3 different specifications within the Java framework (J 2 SE, J 2 ME, J 2 EE) • Created to provide a simple, unified standard for distributed applications through a component based application model • Specification is managed by a consortium of industry leaders 2

Some useful online references • http: //java. sun. com/j 2 ee/tutorial/index. html 3

Some useful online references • http: //java. sun. com/j 2 ee/tutorial/index. html 3

J 2 EE and Other Java 2 Platform Editions Source: Computer, August 2000 J

J 2 EE and Other Java 2 Platform Editions Source: Computer, August 2000 J 2 EE, J 2 SE, J 2 ME 4

J 2 EE and Other Java 2 Platform Editions J 2 EE, J 2

J 2 EE and Other Java 2 Platform Editions J 2 EE, J 2 SE, J 2 ME Source: Sun Microsystems, Inc. 5

Java Development and Runtime Environment Source: P. J. Perrone and V. S. R. R.

Java Development and Runtime Environment Source: P. J. Perrone and V. S. R. R. Chaganti, Building Java Enterprise Systems with J 2 EE 6

Java 2 Platform Runtime Architecture Source: P. J. Perrone and V. S. R. R.

Java 2 Platform Runtime Architecture Source: P. J. Perrone and V. S. R. R. Chaganti, Building Java Enterprise Systems with J 2 EE 7

Java 2 Platform, Standard Edition (J 2 SE 1. 3) Source: Sun Microsystems, Inc.

Java 2 Platform, Standard Edition (J 2 SE 1. 3) Source: Sun Microsystems, Inc. , http: //java. sun. com/j 2 se/1. 3/ 8

Java 2 Platform, Standard Edition (J 2 SE 1. 4) Source: Sun Microsystems, Inc.

Java 2 Platform, Standard Edition (J 2 SE 1. 4) Source: Sun Microsystems, Inc. , http: //java. sun. com/j 2 se/1. 4/ 9

Why J 2 EE ? • A stand alone program • Client/Server (2 -Tier)

Why J 2 EE ? • A stand alone program • Client/Server (2 -Tier) – BBS, News, FTP, Telnet, … • Traditional (non-component) N-Tier Systems – 3 -tier application: Browser – WEB Server – DBMS • New trend: – Component N-Tier Systems (J 2 EE Architecture) See figures on next slides 10

2 -Tier Database Access • Client Tier – Presentation, Business Logic • Data Tier

2 -Tier Database Access • Client Tier – Presentation, Business Logic • Data Tier – Database Management Services Source: Sun Microsystems, Inc. , JDBC 3. 0 Specification 11

Traditional(non-component) N-Tier Systems • Client Tier – Presentation Logic • Application Tier – Business

Traditional(non-component) N-Tier Systems • Client Tier – Presentation Logic • Application Tier – Business Logic • Data Tier – Database Management Services Source: Sun Microsystems, Inc. , JDBC 3. 0 Specification 12

Component N-Tier Systems J 2 EE Architecture Client Tier Fireware Applet Container Web Tier

Component N-Tier Systems J 2 EE Architecture Client Tier Fireware Applet Container Web Tier Web Container Connector EJB Container JSP Standalone Client Machine EIS Tier Business Tier EJB Servlet Enterprise Information Services J 2 EE Server Machine Database Server Machine 13

J 2 EE Architecture (1/2) J 2 EE Component and Container Source: Sun Microsystems,

J 2 EE Architecture (1/2) J 2 EE Component and Container Source: Sun Microsystems, Inc. , J 2 EE Specification v 1. 3 14

J 2 EE Architecture (2/2) • J 2 EE consists of three major parts:

J 2 EE Architecture (2/2) • J 2 EE consists of three major parts: – Components Hold presentation and business logic – Containers Provide context for components – Connectors Provide access to legacy enterprise systems 15

J 2 EE Components • Application clients • Applets • Web components – Servelets,

J 2 EE Components • Application clients • Applets • Web components – Servelets, Java Server Pages (JSP) – Portlet (see JSR 168) • Business components – Enterprise Java Beans (EJB) 16

J 2 EE Component Applet Component • An applet is a program written in

J 2 EE Component Applet Component • An applet is a program written in the Java. TM programming language that can be included in an HTML page, much in the same way an image is included. When you use a Java technologyenabled browser to view a page that contains an applet, the applet's code is transferred to your system and executed by the browser's Java Virtual Machine (JVM). • An applet is a small program that is intended not to be run on its own, but rather to be embedded inside another application. 17

Applet pro vs. con • Applets: Java code that runs inside browser • Advantages:

Applet pro vs. con • Applets: Java code that runs inside browser • Advantages: – – Extends functionality on the client side More complicated GUIs than w/ HTML or Java. Script Computation can be off-loaded from server Users don’t have to build, install, and configure • Disadvantages: – Download time – “Sandbox” limits functionality (unless signed) – Window management by browser 18

J 2 EE Component Web Component • Servlets – A servlet is a program

J 2 EE Component Web Component • Servlets – A servlet is a program that extends the functionality of a Web server. Servlets receive a request from a client, dynamically generate the response (possibly querying databases to fulfill the request), and then send the response containing an HTML or XML document to the client • JSP – The Java. Server Pages (JSP) technology provides an extensible way to generate dynamic content for a Web client. A JSP page is a textbased document that describes how to process a request to create a response 19

Java Servlet Class wasn’t loaded into System Class Loader HTTP Request Web Services Browser

Java Servlet Class wasn’t loaded into System Class Loader HTTP Request Web Services Browser Load Servlet class Into System Servlet Class was loaded Invoker HTTP Response Services 20

Java Servlet • Java Servlet is the bridge for user to use Java solution

Java Servlet • Java Servlet is the bridge for user to use Java solution in Web Server. • Java Servlet has better performance than CGI(Common Gateway Interface). • Java Servlet can use session to replace cookie and enhance security. • J 2 EE Server maintains the session for Java Servlets. 21

Java. Server Pages (JSP) Java Source Code Compiler Java Bytecode Load Servlet class Into

Java. Server Pages (JSP) Java Source Code Compiler Java Bytecode Load Servlet class Into System New JSP Page JSP was modified Class Loader JSP isn’t loaded yet. HTTP Request (. jsp) Web Services Browser Invoker HTTP Response jsp. Services 22

Java. Server Pages (JSP) • • • JSP has all features of Servlet. JSP

Java. Server Pages (JSP) • • • JSP has all features of Servlet. JSP is a HTML like document. JSP is designed for Web Page Developer. JSP will change to Java Servlet source. JSP is ran via Servlet mode. 23

Java. Server Pages Objects • JSP has 9 objects which developer can use directly

Java. Server Pages Objects • JSP has 9 objects which developer can use directly without new it. JSP Object java class request javax. servlet. Servlet. Request responsejavax. servlet. Servlet. Response page. Context javax. servlet. jsp. Page. Context session javax. servlet. http. Http. Session application javax. servlet. Servlet. Context out javax. servlet. jsp. Jsp. Writer config javax. servlet. Servlet. Config page java. lang. Object exception java. lang. Throwable scope request page session application page 24

Portlet and Portal • JSR 168 Browser Portal Server HTTP – Java portlet standard

Portlet and Portal • JSR 168 Browser Portal Server HTTP – Java portlet standard • WSRP (Web Services for Remote Portlets) WSRP – Remote portlet JSR 168 Portlet Container communication protocol JSR 168 – Portals aggregate Portlet remote portlets 25

The Reason For JDBC • Despite almost all databases supporting SQL, database vendors (Microsoft

The Reason For JDBC • Despite almost all databases supporting SQL, database vendors (Microsoft Access, Oracle etc. ) provide proprietary (no standard) Application Programming Interfaces for sending SQL to the server and receiving results from it! • Languages such as C/C++ can make use of these proprietary APIs directly – High performance – Can make use of non standard features of the database – All the database code needs to be rewritten if you change database vendor or product • JDBC (Java Data. Base Connectivity) is a vendor independent API for accessing relational data from 26 different database vendors in a consistent way CCTM: Course material developed by James King (james. king@londonmet. a

JDBC • JDBC provides an API that hides the vendor specific APIs by inserting

JDBC • JDBC provides an API that hides the vendor specific APIs by inserting a driver between the Java application and the database API • JDBC requires a vendor-specific driver • The driver converts calls from JDBC API to vendor’s API => performance penalty • The driver does not provide access to vendor specific functionality • The same Java application can be used with a different vendor’s database by simply switching JDBC driver and changing one line of Java code. • JDBC 1. 0 is included inside JDK 1. 1 or higher in a package java. sql 27 • JDBC 2. 0 and 3. 0 require updated drivers and an additional package javax. sql CCTM: Course material developed by James King (james. king@londonmet. a

Rollback and Commit • By default connections to the database commit each update as

Rollback and Commit • By default connections to the database commit each update as soon as it is completed. • If you want to make a set of changes and only commit the aggregate result if nothing goes wrong auto commit needs to be switched off connection. set. Auto. Commit(false) You can then use connection. commit() to apply the changes connection. rollback() to undo changes since the last commit • You can switch auto commit back on using connection. set. Auto. Commit(true) 28 CCTM: Course material developed by James King (james. king@londonmet. a

J 2 EE Compoent (1/2) EJB Component • Enterprise Java. Bean (EJB) – The

J 2 EE Compoent (1/2) EJB Component • Enterprise Java. Bean (EJB) – The Enterprise Java. Beans (EJB) architecture is a server -side technology for developing and deploying components containing the business logic of an enterprise application. – Enterprise Java. Beans components, termed enterprise beans, are scalable, transactional, and multi-user secure. • EJB is an architecture for component-based transactional distributed computing. 29

EJB Component (2/2) • An enterprise bean contains business logic that operates on the

EJB Component (2/2) • An enterprise bean contains business logic that operates on the enterprise’s data. • Client access is mediated by a Container. • There are three kinds of enterprise beans: session beans, entity beans, and messagedriven beans. 30

Enterprise Bean Objects • Session objects: for a single client, shortlived, …Stateful, Stateless •

Enterprise Bean Objects • Session objects: for a single client, shortlived, …Stateful, Stateless • Entity objects: object view of data in the database, shared by multiple clients, longlived, … • Message-driven objects: triggered by a single client message, short-lived, stateless, … 31

Stateful vs. Stateless Session Beans • Stateful – Possess Internal State – One per

Stateful vs. Stateless Session Beans • Stateful – Possess Internal State – One per client – Need to handle activation/ passivation • Stateless – Do not possess state – Can be pooled to handle multiple clients – Do not need to be passivated 32

Entity Beans: CMP vs. BMP • Container Manager Persistence – Container responsible for database

Entity Beans: CMP vs. BMP • Container Manager Persistence – Container responsible for database accesses/ controls – Developer focuses on data use • Bean Managed Persistence – Developer must write code to handle database accesses/ controls – Used for more specialized data mapping strategies 33

Entity Bean Characteristics • Provides an object view of data in the underlying database

Entity Bean Characteristics • Provides an object view of data in the underlying database • Shared across multiple users • Long-lived • Survives container crash 34

To Implement an Enterprise Bean (1/2) • Any enterprise bean must define two interfaces

To Implement an Enterprise Bean (1/2) • Any enterprise bean must define two interfaces and one or two classes – Remote interface • defines a bean’s external interface • must extend javax. ejb. EJBObject (which in turn extends java. rmi. Remote) – Home interface • The home interface defines a bean’s “life cycle” methods, eg. create bean, remove bean, find bean, etc. • must extend javax. ejb. EJBHome which also extends java. rmi. Remote 35

To Implement an EJB (2/2) • Bean Class – The java class that actually

To Implement an EJB (2/2) • Bean Class – The java class that actually implements the bean’s external interface, e. g. the bean class provides implementations for the bean’s “business methods” – An entity bean must implement the javax. ejb. Entity. Bean interface, while a session bean must implement the (you guessed it) javax. ejb. Session. Bean. Both of these interfaces extend javax. ejb. Enterprise. Bean • Primary Key – The primary key is a very simple class that provides a pointer into a database; Only entity beans need a primary key. This class must implment java. io. Serializable (so the entity bean can automatically be sent to persistent storage) 36

EJB Container • A container is provided by the Application Server vendor to provide

EJB Container • A container is provided by the Application Server vendor to provide basic services that are required by J 2 EE specification. • An EJB programmer places their code here, and is assured a variety of basic services are available • This means the developer doesn’t have to code these services from scratch • Specification states which services must be supported but not how 37

Basic Services Supplied by the EJB Container • • • Security Transaction management Remote

Basic Services Supplied by the EJB Container • • • Security Transaction management Remote Client Connectivity Life Cycle Management Database Connection Pooling 38

More Services provided by container • The following basic services will be supported by

More Services provided by container • The following basic services will be supported by all J 2 EE compliant products – – – – RMI/RMI-IIOP Resource Pooling Thread Control Presentation Logic Persistence Messaging And more… IIOP: Internet Inter-ORB Protocol ORB: Object Request Broker 39

Can’t Do in an EJB • • • Can’t use threads Can’t use the

Can’t Do in an EJB • • • Can’t use threads Can’t use the AWT Can’t act as network server Can’t use java. io package Can’t load native libray Can’t use this as an argument or return value 40

EJB Benefits Summary • Developing distributed applications in Java – Application developer is spared

EJB Benefits Summary • Developing distributed applications in Java – Application developer is spared from following details • • Transaction management State management Multi-threading Connection pooling • Write once, run anywhere • Interoperability with other languages • Compatible with CORBA protocols 41

J 2 EE Containers (1/2) Web Containers • Web Component Containers – 1. Servlet

J 2 EE Containers (1/2) Web Containers • Web Component Containers – 1. Servlet Containers • A servlet container provides network services (by which requests and responses are sent), decodes requests, and formats responses. All servlet containers must support HTTP as a protocol for requests and responses, but may also support additional request-response protocols such as HTTPS. – 2. JSP Containers • A JSP container provides the same services as a servlet container and an engine that interprets and processes a JSP page into a servlet. – 3. Web Containers • A Web container provides the same services as a JSP container and access to the J 2 EE service and communication APIs. 42

J 2 EE Containers (2/2) EJB Containers • EJB Container – Enterprise beans are

J 2 EE Containers (2/2) EJB Containers • EJB Container – Enterprise beans are hosted by an EJB container. In addition to standard container services, an EJB container provides a range of transaction and persistence services and access to the J 2 EE service and communication APIs. 43

Tomcat • Tomcat: Java-based web server + servlet container w/ JSP environment • Execution

Tomcat • Tomcat: Java-based web server + servlet container w/ JSP environment • Execution modes: – Standalone: default mode for Tomcat – Out-of-process add-on: web server plugin opens JVM outside web server; plugin and JVM communicate using IPC mechanism (TCP/IP sockets and special protocol) 44

Tomcat and Apache • Communication mechanism between Tomcat and Apache: web server adapter” or

Tomcat and Apache • Communication mechanism between Tomcat and Apache: web server adapter” or named as “connector” • Implemented as shared library (e. g. , mod_jserv. so, mod_jk. so) • Uses/manages TCP connections • Uses the AJPV 12/AJPV 13 communication protocol 45

J 2 EE Connectors • Contract between container and Enterprise Information Systems (EIS) •

J 2 EE Connectors • Contract between container and Enterprise Information Systems (EIS) • Proprietary and under the hood • Implementation is available with J 2 EE specification version 1. 3 / 1. 4 46

J 2 EE Standard Services • HTTP/HTTPS • Java Transaction API (JTA) • Java

J 2 EE Standard Services • HTTP/HTTPS • Java Transaction API (JTA) • Java Database Connection (JDBC) • • Java Message Service (JMS) Java Authentication and Authorization Service (JAAS) J 2 EE Connector Architecture (JCA) Others: RMI-IIOP, Java. IDL, Java. Mail, Java. Beans Activation Framework (JAF), Java API for XML Parsing (JAXP) IIOP: Internet Inter-ORB Protocol 47

The Solution: J 2 EE Application Model • J 2 EE application model partitions

The Solution: J 2 EE Application Model • J 2 EE application model partitions the work needed to implement a multi-tier service into two parts – the business and presentation logic (implemented by the application developer) – the standard system services provided by the J 2 EE platform. • The developer can rely on the platform to provide the solutions for the hard systems level problems of developing a middle-tier service. 48

J 2 EE Application Model Source: Sun Microsystems, Inc. , http: //java. sun. com/j

J 2 EE Application Model Source: Sun Microsystems, Inc. , http: //java. sun. com/j 2 ee/overview 2. html 49

Benefits of J 2 EE Application Model • The J 2 EE application model

Benefits of J 2 EE Application Model • The J 2 EE application model provides the benefits of Write Once, Run Anywhere™ portability and scalability for multi-tier applications. • This standard model minimizes the cost of developer training while providing the enterprise with a broad choice of J 2 EE servers and development tools. 50

J 2 EE Platform Roles • • • J 2 EE Product Provider Application

J 2 EE Platform Roles • • • J 2 EE Product Provider Application Component Provider Application Assembler Deployer System Administrator Tool Provider 51

The Connector Architecture • Integration of J 2 EE servers with Enterprise Information Systems

The Connector Architecture • Integration of J 2 EE servers with Enterprise Information Systems (EIS) • EIS vendor-provided resource adaptors • Resource adaptor-permitting application servers 52

J 2 EE Connector • J 2 EE Connector – The J 2 EE

J 2 EE Connector • J 2 EE Connector – The J 2 EE Connector architecture defines a standard architecture for connecting the J 2 EE platform to heterogeneous EISs. Examples of EISs include ERP, mainframe transaction processing, database systems, and legacy applications not written in the Java programming language. By defining a a set of scalable, secure, and transactional mechanisms, the J 2 EE Connector architecture enables the integration of EISs with application servers and enterprise applications. 53

System Level Pluggability Source: Sun Microsystems, Inc. , J 2 EE Connector Architecture Specification

System Level Pluggability Source: Sun Microsystems, Inc. , J 2 EE Connector Architecture Specification 54

Connector Architecture Overview Source: Sun Microsystems, Inc. , J 2 EE Connector Architecture Specification

Connector Architecture Overview Source: Sun Microsystems, Inc. , J 2 EE Connector Architecture Specification 55

Connector Architecture Overview (cont. ) 56 Source: Sun Microsystems, Inc. , J 2 EE

Connector Architecture Overview (cont. ) 56 Source: Sun Microsystems, Inc. , J 2 EE Connector Architecture Specification

Connector Architecture in B 2 B Scenario Source: Sun Microsystems, Inc. , J 2

Connector Architecture in B 2 B Scenario Source: Sun Microsystems, Inc. , J 2 EE Connector Architecture Specification 57

Client View of an Enterprise Bean • Home Interface: methods for creating, removing, and

Client View of an Enterprise Bean • Home Interface: methods for creating, removing, and finding bean instances • Remote Interface: methods callable by the client • Object Identity • Metadata Interface: mainly for dynamic invocation • Handle 58

Client View of Session Beans Source: Sun Microsystems, Inc. , Enterprise Java. Beans 2.

Client View of Session Beans Source: Sun Microsystems, Inc. , Enterprise Java. Beans 2. 0 59

Accessing Enterprise Beans from Servlets/Java. Server Pages Source: Sun Microsystems, Inc. , J 2

Accessing Enterprise Beans from Servlets/Java. Server Pages Source: Sun Microsystems, Inc. , J 2 EE Specification, v 1. 3 60

J 2 EE Deployment 61 Source: Sun Microsystems, Inc. , J 2 EE Specification,

J 2 EE Deployment 61 Source: Sun Microsystems, Inc. , J 2 EE Specification, v 1. 3

J 2 EE Application Life Cycle Source: Sun Microsystems, Inc. , J 2 EE

J 2 EE Application Life Cycle Source: Sun Microsystems, Inc. , J 2 EE Connector Architecture Specification 62

Overview of Enterprise Applications Integration (EAI) Source: P. J. Perrone and V. S. R.

Overview of Enterprise Applications Integration (EAI) Source: P. J. Perrone and V. S. R. R. Chaganti, Building Java Enterprise Systems with J 2 EE 63

Overview of Enterprise Applications Integration (EAI) Source: P. J. Perrone and V. S. R.

Overview of Enterprise Applications Integration (EAI) Source: P. J. Perrone and V. S. R. R. Chaganti, Building Java Enterprise Systems with J 2 EE 64

EAI with XML Source: P. J. Perrone and V. S. R. R. Chaganti, Building

EAI with XML Source: P. J. Perrone and V. S. R. R. Chaganti, Building Java Enterprise Systems with J 2 EE 65

Enterprise Beans of the Example Design Source: Sun Microsystems, Inc. , The J 2

Enterprise Beans of the Example Design Source: Sun Microsystems, Inc. , The J 2 EE Tutorial 66

J 2 EE Platform Technologies 1/3 • Servlets and JSP – Java technology servlets

J 2 EE Platform Technologies 1/3 • Servlets and JSP – Java technology servlets and Java. Server Pages are server components that run in a web server that supports dynamic HTML generation and session management for browser clients. • EJB – Enterprise Java. Beans is a server component model that provides protability across application servers and implements automatic services on behalf of the application components. • JTA – Java Transaction API provides a transaction demarcation API. • JTS – Java transaction Service defines a distributed transaction management service based on the CORBA Object Transaction Service. 67

J 2 EE Platform Technologies 2/3 • JNDI – Java Naming and Directory Interface

J 2 EE Platform Technologies 2/3 • JNDI – Java Naming and Directory Interface provides access to naming and directory services, such as DNS, LDAP, NDS, and CORBA Naming. • RMI-IIOP – Remote Method Invocation(RMI) creates remote interfaces for Java-to. Java communication. This extension uses the CORBA standard IIOP communication protocol. • Java IDL – Java Interface Definition Language creates remote interfaces to support java-to-CORBA communications. 68

J 2 EE Platform Technologies 3/3 • JDBC – JDBC database access API provides

J 2 EE Platform Technologies 3/3 • JDBC – JDBC database access API provides uniform access to relational databases. • JMS – Java Messaging Service supports asynchronous communication using either a reliable queuing or publish/subscribe model. • Java. Mail – Java. Mail provides a protocol-independent framework to build mail and messaging applications. • JAF – Java. Beans Activation Framework provides standard services to determine the type of an arbitrary piece of data and activate an appropriate Java. Beans component to manipulate the data. 69

History of J 2 EE Technologies • Distributed Objects – CORBA, DCOM, etc. –

History of J 2 EE Technologies • Distributed Objects – CORBA, DCOM, etc. – Three-tier scenario: presentation, business logic, and backend databases • Hard to “get right” without the proper infrastructure • Server-Side Components – Focuses on encapsulating “business rules” into objects in the middle tier • Component Transaction Monitors – Descendant of CORBA’s Object Request Broker • provides discovery, persistence, event notification, transactions, etc. for three-tier or n-tier applications 70

J 2 EE Platform Services • Naming Services – Provide application clients, EJB and

J 2 EE Platform Services • Naming Services – Provide application clients, EJB and Web components with access to a JNDI naming environment. • Deployment Services – Allow components and applications to be customized at the time they are packaged and deployed. • Transaction Services – Devide an application into a series of indivisible or atomic units of work. • Security Services – Designed to ensure that resources are accessed only by users authorized to use them. 72

J 2 EE Platform Benefits • • • Simplified architecture and development Scalability to

J 2 EE Platform Benefits • • • Simplified architecture and development Scalability to meet demand variations Integration with existing information systems Choices of servers, tools, components Flexible security model • The J 2 EE reduces the cost and complexity of developing these multi-tier services, resulting in services that can be rapidly deployed and easily enhanced as the enterprise responds to competitive pressures. 73

J 2 EE Platform • The J 2 EE platform is the standard environment

J 2 EE Platform • The J 2 EE platform is the standard environment for running J 2 EE applications. The J 2 EE platform is composed of the following elements: – J 2 EE deployment specification - a standard that defines a common way of packaging applications for deployment on any J 2 EE compatible platform. – Java technology standards for the J 2 EE platform - a set of standards that all J 2 EE platform products must support (JMS , JNDI etc) – IETF standards for the J 2 EE platform - a set of standards defined by the Internet Engineering Task Force that all J 2 EE platform products must support. (eg XML, HTTP, HTML) – CORBA standards for the J 2 EE platform - a set of CORBA standards upon which the J 2 EE platform bases its middle-tier interoperability. 74

J 2 EE Application Assembly • A J 2 EE application is packaged into

J 2 EE Application Assembly • A J 2 EE application is packaged into one or more standard units for deployment to any J 2 EE platformcompliant system. • Each unit contains a functional component or components (enterprise bean, JSP page, servlet, applet, etc. ), a standard deployment descriptor that describes its content, and the J 2 EE declarations which have been specified by the application developer and assembler. • Once deployed, theses components can then be run. 75

J 2 EE Reference Implementation • Its primary role is as an operational definition

J 2 EE Reference Implementation • Its primary role is as an operational definition of the J 2 EE platform. • Most importantly, it is used as the standard platform for running the J 2 EE Compatibility Test Suite. • A secondary role for the reference implementation is as a freely available platform for popularizing Java 2 platform, Enterprise Edition. 76

J 2 EE Reference Implementation • Latest version available for download – Java. TM

J 2 EE Reference Implementation • Latest version available for download – Java. TM 2 SDK, Enterprise Edition Version 1. 3 – Downloadable at http: //java. sun. com/j 2 ee/ • NOTE : – This version will require Java 2 SDK, Standard Edition (J 2 SE) Version 1. 3. 1 or higher. 77

Application Servers • Consists of – EJB server – Web server (HTTP) – Secured

Application Servers • Consists of – EJB server – Web server (HTTP) – Secured web server (HTTPS) … • J 2 EE Compliance Test – Brings vendor neutrality to your applications – Consists of more than 5000 tests – Currently 9 application servers have been certified • BEA Web. Logic (BEA) • i. Planet (Sun + Netscape) • Websphere (IBM) • (check out www. javasoft. com/j 2 ee for latest update) 78

The BEA Web. Logic Server • All Java, clean-room implementation of the J 2

The BEA Web. Logic Server • All Java, clean-room implementation of the J 2 EE • Shipping basic APIs since 1997 • One of the most widely-used Application Servers on the market – Over 12, 000 customers • Associated BEA product: TUXEDO – Distributed TP Monitor – Originally developed at Bell Labs in 1984 – Influenced the design of Web. Logic 79

Sun ONE Application Server 7 • Provides a comprehensive overview of the Sun ONE

Sun ONE Application Server 7 • Provides a comprehensive overview of the Sun ONE Application Server. Please note - the tour may take up to 1 minute to complete testing your system before starting to load. • Sun is the first software vendor to deliver a fully J 2 EE[tm] platform-certified, commercial application server, free of charge, on all leading OS platforms. • The new Sun ONE Application Server 7 includes the world's fastest, secure http server, and new "Always On" technology. Sun ONE Application Server 7 80

J 2 SE Component Links – – – – Assistive Technologies Drag and Drop

J 2 SE Component Links – – – – Assistive Technologies Drag and Drop Java Access Bridge Java. Beans. TM Technology Javadoc Tool Java Foundation Classes (JFC)/Swing Java Hot. Spot. TM Virtual Machine Java Platform Debugger Architecture (JPDA) Java Plug-in for Windows XP Java 2 DTM API product page Java Web Start JDBCTM Technology Pluggable Look and Feel Remote Method Invocation (RMI) Security 81

List of J 2 ME Technologies – – – – Personal Profile Personal Basis

List of J 2 ME Technologies – – – – Personal Profile Personal Basis Profile Java Card. TM Technology Java Embedded Server. TM Technology Java. Phone. TM API Java Telematics Technology (JTT) Java TVTM API J 2 ME Wireless Toolkit Personal. Java. TM Technology Wireless Developer web site Connected Limited Device Configuration (CLDC) Mobile Information Device Profile (MIDP) Connected Device Configuration (CDC) Foundation Profile 82

JBoss Application Server • JBoss is a simply powerful J 2 EE application server.

JBoss Application Server • JBoss is a simply powerful J 2 EE application server. – JBoss Application Server is the #1 most widely used Java application server on the market. A J 2 EE certified platform for developing and deploying enterprise Java applications, Web applications, and Portals, JBoss Application Server provides the full range of J 2 EE 1. 4 features as well as extended enterprise services including clustering, caching, and persistence. • EJB 3. 0 – JBoss Application Server includes support for Enterprise Java Beans (EJB) 3. 0 which is designed to dramatically simplify the enterprise Java programming model. • Service Oriented Architecture – JBoss AS is founded on a service oriented microkernel architecture with an extremely small in footprint that ensures all services are accessed, managed, and integrated in a unified and consistent manner. 83

Introduction to Apache Ant • What is Ant? – Java-based build tool • Why

Introduction to Apache Ant • What is Ant? – Java-based build tool • Why use Ant? – Cross-platform – Java domain smart – Fast, extensible, integrated – Alternatives? • Analogy – Factory automation 84

Typical Things to Build 85

Typical Things to Build 85

Designing a Build • What are you building? • What does it take to

Designing a Build • What are you building? • What does it take to build it? • How are the steps related? 86

High-level Model Source Code HTML / Text files Index Application (EAR) 87

High-level Model Source Code HTML / Text files Index Application (EAR) 87

Examples of Commercially Used AOP Tools • Aspect. Werkz – Supported by BEA •

Examples of Commercially Used AOP Tools • Aspect. Werkz – Supported by BEA • Spring AOP framework • JBoss AOP • CME (Concern Manipulation Environment) – Supported by IBM 88

Technical Architecture Web Tier View - JSP Struts - Search. Form Commons Validator Struts

Technical Architecture Web Tier View - JSP Struts - Search. Form Commons Validator Struts - Search. Action Search. Session. Bean EJB Container content Ant build <index> task Search. Util API Lucene API index 89

AOP – Aspect Oriented Programming • Which tools are suitable for commercial dev? –

AOP – Aspect Oriented Programming • Which tools are suitable for commercial dev? – Over a dozen tools are listed on aosd. net – Early adopters harden new technologies project posts list (november’ 04 posts) url – How active are the user communities of each? Aspect. J aspectj-users at eclipse. org/aspectj user at aspectwerkz. codehaus. org aspects/jboss forum jboss. org/products/aop Spring AOP springframework-user www. springframework. org abc-users at comlab. ox. ac. uk abc. comlab. ox. ac. uk aspectsharp-users aspectsharp. sourceforge. net aspectc-user at aspect. org aspectc. org jac-users at objectweb. org jac. objectweb. org Aspect. Werkz JBoss AOP aspect# Aspect. C++ JAC 150. . 210 each 1. . 30 90

IDE support, libs, and docs Aspect. J ide editor eclipse, jdeveloper, jbuilder, netbeans highlighting,

IDE support, libs, and docs Aspect. J ide editor eclipse, jdeveloper, jbuilder, netbeans highlighting, content assist, advice links Aspect Werkz advice links JBoss AOP advice links, UI for pointcut creation Spring AOP eclipse views debugger outline, visualizer, cross references ajdoc, ajbrowser aspect manager, advised members - other plain Java dynamic deployment UI, jboss framework integration spring framework integration libs docs - ++++ - ++ ++ +++ + 91

Building AOP programs • What’s it like to adopt AOP on an existing project?

Building AOP programs • What’s it like to adopt AOP on an existing project? source Aspect. J extended. java, or. aj Aspect Werkz JBoss AOP Spring AOP compiler checking incremental aspectj compile full static checking java compile, post processing minor static checking, none of pointcuts plain. java, . xml java compile - weaving compile and load-time, produce bytecode runtime interception and proxies deployment static deployment hot deployable run plain Java program framework invoked & managed 92

AOP features • Aspect. J and Aspect. Werkz – Aspect. J 5 will feature

AOP features • Aspect. J and Aspect. Werkz – Aspect. J 5 will feature support for generics in pointcuts. The @Aspect. J syntax will support the Aspect. Werkz annotation style • JBoss AOP – Static typing for parameters, performance improvements, libraries, and more IDE support features • Spring AOP – Performance improvements, interoperability with Aspect. J's pointcuts, and packaging of some Spring AOP services as Aspect. J aspects 93

JBoss AOP (1/2) - Lack of static checking for pointcuts - Advanced IDE features

JBoss AOP (1/2) - Lack of static checking for pointcuts - Advanced IDE features not yet supported + Rich set of enterprise aspects libraries are available and integrated with JBoss and JEMS + IDE support lowers adoption and reduces need to hand-code XML + Support for dynamic deployment of aspects http: //jboss. org/products/aop 94

JBoss AOP (2/2) 95

JBoss AOP (2/2) 95

Web services in JBoss Overview: JBoss. net • Specifies how JBoss server components are

Web services in JBoss Overview: JBoss. net • Specifies how JBoss server components are exposed as Web service – Stateless Session Beans – Web components – POJO as servlet 96

JBoss Hibernate IS EJB 3. 0 CMP is an API and XML mappings Hibernate

JBoss Hibernate IS EJB 3. 0 CMP is an API and XML mappings Hibernate is the actual persistence engine Hibernate caches are being integrated with JBoss. Cache Full distributed data with OR backend on one node 97

Hibernate Part of JBoss full-time Gavin King and Christian Bauer on board Persistence for

Hibernate Part of JBoss full-time Gavin King and Christian Bauer on board Persistence for POJOs (Java. Beans) • Flexible and intuitive mapping • Support for fine-grained object models • Powerful, high performance queries • Dual-Layer Caching Architecture (HDLCA) • Support for detached objects (no DTOs) • Transparent Persistence • Automatic dirty checking • Transitive Persistence • Smart fetching and caching • Smooth migration to EJB 3. 0 • Consulting and support available as part of JBoss inc 98

Tomcat 5. 0. x improvements • Tomcat’s Remy Maucherat is on JBoss inc staff

Tomcat 5. 0. x improvements • Tomcat’s Remy Maucherat is on JBoss inc staff • Performance optimizations and reduced garbage collection • Optional standalone deployer (validation and precompilation of webapps) • Scalability and reliability enhancements • Complete server monitoring using JMX • Improved Taglibs handling, including advanced pooling and tag plugins • Embedding of Tomcat using JMX • Enhanced Security Manager support (now allows very restrictive policies) • Expanded documentation • Consulting and support available as part of JBoss inc 99

Tomcat standalone or Tomcat inside JBoss ? • Better JBoss deployer – – Hot

Tomcat standalone or Tomcat inside JBoss ? • Better JBoss deployer – – Hot deployment Deployment of nested archives (EARs, SARs) Redeployment Automatic undeployment • Advanced clustering • Integrated J 2 EE stack within one VM – Deployment descriptor – Optimized local calls – Integrated security • AOP in JBoss 4. 0 available in Tomcat components and webapps • Easy to use classloader • Nukes 100

JBoss IDE • JBoss IDE is based on Eclipse. – Series of plugins for

JBoss IDE • JBoss IDE is based on Eclipse. – Series of plugins for Eclipse • The debugging and monitoring of JBoss servers and the control of their life cycle (start/stop). • A very comfortable and sophisticated support for XDoclet – Support completion and generation – Support for AOP (completion and generation). • An easy way to configure and deploy the packaging layout of archives (packed or exploded) 101

What Is JBoss. Cache? • What is JBoss. Cache? – A transactional replicated cache

What Is JBoss. Cache? • What is JBoss. Cache? – A transactional replicated cache for JBoss with and without AOP (aspect-oriented programming) • A cache for frequently accessed elements – Stateful Session Beans, HTTPSession – Caches are used in a number of places in JBoss • This one provides a central cache service (MBean interface) • All access goes through the cache – – Write-through (lazy or eager) Reads only access the cache (very fast on cache hits) Items not in the cache are loaded (e. g. from database) Bounded size; old items are removed by eviction policy • Local (=non-replicated) and replicated caches – Replicated caches are the interesting part 102

Feature • Transactions – All modifications done within TX, replication at TX commit. No

Feature • Transactions – All modifications done within TX, replication at TX commit. No replication on rollback • Locking – Access to nodes serialized by locks – Lock acquisition timeouts used for deadlock prevention • Replication – local: in-VM, no replication – repl-async: replication done on separate thread – repl-sync: replication done on user's thread, wait for all acks • All combinations supported – From local/no-tx/no-locking to repl/tx/locking – Ex: repl-async/no-locking/TX 103

Nukes on JBoss ™ • Nukes on JBoss is a port of PHP postnukes

Nukes on JBoss ™ • Nukes on JBoss is a port of PHP postnukes – Scalability problems with Zend engine – Full port to EJB/J 2 EE. – Leverage the vast library of nukes modules • Most of PN modules are ported • Core : offers the core functionalities to other modules – Security, lifecycle management, parameterization • User : enables user management • Html : stores files, filesystem is abstracted, stored in DB • Sections : edit/publish articles • FORUMS!!!! 104

CMS: ease of update for nontechies 105

CMS: ease of update for nontechies 105

Nukes components 106

Nukes components 106

How to Deploy on JBoss (1/3) 1. Write your beans and package them in

How to Deploy on JBoss (1/3) 1. Write your beans and package them in an ejb-jar file. 2. Write your servlets/JSPs and package them in a war file. 3. Add a Class-Path attribute to your war files MANIFEST. MF file to reference your beans package. for detailed information on that see J 2 EE Deployment specification. http: //www. jboss. org http: //www. jboss. com 107

How to Deploy in JBoss (2/3) 4. Package your application in an ear file.

How to Deploy in JBoss (2/3) 4. Package your application in an ear file. An ear file is a jar archive which contains: • Your jar files • Your war files • A deployment descriptor for your application. This file must be named "application. xml", and must be located in the META-INF directory in the ear archive. This file tells JBoss which modules are EJBs, which ones are web modules, and the context paths for the web-modules. 108

Sample Application. xml file <? xml version="1. 0" encoding="ISO-8859 -1"? > <application> <display-name>My application</display-name>

Sample Application. xml file <? xml version="1. 0" encoding="ISO-8859 -1"? > <application> <display-name>My application</display-name> <module> <web-uri>webmodule. war</web-uri> <context root>/servlets</context-root> </web> </module> <ejb>beans. jar</ejb> </module> </application> 109

How to Deploy in JBoss (3/3) 5. Deploy your ear file. Option 1: Copy

How to Deploy in JBoss (3/3) 5. Deploy your ear file. Option 1: Copy your ear file to JBOSS_HOME/deploy (wow!) Write once Deploy Any. Where!! 110

Thank you! 謝謝捧場 http: //www. csie. nctu. edu. tw/~tsaiwn/java/ 蔡文能 111

Thank you! 謝謝捧場 http: //www. csie. nctu. edu. tw/~tsaiwn/java/ 蔡文能 111

112

112