1 / 92

J2EE TM : Why, What and How

J2EE TM : Why, What and How. University of Texas at Dallas Anna Yi. Objectives. Why J2EE? What is J2EE? How to use J2EE?. Motivation for J2EE. Why J2EE?. Need for New multi-tier enterprise computing model in web environment A way to bring in different elements of enterprise application

chapa
Télécharger la présentation

J2EE TM : Why, What and How

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. J2EETM : Why, What and How University of Texas at Dallas Anna Yi

  2. Objectives • Why J2EE? • What is J2EE? • How to use J2EE?

  3. Motivation for J2EE Why J2EE? • Need for • New multi-tier enterprise computing model in web environment • A way to bring in different elements of enterprise application • Web interface design • Transaction processing • Meeting non-functional system requirements: • Availability, reliability, enhanceability, performance, scalability, reusability, interoperability • Timely development and deployment

  4. Two-tier Client/Server Architecture Why J2EE? Server Client

  5. Simple Web Client/Server Why J2EE? • Interaction of two-tier architecture • Client: simply accesses web pages through web browser • Server: retrieves html documents

  6. CGI-based Web Client/Server Why J2EE? • Interaction of two-tier architecture • Client: uses service requiring 2ndary storage • Server: manipulates forms, Database updates, (primitive) electronic commerce • Fat Server/ Thin Client

  7. Java Applet-based Web Client/Server Why J2EE? • Interaction of two-tier architecture • Client: uses Java Applet for client-side computation • Server: provides Applet bytecode • Fat Client/Thin Server

  8. Server Client Why J2EE? Two-tier Client/Server Architecture But what is the problem with this architecture? • So, important processing needs to be run on the server • Then, Java needs to run on the server too to be more useful  enterprise • The server is almost like what CGI-programming does • Client: data access applying business logic and presentation of data (computation) • Server: serves only as service-database server, not application server web server

  9. Drawbacks of two tier application architecture Why J2EE? • Easy to deploy, but difficult to enhance or upgrade • Reusability of business and presentation logic difficult • Not scalable

  10. Vision of J2EE Why J2EE? • An open standard • Umbrella for anything Java-related • For designing, developing, assembling, and deploying component-based enterprise applications • Separation of business logic from presentation • Reusability, enhanceability, scalability, interoperability

  11. Separation of Business logic from Presentation logic Why J2EE? • Presentation logic : display • Business logic : what the company wants to do Example: the distribution of different sales figures by diff dept (business logic) can be represented in many different ways (pie chart, bar graph, etc)

  12. Why J2EE? • Simplifies the complexity of a building n-tier application • Standardizes an API between components and application server container • J2EE Application Server and Containers provide the framework services

  13. What is J2EE? • Defines the standard for developing multitier enterprise applications • Simplifies enterprise applications by: • Basing them on standardized, modular components • Providing a complete set of services to those components • Handling many details of application behavior automatically, without complex programming

  14. Thin-client Multi-tiered Architecture What is J2EE?

  15. J2EE Tiers • Client Presentation • HTML or Java applets deployed in Browser • XML documentations transmitted through HTTP • Java clients running in Client Java Virtual Machine (JVM) • Presentation Logic • Servlets or JavaServer Pages running in web server • Application Logic • Enterprise JavaBeans running in Server

  16. J2EE Components & Services • Components • Java Servlets • JavaServer Pages (JSP) • Enterprise JavaBeans (EJB) • Standard services & supporting technologies • Java database connectivity(JDBC) data access API • Java Messaging Service (JMS) (Remote Method Invocations (RMI)) • Extensible Markup Languages(XML) • JavaIDL (Interface Description Language) • JavaMail • Java Security • CORBA technology • Design Patterns

  17. Advantages of Multi-tiers • Tiers separate functionality: • Presentation Logic, Business Logic, Data Schema • Easier upgrade since one tier can be changed without changing the rest • Lower deployment and maintenance cost • More flexible (can support changes), more extensible (can add functionality)

  18. The Big Picture What is J2EE?

  19. 4-Tier Model What is J2EE? Web Tier Client Tier EIS Tier Business Tier

  20. Commercial Platforms What is J2EE? • J2EE SDK 1.3 (Sun) * • WebLogic (BEA Systems) • WebSphere (IBM) • iPlanet (Sun & NetScape) • JBoss (Open source)

  21. What is J2EE? What is Application Server • Application servers enable the development of multi-tiered distributed applications. They are also called “middleware” • An application server acts as the interface between the database(s), the web servers and the client browsers

  22. Application Server: Key Services

  23. JBoss- Application Server

  24. What is J2EE? J2EE Components • Java Servlets • JavaServer Pages (JSP) • Enterprise JavaBeans (EJB)

  25. What is J2EE? Overview of Servlets • Container-managed web components • Replace Common Gateway Interface(CGI) or Active Server Pages (ASP) • Generate dynamic response to requests from web based clients • Synchronize multiple concurrent client request • Serve as client proxies

  26. What is J2EE? Servlet Operation • Server is Java program that runs as separate thread inside servlet container. • Servlet container is part of web server • It interact with web client using response request paradigm

  27. What is J2EE? JavaServer Pages (JSP) • Text based documents describe how to process a request and create a response • Contains HTML or XML and other JSP elements defined by JSP specification. • Are Installed on web server • are web components that sits on top of java servlet mode.

  28. What is J2EE? JSP Advantages • Performance • Runtime characteristics of servlets • uses Lightweight threads: Doesn’t start new process for each request, Initialized once and persists in memory for multiple requests, cached • Automatic recompilation of modified pages • Server side processing • Programming • Emphasize use of reusable components • Write Once , Run Anywhere properties • Extensible through custom tag libraries • Provides front end access mechanism to EJBs

  29. What is J2EE? Parts of JSP Pages Directive <%@ page import=“java.util.”, MVCApp.Cart, MVCApp.CartItem” %> Declaration <%! Iterator it = null; CartItem ci = null; Vector cpi = null;%> Raw HTML <html><head><title>Shopping Cart</title></head></html> Action <jsp:usebean id =“Cart” scope = “session” class = “MVCApp.Cart”/> Scriplets % Cpi = cart.getCartItems ( ); it = cpi.iterator(); While (it.hasNext()){ci= (Cart Item)it.next(); %>

  30. What is J2EE? Parts of JSP Pages • Expression <td<% = ci.getTitle() %></td> <td align =“right”><%=ci.getQuantity()%></td> • Implicit Objects <% string action = request.getParameter(“action”) ; %>

  31. What is J2EE? Enterprise Java Beans (EJBs) • Entity Beans • Represent persistent business Entity • Persisted in storage system ( usually Database) • Might contain Application logic intrinsic to entity • Session Beans • Perform work for individual clients on the server • Encapsulate complex business logic • Can coordinate transactional work on multiple entity beans

  32. What is J2EE? States and Persistence • Session beans can be • Stateless- belong to client for duration of a method call • Stateful- belong to client for duration of client conversation • Entity beans can have • Bean-managed persistence- The developer writes SQL code to retrieve,store and update database • Container managed persistence- The developer provide database mapping information that allows the container to manage persistence

  33. What is J2EE? Example of EJB Application • It consists of number of clients accessing session beans and entity beans • Each Session bean provides specialized processing on behalf of client e.g. Travel Agent session bean makes travel reservations while Flight Scheduler bean schedules planes to fly on various routes. • Each Entity Bean represent different type of business entity. e.g.Passengers, seats, planes, flights are entity beans

  34. What is J2EE? Example: Travel Agency

  35. How to use J2EE? How to use J2EE ? • Using J2EE SDK 1.3.1 to Design, Develop, Assemble and Deploy Applications

  36. How to run J2EE application on J2EE SDK 1.3.1 • Preparation • Write and compile codes <Start J2EE SDK> to Assemble, Deploy, and Run the application • Packaging • Creating the J2EE Application (.ear) • Creating the Enterprise Bean (.jar) • Creating the Web Client (.war) • Deploying • Running

  37. Preparation • Install J2EE SDK 1.3.1 on your system • Set Environment Variables • JAVA_HOME = root directory of J2SE SDK installation • J2EE_HOME = root directory of J2EE SDK installation • PATH = %PATH%;%JAVA_HOME%\bin;%J2EE_HOME%\bin • CLASSPATH = %CLASSPATH%;%J2EE_HOME%\lib\j2ee.jar

  38. Creating Web Component When web client such as browser communicates with J2EE application, it dose so through server-side objects called Web components • Writes and compiles the source code • Bundles the .class, .jsp, .html files into WAR file

  39. Remote Interface Remote Client EJB Home Interface Creating Enterprise Bean An enterprise bean is a server-side component that contains the business logic of an application • Write and compile the source code • Package the bean’s classes into EJB JAR file • Remote Interface • Home Interface • Enterprise Bean Class

  40. Remote Interface • WebAddressAccount.java • defines the business methods that a client may call. The business methods are implemented in the enterprise bean code public interface WebAddressAccount extends EJBObject { public String getUrlName(); public String getUrlDescript(); }

  41. Home Interface • WebAddressAccountHome.java • defines the methods that allow a client to create, find, or remove an enterprise bean public interface WebAddressAccountHome extends EJBHome { public WebAddressAccount create(String urlName, String urlDescript); public WebAddressAccount findByPrimaryKey(String urlName) ; }

  42. Enterprise Bean Class • WebAddressAccountBean.java • implements the business methods public class WebAddressAccountBean implements EntityBean { public String getUrlName() { return urlName; } public String getUrlDescript() { return urlDescript; } public String ejbCreate( String urlName, String urlDescript) { insertRow( urlName, urlDescript); } public String ejbFindByPrimaryKey(String primaryKey) { result = selectByPrimaryKey(primaryKey); }

More Related