Middleware Technology (J2EE/EJB) February 2011 Course Information • Lecturer: 尹皓 • Contact: – yinhao@scu.edu.cn, 13551277539 • Course website: – http://swjx.scu.edu.cn/moodle • TA: 石丹 • Contact: – standing06@yahoo.com.cn, 13541298431 – QQ:284451824 2 3 Contents • • • • • JSP/Servlet EJB Fundamentals Java RMI & Message Service EJB 2.1 EJB 3.0 4 Assessment • 70% Final Examination • 20% Project Presentation • 10% On-class Practice 5 Your Role – Learning With Doing • Attend all lectures • Work out the exercise on your own or after a discussion with your group, don’t make copy 6 You end up learning more in less time when you are actually doing stuff instead of just reading. Reference Book & Course Material • Mastering EJB 3.0 Rima Patel Sriganesh, Gerald Brose, and Micah Silverman, Wiley Publishing, Inc. 2006 • JBoss EJB3.0 Tutorial • http://java.sun.com (Oracle) • http://java.sun.com/docs/books/tutorial/ • http://www-900.ibm.com/developerWorks/cn (IBM WebSphere) • BEA WebLogic 8 Application realm • Java technology could be used in the following fields: Website, Electronic Business, Mobile Business, Grid Computing, Game, etc. 9 1. Overview • Now a typical business application is a distributed system,we should break up a monolithic application into a distributed system with multiple clients connecting to multiple servers and database over network. • What should we think about according to the above scheme? Remote method invocation Load balance Back-end integration Transaction Clustering 10 The motivation for EJB • In the past, most companies built their own middleware. • These days, rather than build them yourself, you could buy these middleware services because of the appearance of application server (standard). Application servers provide you with common middleware services, such as resource pooling (database, socket), network, transaction, security, and more. • We build our application out of components. Components are not entire applications, they can not run alone. • A company can purchase a well-defined module that solve a problem and combine it with other components to solve larger problem. 11 The motivation for EJB • An example – a pricing component Different customers can reuse a generic component provided by the same vendor. • The advantages of reusing components The IT shop needs less in-house expertise The application is assembled faster There is a lower total cost of ownership • Therefore we need a standard between application servers and components. This will allow components to be switched in and out of various application servers without having to change code or potentially even recompile the components. 12 Thin-Client Multi-tier Application Web Browser HTML Page Tier 1: Client Tier Network Web Server (Thin-Client Servlet) Tier 2: Web Tier Network Enterprise Beans Application Server Tier 3: Business Tier Network Database Server Tier 4: EIS Tier (Enterprise Information System) 13 Introducing EJB • Enterprise JavaBean(EJB) is a server-side component architecture.(different from Java Beans) • Scalable、reliable 、secure application (thin client) • Rapid application development for server-side • EJB Standard is a component architecture for deployable serverside components in Java • Specification、interface 14 Top three values of EJB • It is agreed upon by industry. (“Train once, code anywhere”) • Portability is easier. EJB specification is published and available freely to all. (java.sun.com) • Rapid application development. 15 Why Java • EJB components must be written in Java only. (restriction) • Interface/Implementation separation (JDBC) • Safe and secure (no pointers/automatic garbage collection) • Cross platform (windows/Unix) 16 What EJB can do • Performing business logic (back end) • Access a database (JDBC) • Access another system (JCA: Java Connector Architecture) 17 EJB Ecosystem(6 roles) • The Bean Provider (Application Component Provider) • The Application Assembler (Application Assembler) create a .ear file • The EJB Deployer (Deployer) deploy transaction and security, etc. • The System Administrator (System Administrator) monitoring the runtime environment (Log Analyzer、Resource Analyzer) • The Container and Server Provider (J2EE Product Provider) IBM’s WebSphere、BEA’s WebLogic、Macromedia’s JRun • The Tool Vendors (Tool Provider) IBM’s Visual Age for Java (WSAD)、Borland’s JBuilder、 Oracle’s JDeveloper (IDE) 18 J2EE Application J2EE Application Application Client Component Web Component 19 EJB Component J2EE Application Files • • J2EE Application J2EE Application Deployment Descriptor .ear .xml • • • • • EJB Component EJB Deployment Descriptor EJB Class Remote Interface Home Interface .jar .xml .class .class .class • • • • • Web Component Web Component Deployment Descriptor JSP Files Servlet Class HTML Files .war .xml .jsp .class .html • • • J2EE Application Client J2EE Application Client Deployment Descriptor Java Application .jar .xml .class 20 J2EE Architecture 21 Glossary J2EE:Java 2 Platform, Enterprise Edition SSL:Secure Sockets Layer RMI:Remote Method Invocation JMS:Java Message Service JNDI:Java Naming and Directory Interface JTA:Java Transaction API JAF:JavaBeans Activation Framework RMI/IIOP:RMI over IIOP JDBC:Java Database Connectivity 22 J2EE • The Java 2 Platform, Enterprise Edition (J2EE) Providing a platform-independent, portable, multi-user, secure and standard enterprise-class platform for server-side deployment written in the Java language. • Three different Java platforms The Java 2 Platform, Micro Edition (J2ME) A development platform for Java-enabled device (small devices) The Java 2 Platform, Standard Edition (J2SE) JDK The Java 2 Platform, Enterprise Edition (J2EE) A complete development platform for enterprise-class server-side deployment in Java. J2EE builds on J2SE. 23 Microsoft SQL Server JDBC Java Platform Grid project Globus Toolkit 3.0 Platforms J2SDK J2EE J2ME Core/Desktop Enterprise/Server Mobile/Wireless Application,Applet, Swing, Awt JSP/Servlet, EJB Midlet (Cell Phone/PDA) Borland JBuilder, JCreator, or Text Editor IBM WebSphere, WSAD BEA WebLogic, Workshop Sun One Studio Oracle JDeveloper 24 Nokia, Motorola, Siemens SDK JBuilder,Sun One Studio The J2EE Technologies (API) • Enterprise JavaBeans (EJB) • Java Remote Method Invocation (RMI) and RMI-IIOP RMI-IIOP is an extension of RMI that can be used for CORBA integration. RMIIIOP is the official API used in J2EE (not RMI). • Java Naming and Directory Interface (JNDI) EJB components, Data Source and other resources across network • Java Database Connectivity (JDBC) accessing relational database 25 The J2EE Technologies (API) • Java Transaction API (JTA) and Java Transaction Services (JTS) Commit/Rollback, container management • Java Messaging Service (JMS) Message-Driven Bean, asynchronous invocation • Java Servlets Taking requests from some client host (such as a web browser) and issue a response back to that host. • Java Pages (JSPs) The largest difference between JSP scripts and Servlets is that JSP scripts are not pure Java code. 26 The J2EE Technologies (API) • Java IDL Java-based implementation of CORBA. • JavaMail Allowing you to send email message in a platform-independent, protocol-independent manner from your Java programs. • J2EE Connector Architecture (JCA) Handling transaction and security concerns. • The Java API for XML Parsing (JAXP) SAX/DOM • The Java Authentication and Authorization Services (JAAS) 27