J2EE - Overview and Introduction Matt Oberlin IBM Software Services for WebSphere
01_J2EE_Overview.prz
Page 1 of 32
J2EE is ...
Java 2 Platform Enterprise Edition Application development that ... is implemented using Java has a component / container division of responsibilities enables a multi-tier architecture is suitable for industrial strength applications uses declarative techniques encourages a separation of engineering roles
01_J2EE_Overview.prz
Page 2 of 32
Java - as a server-side development platform? Language itself easy to learn Fewer mysterious bugs (at least in my code) APIs now mature - cover most significant problem areas Good tools Large community
01_J2EE_Overview.prz
Page 3 of 32
But ... Seductive - server side programming is still not trivial Raw performance significant improvements, and work continues still a performance cost in choosing Java
Pace of change - ongoing evolution of Standards Products What is practicable
01_J2EE_Overview.prz
Page 4 of 32
JSR - learning opportunities JSR 1 - Real-time Extension; Lead JSR 3 - Java Management Extension; Participant JSR 4 - ECPerf Benchmark; Participant JSR 5 - XML Extensions; Participant JSR 6 - Unified Print API; Participant JSR 10 - Preferences API; Lead JSR 11 - JAIN; Participant JSR 12 - Java Data Objects; Participant JSR 13 - Big Decimal Arithmetic; Lead JSR 14 - Generic Types; Participant JSR 16 - J2EE Connectors; Participant, Submitter JSR 19 - EJBs; Participant, Submitter JSR 20 - Orthogonal Persistence; Participant JSR 21 - JAIN JCC/JCAT; Participant JSR 22 - JAIN SCE/SLEE; Participant JSR 26 - UML/EJB Mapping; Participant JSR 28 - Java/SASL; Participant JSR 31 - XML Data Binding; Participant JSR 38 - Application Installation API; Participant JSR 40 - Metadata API; Participant JSR 43 - JTAPI API; Participant JSR 44 - Braile API; Participant JSR 45 - Debugging Support for other Languages; Participant JSR 47 - Java Logging API; Co-lead, Submitter JSR 48 - WBEM Services; Participant JSR 50 - Distributed Realtime; Participant
01_J2EE_Overview.prz
JSR 51 - I/O APIs; Participant JSR 52 - Standard Tag-lib for JSPs; Participant JSR 53 - Servlet 2.3 and JSP 1.2; Participant JSR 54 - JDBC 3.0; Participant JSR 55 - Certification Path API; Participant JSR 57 - Long-term Persistence for JavaBeans; Participant JSR 58 - J2EE 1.3 Specification; Participant JSR 59 - J2SE Merlin Specification; Participant JSR 63 - Java API for XML Processing; Participant JSR 67 - Java API for XML Messaging; Participant JSR 68 - J2ME Specification; Participant JSR 69 - Java OLAP Interface; Participant JSR 72 - Generic Security Services; Participant JSR 73 - Data Mining API; Participant JSR 74 - Public Key Crypto; Lead JSR 75 - PDA Profile for JME; Participant JSR 76 - RMI Security; Participant JSR 77 - J2EE Management; Participant JSR 78 - Custom Remote References; Participant JSR 80 - Universal Serial Bus; Lead JSR 82 - Java APIs for Bluetooth; Participant JSR 83 - Java Multi-array Package; Lead JSR 84 - Floating Point Extensions; Lead JSR 86 - Enterprise Media Beans; Lead JSR 87 - Java Agent Services; Participant JSR 88 - J2EE Application Deployment; Participant JSR 92 - Localizable Text; Lead, Submitter JSR 93 - Java API for XML Registry; Participant JSR 94 - Java Rule Engine; Participant JSR 95 - J2EE Activity Service for Extended Transactions; Lead, Submitter JSR 96 - Java Daemons; Participant JSR 100 - JAIN Service Creation Environment; Participant
JSR 101 - Java APIs for XML-based RPC; Participant JSR 102 - JDOM; Participant JSR 104 - XML Trust Services API; Lead JSR 105 - XML Digital Signatures API; Co-lead JSR 106 - XML Digital Encryption API; Lead JSR 107 - JCACHE; Participant JSR 109 - Implementing Enterprise Web Services; Lead JSR 110 - Java APIs for WSDL; Lead JSR 111 - Java Services Framework; Participant JSR 112 - J2EE Connector Architecture 2.0; Participant, Submitter JSR 114 - JDBC Rowset Implementations; Participant JSR 115 - Java Authorization Service; Participant JSR 117 - J2EE APIs for Continuous Availability; Participant JSR 121 - Application Isolation APIs; Participant JSR 126 - Distributed Page Assembly; Lead JSR 127 - GUI Component Architecture; Participant JSR 131 - ECPerf 1.1; Participant JSR 133 - Java Memory Model; Participant JSR 138 - Performance Metrics; Participant JSR 149 - WorkAreas; Lead, Submitter JSR 150 - I18N Context; Lead, Submitter JSR 151 - J2EE 1.4; Participant JSR 152 - JSP 1.3; Participant JSR 153 - EJB 2.1; Participant JSR 153 - Servlet 2.4; Participant JSR 168 - Portlet API, Lead, Submitter
Page 5 of 32
WebSphere and the J2EE Specifications Standards WebSphere 5.0 J2EE JDK EJB Servlet JSP JDBC RMI/IIOP JTS/JTA JMS JavaMail/JAF JCE J2C
01_J2EE_Overview.prz
1.3 1.3 2.0 2.3 1.2 2.0 1.0 1.0 1.0.2 1.2 1.3 1.0
WebSphere 4.0x WebSphere 3.5x 1.2 1.3 1.1 2.2 1.1 2.0 1.0 1.0 1.0 1.1
None 1.2.2 1.0 2.2 1.1 2.0 1.0
Page 6 of 32
Components and Containers
"Good" application design We want: Flexible, Maintainable, Scalable, Separation of concerns We don't want: Repetition, Re-invention, Repetition
We write components; code that: Does one, well-defined, job well - separation of concerns Can be used with other components - appropriate interfaces Uses Standard APIs - implemented with well-known techniques Has a life-cycle and environment provided by the container: use existing plumbing exploit rich container facilities
01_J2EE_Overview.prz
Page 7 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Check available stock Calculate order value Update available stock
01_J2EE_Overview.prz
Page 8 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Read from database Check available stock Calculate order value Update available stock Write to database
01_J2EE_Overview.prz
Page 9 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Map object to relational data Write to database
01_J2EE_Overview.prz
Page 10 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database
01_J2EE_Overview.prz
Page 11 of 32
Component Example - Wine Cellar Customer orders some cases of wine Begin Transaction Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database Commit Transaction
01_J2EE_Overview.prz
Page 12 of 32
Component Example - Wine Cellar Customer orders some cases of wine Interpret Request Check authorisation Begin Transaction Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database Commit Transaction Prepare response
01_J2EE_Overview.prz
Page 13 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Obtain request (HTTP) Authenticate Retrieve Session Data Interpret Request Dispatch to Service
01_J2EE_Overview.prz
Check authorisation Begin Transaction Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database Commit Transaction
Determine output device Format response Write response (HTTP)
Page 14 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Obtain request (HTTP) Authenticate Retrieve Session Data Interpret Request Dispatch to Service
01_J2EE_Overview.prz
Select Service Object Check authorisation Begin Transaction Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database Commit Transaction
Determine output device Format response Write response (HTTP)
Page 15 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Obtain request (HTTP) Authenticate Retrieve Session Data Interpret Request Dispatch to Service
01_J2EE_Overview.prz
Select Service Object Check authorisation Begin Transaction Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database Commit Transaction
Determine output device Format response Write response (HTTP)
Page 16 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Obtain request (HTTP) Authenticate Retrieve Session Data Interpret Request Dispatch to Service
01_J2EE_Overview.prz
Select Service Object Check authorisation Begin Transaction Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database Commit Transaction
Determine output device Format response Write response (HTTP)
Page 17 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Obtain request (HTTP) Authenticate Retrieve Session Data Interpret Request Dispatch to Service
Connection Pooling
01_J2EE_Overview.prz
Select Service Object Check authorisation Begin Transaction Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database Commit Transaction
Determine output device Format response Write response (HTTP)
Page 18 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Obtain request (HTTP) Authenticate Retrieve Session Data Interpret Request Dispatch to Service
Prepared Statement Cache
01_J2EE_Overview.prz
Select Service Object Check authorisation Begin Transaction Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database Commit Transaction
Determine output device Format response Write response (HTTP)
Page 19 of 32
Component Example - Wine Cellar Customer orders some cases of wine
Obtain request (HTTP) Authenticate Retrieve Session Data Interpret Request Dispatch to Service
Container will do this
01_J2EE_Overview.prz
Select Service Object Check authorisation Begin Transaction Obtain database connection Read from database Map relational data to object Check available stock Calculate order value Update available stock Create Invoice Map object to relational data Write to database Commit Transaction
Determine output device Format response Write response (HTTP)
Page 20 of 32
J2EE: component and container Widely accepted application structure Standard APIs as solutions to common programming requirements Containers to manage solutions to infrastructure problems Access always via container EJB Container
Servlet Container
Threads Security Transactions
Threads Security serlvet
Monitoring
Monitoring Servlet
JDBC
JCA
JMS
JNDI
APIs
01_J2EE_Overview.prz
Page 21 of 32
Divide and ... Sharing requests across multiple servers Configuration options that improve Scalability - serve more users Load balancing - share work fairly Availability - system runs if server fails
01_J2EE_Overview.prz
Page 22 of 32
Servlet Workload Management HTTP Server Plug-in routes Servlet requests Random or Round Robin among available Clones Using HTTP Temporarily routes around unavailable Clones
HTTP Requests
HTTP Server Plug-in
Web EJB Container Container Servlet App Server 1, Clone 1 Requests HTTP
01_J2EE_Overview.prz
Web EJB Container Container App Server 1, Clone 2
Application Database
Page 23 of 32
Round Robin Prefer Local - Default Local = Same Node Fails over to remote Clones if no local Clones available Returns to the same Clone within a Transaction Transaction and security contexts flow automatically
Web Container AS 2, Cl. 1
HTTP Requests
HTTP Server Plug-in
EJB Container AS 3, Cl. 2 IIOP
HTTP
Web Container AS 2, Cl. 2
01_J2EE_Overview.prz
EJB Container Prefer AS 3, Cl. 1 Local
Java Client
EJB Container Prefer AS 3, Cl. 3 Local EJB Container AS 3, Cl. 4
Page 24 of 32
Process Affinity Process Affinity where EJB Client and EJB Container are in the same Application Server
Web EJB Process Container Affinity Container Application Server 1, Clone 1 EJB Process Web Container Affinity Container Application Server 1, Clone 2 HTTP Requests
HTTP Server Plug-in
IIOP
HTTP
Java Client
EJB Process Web Container Affinity Container Application Server 1, Clone 3 Web EJB Process Container Affinity Container Application Server 1, Clone 4
01_J2EE_Overview.prz
Page 25 of 32
J2EE is Application development that .. is implemented using Java has a component / container division of responsibilities enables a multi-tier architecture is suitable for industrial strength applications uses declarative techniques encourages separation of engineering roles
01_J2EE_Overview.prz
Page 26 of 32
When the Container controls it can ...
Monitor Performance monitoring hooks
Optimise By Caching By improving Data Access Improve Application Performance Without Code Change
01_J2EE_Overview.prz
Page 27 of 32
Example 2 - Servlet container opportunity F I 2 3 R E W 8 10 A 9 Web Server Internet L L
1
F I 4 5 R E W 6 7 A App Server DB Server L L
Ten network hops for a single request Servlet, security, EJB systems, back-end datasource servers (DB, ERP, JMS) all exercised and stressed repeatedly to return exact same results
01_J2EE_Overview.prz
Page 28 of 32
Example 2 - Servlet container caches results F I 2 3 R E W 6 8 A 7 Internet Web Server L L
1
F C I 4 a R c E h e W 5 A App Server DB Server L L
Stress relieved on servlet, EJB containers, back-end datasource servers Can cache page 'fragments' and whole pages
01_J2EE_Overview.prz
Page 29 of 32
Example 2 - Caching obtained by configuration
01_J2EE_Overview.prz
Page 30 of 32
J2EE is Application development that .. is implemented using Java has a component / container division of responsibilities enables a multi-tier architecture is suitable for industrial strength applications uses declarative techniques encourages separation of engineering roles
01_J2EE_Overview.prz
Page 31 of 32
Development role perspective Concern
Page Layout and Content (View)
Application Flow (Controller)
Business Logic (Model)
Operational Environment (Application)
Role Page Producer
Application Assembler
Bean Builder
Deployer
Components Produced
Java Server Pages, HTML, MIME types
HTTP Servlets, View Beans, Tags
Data Beans, Access Beans, EJBs
EJB container methods
Components Used
View Beans, Tags
Data Beans, JSPs
EJBs, Data Beans
Programming Skills Required
Data Beans, Access Beans, EJBs
Little or None
Pure Java
Pure Java
Java, SQL, CICS, ...
WYSIWYG Editors
OOAD, Java IDE
OOAD, Java IDE
Specialized Wizards
Tools
Best practice: "Let the right expert do the work."
01_J2EE_Overview.prz
Page 32 of 32